frameworks/base: LPA and routing api  implementation

- Integrated routing APIs for LPA with the new AUDIO HAL
- Integrated LPAPlayer for LPA Playback on 8660

Change-Id: I345f62afa53057261602042ac348d43333cc8732
libstagefright: Integrate LPAPlayerALSA for LPA playback on 8960

Change-Id: Ie7ec686bef7a8c0b41c06ae11bdf49f84e136197
frameworks/base: Fix for no audio while playing specific ADIF clips

- Now the SW AAC Decoder is OMX based and handles decoding from the
  beginning after the port reconfiguration. So it is not required to
  force seeking to the beginning when INFO_FORMAT_CHANGED received,
  after decoding the first frame.
- Removed the same to fix no audio issue with specific ADIF clips
  which reports INFO_FORMAT_CHANGED.

Change-Id: I057312d1f9e0e5ced26bb5234cbc79d95be53b1b
CRs-fixed: 321723
libstagefright: fix for crash in AwesomePlayer startAudioPlayer_l

-Issue: check(seeking) fails in startAudioPlayer_l for LPA playback
-Cause: LPAPlayer does not set seeking flag after starting playback
in the middle of a clip
-Fix: Set mSeeking flag and ReadOptions in LPAPlayer::Start

Change-Id: Iac91a2b328be41cb98f6fdfa7c62e0b93a3a48a4
CRs-fixed: 322725
frameworks/base: Fix for pause/resume issue while LPA playback

- If LPA playback is paused and resumed immediately, the audio
  resumes for sometime and then the playback switches to next
  clip due to error in OMXCodec.
- In the LPA pause implementation, the source, OMXCodec, pause
  is being called which does not handle executing to pause
  state transition. So this causes decoding issue while resuming.
- Removed unnecessary pause/resume API calls to OMXCodec to fix
  the issue.

Change-Id: Ic7713c43aeedd9ec4818def9275653e7756e3a91
CRs-fixed: 322324
libstagefright:Fix for no progress bar update while seeking at end of LPA clip

-progress bar doesnt update while seeking at end of LPA clip.
-EOS is not posted to Awesome player when i/p EOS is reached,all input buffers have been decoded
and response queue is empty.
-Post EOS to Awesome player when i/p EOS is reached,all input buffers have been decoded
and response queue is empty.
CRs-Fixed: 321961

Change-Id: I6f90ac577825d807b99e724b3948f7cca1478e8d
frameworks/base: Enable Audio effects for LPA output

- Added the support to apply Audio Effects on LPA output.

Change-Id: I08b64167e9beac7fbe84ad2610f0177766be7c7e
frameworks/base:Fix for memory leaks during LPA playback

-Sigkill errors while running audio monkey causing the device the monkey to stop
 Memory is getting critically low leading to background process getting killed
 by the OOM killer.
-Memory leaks during LPA playback is leading to memory exhaution.
-Fixing the memory leaks.

Change-Id: I546d2a08d33789b3433d8ea61c30f6cba02a9f7c
CRs-Fixed: 326720
libstagefirght: Update timeStarted to use system time in LPAPlayer::start

- Issues: Paussing LPA clips at the last second causes the control to
the end of next clip
- Causes: TimeStarted is not updated correctly if pause cmd is received
before decoder thread starts.
- FIX: Update timeStarted to use system time in LPAPlayer::start()

Change-Id: If01b397b251c8aa20feed581c260d5ff818a2834
CRs-fixed: 324298
frameworks/base: Prevent effects application in paused state

- The issue is that effects are being applied on the LPA buffers
  in paused state.
- After 3s in paused state, session of the playback is
  deregistered hence effects should not be applied
- The issue is fixed by stalling the effects thread till the
  playback is resumed and session for LPA is re-establised with
  MediaPlayerService

Change-Id: I87f0f1cfcaaaf0f95a7218f46ea76d043c84bb77
CRs-Fixed: 328300
frameworks/base: Syncronize resume and onPauseTimeOut

- All the mixer controls are closed 3s after pausing playback
  through the onPauseTimeOut function
- A scenario where onPauseTimeOut is closing mixer controls, a
  resume is issued, causes a crash
