libstagefright: Fix ANR issue in HTTP Streaming

The root cause of the ANRs during this usecase is the
blocking nature of the read calls on the network data
source due to which application thread gets blocked on
some lock in framework.

Fixes ANR during seek/pause during HTTP streaming
* Non-blocking read implmentation for NuCachedSource2
* Other framework related changes to handle underruns

Change-Id: Ief280b7e23727606746e1ca2bf4caa4a3044b7bc
Add 2 APIs (suspend/resume) in MediaPlayer

- API:suspend() will just pause the player and release all the decoders
  to replace release() which will release the whole player
- API:resume() will just init the decoders again,
  then start() will be called to start to play the streaming
- Add a check in AwesomePlayer::onVideoEvent()
  to make sure the first seek operation will always seek the next i-frame

Change-Id: Ie4c82906a2a056378119921a656128ebdc1007c4
[libstagefright] : camcorder pause-resume implementation

- Added pause resume feature in camcorder app.so that
  user pause recording and resume later which results
  in a single recorded clip.
CRs-Fixed: 587051

Change-Id: Ib82a93009348d997a4b8343b8b417b433be4c9df
libstagefright: Fix crash during seek

OMXCodec state is changed to EXECUTING when flush
is complete. Update assert condition to check
EXECUTING state instead of FLUSHING.

CRs-Fixed: 607762
Change-Id: I12b3eedfc83e00578d70af3ef903c5a26ccde3eb
 libstagefright: Signal input EOS after last buffer is released

-In offload playback, sink stop is called at EOS from the sink call
 back when input EOS is reached. This is called before the last
 buffer is released.
-During seek to the end of clip ,drain can complete even before
 last buffer is released. This can cause playback to switch to
 next stream.
-Fix by ensuring sink stop is called only after the last buffer is
 released.

CRs-Fixed: 607104
Change-Id: I9cc45cc25b5f87dd878b26f76ea741323a0242a6
AwesomePlayer: Enable audio offload for widevine

- Set offload parameter for ADTS compressed data
- Remove offload audio check for drm content
  so that widevine goes through tunnel mode

Change-Id: I383fd315becc714f5bad08ef11ab1da4730b55fc
libstagefright: Do not offload HEVC AV decoding

- Add compress offload exception for HEVC audio
  decoding.

Change-Id: Id0831ec779ca1704533e3f24f0b6d72968edb44d
CRs-Fixed: 599669
libstagefright: fix force close issue when mute MPEG4 clips

- Forgot to get ESDS when convert message to MetaData for MPEG4 decoded
  clips
CRs-Fixed: 600462

Change-Id: I2e73f42b641b0224cdf37a81fee611e9856235f0
stagefright: do not offload LD-AAC decoding

For now, do not offload LD and ELD AAC decoding because there
is no way to know if it is supported by the audio DSP implementation.
The longer term fix will be to have mapMimeToAudioFormat() use the
audio object type in track metadata to refine the AAC format and the
audio HAL list supported AAC profiles.

Change-Id: Iaa88ecf3f4ae42ad48c1b42a9b007dd80eb88147
stagefright: do not offload MAIN-AAC decoding

-Disable compress offload playback for AAC-MAIN
 format

Change-Id: Id0bc9da7c35d2b7b6913fd0793e06622df326e9c
libstagefright: Fix DP Parsing issue with mpeg4 SP,ASP

- DP partition logic returns true for mpeg4 clips with SP ,ASP
  profiles.
- Fix the issue by parsing additional fields in the ESDS atom

CRs-fixed: 556619

Change-Id: I69c719011e1a0d2a0b0ae5a9b504b7cce443866b
Audio: Add Pause/Resume in AMR-WB tunnel recording

- Stopping AudioSource will be implemented when
  Pausing the SoundRecorder. However, it will
  be redone when stopping the SoundRecorder which
  will cause the exception.
