ACodec: Add video codec fallback logic

- Check while onAllocate if codec is capable of handling video
  resolution. If not fallback\retry other capable components in the
  list

Change-Id: I3203275be23651dbd9ad7a7397526ac601a3350a
(cherry picked from commit 83275e26fcb454b52d3002613fb584219aae6b1e)
audioflinger: Fix cleanup of asynccallback thread

AsyncCallbackThread will not be spawned if the output
profile does not support non-blocking output or if the HAL does not
support set_callback API.

Add a check for validity of callback thread object before deleting it.

Change-Id: I3943f80abba3fd7f18fbfd6190bb884f773772b5
(cherry picked from commit 613d35913d78400cc794f7949da809d7e056fe4e)
libstagefright: Fix in AudioPlayer media time mapping

- Use seektime as the play position when player is still
  seeking.

Change-Id: Id92a07e3291280b17b83d53ff2e218acc3ee6020
(cherry picked from commit 5987252b74dd8cfb72cf860f3496fe129f9105cd)
stagefright: Fix AV sync issue for cached audio sources

Non-HTTP sources may continue to fetch audio data after video has
already seen a seek request causing audio to run ahead. When video
sees a seek request, audio should pause, resuming once it too has
handled the seek request.

Change-Id: Iddbf3d79f29bbe8bcdb4b07338c4a00734acd8e2
(cherry picked from commit c7bc3dc70d08a5497b36d3e33f044baa48492987)
AudioFlinger: Offload track transition fix

Trigger state changes in OffloadThread on adding a new offload track.

Bug: 12530661
Change-Id: I95b62764c7ac041d470702e86b951f812eb0e70f
(cherry picked from commit 9763f0c1fcf65f58c2ef58cc156a3b28ca3e58ed)
audioflinger: Handle pause /resume in stopping state

-Pre-requisite:
 Perform seek on the clip. After seek the data remaining till EOS
 is little more than the driver and common block buffering.
-Framework state:
 Offload thread is waiting for signal from the HAL for a free
 buffer. Audio Player calls sink stop on reaching EOS. Audio
 track is waiting on obtain buffer for a free space in common
 block to send the last buffer. The track is moved to stopping
 state as input EOS is reached.
-Issue:
 Perform pause/ resume in this state(STOPPING), Audio playback
 does not resume.
-Fix
 Ensure resume is called in stopping state if frames ready is
 greater than zero.

Change-Id: I9268ab2a6cd1cc69a3ff23801f978f7a9f75a11b
(cherry picked from commit 8542a54c147fd908b08f9201d5205030a758a096)
AudioFlinger: Modify flush handling for offload path

Do not allow an offload track to directly control the offload thread
behavior. OffloadThread can check for any pending flush reporting
by its active tracks and decide to flush the HW or not.

Bug: 12530661
Change-Id: Ib33f023c942f6c091b618004136b153c38a6eef6
(cherry picked from commit 3d6a5667f4c780796ad032a96058b60bd99a5e35)
libstagefright: Handle offload fallback for WAV content

- For WAV content there is no OMX Source, use the AudioTrack
  as OMX Source for fallback.

Change-Id: Ifeaeb2cf8dd777d167b74eebd11803b7f130e857
(cherry picked from commit c6529d795bb65cc42f941a333d40a55c11ff0dc2)
audioflinger: remove unecessary call to HAL

On a flush, OffloadThread resets its state about HAL being paused.
For the sake of consistency, it is now expected that after a flush
as HW is no longer paused, the resume call is unnecessary.

Change-Id: I47d8b685dd23427bb44e24593124b4e42e4a315e
(cherry picked from commit 65c8123fb291dc377d80b27d95b9bceacc50adbb)