- Synchronize these 2 functions using a mutex to prevent
  concurrent execution.

Change-Id: Ic0e84423f7e3e4a26c441c73235e61d9a13c225d
CRs-Fixed: 329312
frameworks/base : Prevent pcm_prepare when A2DP is enabled

- pcm_prepare should not be called without setting routing
controls, as this will result in driver bad state.
- Fix the issue by calling pcm_prepare only when A2DP is not
enabled and routing controls are set.

Change-Id: Ic2db9224d70500c392fa31804844aa934eca633d
CRs-fixed: 327396
libstagefright: Flush ASM before closing the stream

- By calling pcm_prepare we can flush the driver and
  dsp so that playback close can issue an eos from kernel

Change-Id: Icb5249ff8c480405b4b8ac5ce5f995ed5d73bf0d
CRs-Fixed: 331532
(cherry picked from commit 8bdfa122ec7ff72f61ea01f932d96d94dc27f016)
libstagefright: Fix for seek issue in mp3 streaming playback

-Issue: In LPA playback if seek is issued, the pcm driver
starts after a fill buffer and write is completed. If pause is
issued before the driver starts, audio pause fails and results
to a sudden jump in the playback or to an EOS at random

-Testscenario: Flush,immediately followed by Pause in LPA playback.

-Fix: Pause is handled when the pcm write is completed. This is
acheived by a conditional wait on the pcm write done.

CRs-Fixed: 331099
(cherry picked from commit 6ce15986ee7f2155044f79c505ebcd5a310a6c0d)

Change-Id: I605316bba2d964ba3d52f6a7cc42e7e390d92fdf
libstagefright: prevent trigger for stale events

- prevent event thread from running if response queue is empty which
  means there is no buffer with the driver

CRs-Fixed: 336970
(cherry picked from commit 690fb2d96a58b2341e49e3424d7e0efe7093aad7)

Change-Id: Ie86a900e77175b2786cfe10fc0c64457e9fc4bae
libstagefright: Ensure pcm_prepare is called only when routing is
still active.

- LPAPlayer does Derouting, pcm_prepare and pcm_close during pause.
- pcm_prepare should not be called after derouting, as the driver
tries to prepare a session which is already derouted.
- This results in no backend errors in kernel for LPA Front end
session as the backend is already closed with derouting.
- Fix the issue by ensuring pcm_prepare is always called only
routing is still active.

Change-Id: I4b4eef7f9775b6141a5ec9a0eed82ca2f7a5c6d6
CRs-fixed: 341268
libstagefright: Add support in LPA for DSP timestamp.

Change-Id: Ie9525b0ab201b9de828a25ef1cd9731567f4610a
CRs-Fixed: 338065
(cherry picked from commit 2457cb32ec93a11e2a95d77557daaf6be0e1529a)
libstagefright: honor write done event during pause

Queue up completed buffers for decoding even if playback
is in paused state as there is concurrency between write
done and pause

CRs-Fixed: 340469
(cherry picked from commit c9116b67545c5d973c255fba55c031271d3c38a4)

Change-Id: Ifdc2cec4d92773ac279c02df7067bd95c32ca4a4
libstagefright: Fix A2DP seek to EOS issue in LPA

- In A2dp scenario, when seeked to EOS and 0 bytes returned by decoder,
  eos was not issued to the app. This resulted in no audio.
- Put the buffer back in the request queue in case of 0 decoded bytes
  and post an AudioEOS event to the app.

Change-Id: Icb2cc053d71d02c8adb90fc5be1922ea813331e9
CRs-Fixed: 339608
(cherry picked from commit cdcdc2e6c6967de31476b1ece3702b645989e1df)

Conflicts:

	media/libstagefright/LPAPlayerALSA.cpp
LPAPlayerALSA: Fix for acquire/release Wake-locks.

 -Requires a wake lock to ensure that 3s timer after playback runs
 in suspend mode to get into TCXO shutdown.
 -Add support for acquiring wake locks from mediaserver process
 -PowerService is used for acquiring/releasing wakelock

Change-Id: Icb21c319eee24aa38d56afcd8eddcb6315b74558
CRs-Fixed: 338542