- When it stays at Pause state, avoid to redo Stopping
  AudioSource

Change-Id: I2aeddd1ce4e3366660012b39241546ee305667fb
stagefright: Various cleanups

Revert "framewroks/av:Fix ANR at the end of video recording"

This reverts commit 0868da69c72a30f46bd333adac86e93de7625709.

Change-Id: I5ace469719ed8552c89ddf7939b6e033bb30dc77

stagefright: Add missing include

Change-Id: I27dff95c5307db50d0d53dc4aa76b9827df56599
stagefright: Use pause/flush logic for all targets

 * This is needed by the encoder pause/resume support.

Change-Id: I9f1a14da4b9755fd307495cdba0dc94dbc8c78ff
audio: Add support for tunnel mode recording and compress voip

- Use modulo operator for common block buffer handling. Common block
  size is rounded to power of two. This limitation is avoided with
  modulo operator.
- Add support for tunnel mode recording
- Add support for compress voip

Change-Id: I95cdfff729affd784141487521c9f2f714221d11

audio: check audio mode to enable voice path for VoIP apps

- Add check for MODE_IN_COMMUNICATION to enable voice path
for VoIP applications

Change-Id: Ib603c6321c935d3b1313c2841b09eea932aa13f3

audio: Restrict opening of voip direct output to one instance

Avoid opening of voip direct output track if it is already in use
by another voip application.

Change-Id: I740bbb9e7153c8871c296f1ec5d8d68997391779

audio: check voip input sample rate to allow voip direct output

It is possible that some voip applications request different sample
rates for input and output streams. Avoid opening of voip direct
output if the voip input is already opened with a different sample
rate.

Change-Id: I5669e2a0880ffed0c10cde21da8994c2b47e1878
CRs-fixed: 601785
AudioFlinger: Remove unwanted update of track generation

PlaybackThread::threadLoop unncessarily updates the track generation
before waiting for a pending aync write. This is unncessary and
leads to excess calls to the power manager service for updating
uids.

Change-Id: I1284d79da3be6495acb19a97c81b3ab8db6dbb12
(cherry picked from commit f10fdf3ac4aced7d64bd0d1f05cc886271436685)
(cherry picked from commit 48568df4edf4d9b98c4d05bcfae3770c91f3be7f)
AudioTrack: Fix for race condition

This fixes a race condition between releaseBuffer and flush.

An AudioTrack::releaseBuffer() can be delayed (pre-empted) by
AudioTrack::pause/flush() and ServerProxy::obtainBuffer() calls leading
to a situation where an incorrect position is copied to the cblk

<<Change to be tested>>

Change-Id: I70074d4824ba8c7fa86c9f9ef8cc182de9172ab9
(cherry picked from commit ec237ff01ca194bf0e29933f916a30b8f83c8ace)
(cherry picked from commit 6984cd7b9e99ffa48872cf9316c68d5ae51ad3c5)
add Sony camera parameters

Change-Id: I4d8af24db1873776ad8deca75516f6e0840f1a62
libstagefright: Add custom IOCTL for prefetching CMA data for wv playback

trigger allocation of cma pool at start of drm playback

Change-Id: I6c15b31ff3147739f9d837a2a2b6e135cc918e99

libstagefright: Prefetch CMA data for secure playback via MediaCodec

Trigger allocation of cma pool at start of drm playback in mediacodec mode.

Change-Id: I1ce09f3c9013cb815f1ab0e729a099c7aae79ec5
libstagefright : Allow seek in RTSP VOD streaming using Helix Server

- In the current design,when the server sends npt=0- in Play response,
we treat it as live stream, without cross verifying in SDP.
- Helix server specifically sends npt=0- for the Play Response
- This change cross verifies the npt in SDP and if it is a VOD
clip, the duration returned is greater than Zero, and we allow seek.

Change-Id: Ic76510fa4d80ef9051a5d6d923bd5d757c279f19
CRs-Fixed: 498057