Squashed merge of cm-10.2

Summary:
qcom: Split off caf AUDIO_VARIANT support from QCOM_HARDWARE

One does not imply the other, add a different flag to allow using
them independently

Change-Id: I7fe0c0391967132a65f86f0c5f4bc0f54d50777d

frameworks/av: init rc to avoid effect's fault state

Effect command doesn't necessarily fill cmd return code into &cmdStatus,
so we should initialize cmdStatus to avoid uninitialized value propagates
to upper stack caller.

Change-Id: I2a2985e3010f0d7b8aedf9244a6faabdf05740ac
CRs-Fixed: 517766

libstagefright: enable smooth-streaming based on shell property

Enable smoothstreaming in Acodec/OMXCodec if shell property
mm.enable.smoothstreaming is set to true.

Change-Id: Ic5d64623c3001144f36562c8abf4b5f7be42f1e0

frameworks/av: fix for testAACEncoder CTS testcase

- testAACEncoders CTS testcase is failing for
  Hardware aac encoder use case

- hardware encoder has bitrate limitation
  due to which  CTS testcase is failing

- Removed hardware AAC encoder component from MediaCodec list,
  added in OMXCodec path on specific request from
  Stagefright recorder

Change-Id: Idff8abf4b768f63262da0576768fb13c9d6df1de

frameworks/av: AAC CSD support for MediaCodec path

- AudioFlush CTS test case is failing for AAC

- AAC Codec specific data is missing for
MediaCodec path for AAC if we use Qualcomm
ExtendedExtractor for demuxing

- Added CSD buffer while converting from
metadata to message , which can be used by
ACodec/MediaCodec

Change-Id: Ic8197138f5107f2a6026c28847e74987d91acc16
CRs-Fixed: 509575

audioflinger: Do not apply effect on multichannel content

-Do not apply effect on multichannel content.
-Effects are applied only for mono or stereo.
CRs-Fixed: 484078

Change-Id: I623d40f926d5dd80e74f9aa2f98448158518047e

stagefright: synchronously change nativewindow crop

Only change the nativewindow crop before queuing frames
with the new crop.

Change-Id: Icd8a84c82e66a8be3d6bc1675c777b1de8dc39b9
Signed-off-by: Lajos Molnar <lajos@google.com>
Bug: 9395753

media: Fix merge issues

Change-Id: I89ab96a1ae415822c6d35e244fb3ebed389a1de6

frameworks/av: enable voip flag based on channelcount

voip flag should be enabled based on channelcount instead of
channelmask. Some of voip apps like viber may not use
AUDIO_CHANNEL_OUT_MONO but still configures to single channel
like by using AUDIO_CHANNEL_OUT_FRONT_CENTER.

Change-Id: I3f69a5c50b6e1bb9336e08eb9619e15de2d8a532
CRs-Fixed: 511713

audio: fix meta MIME type failure in MPEG4Writer

- MIME type info included in source->getFormat()
  is not updated properly because only temp
  variable is updated in AudioSource::getFormat().
  MIME type string contains garbage value and it
  results in invalid audio formats.
  MPEG4Writer returns ERROR_UNSUPPORTED and tunnel
  mode recording with 3gpp format fails
- Fix this issue by assigning return value of
  getFormat() to a local variable, and check the
  return value of findCString.

Change-Id: I242fa25a5d4f7b7e2c88fdd855208dcd42883b6c

audioflinger: Fix for removing noise while resuming playback after pause

-Issue: While resuming playback after pausing and seeking to backward,
there is a noise.
-Rootcause: When Resuming a Playback after Pausing and seeking,
AudioResampler's reset() function is resetting their member
variables but derived classes' s member variable are not resetting.
This is causing a noise in Playback because AudioResamplerSinc,
AudioResamplerOrder1 and AudioResamplerCubic's member variables
pointing to some previous state/values.
-Fix: To reset the derived class member variables,
override the reset function in all the derived classes.

Change-Id: I0584947ac203f9470cdc4a680ebccadf60e4e7db
CRs-Fixed: 482838

audioflinger: Fix buffer size for VOIP

 * Crazy ternary is crazy.

Change-Id: I9d076bf8c72f4266be054b093889ec763bf2bb00

libstagefright: Add legacy LPAPlayer

Change-Id: Ie2551345bbf047c022d1fecbb7cb2cc4a4c97d72

libstagefright: Fix to free buffers in error scenarios

MediaBuffer objects are not freed if component transition from
IDLE->EXECUTING or EXECUTING->LOADED fails (or if the
OMX_CmdComplete messages are dropped due to an earlier error)
Additionally with native buffers, the corresponding
ANativeWindowBuffers are not cancelled back in the above scenarios.

Change-Id: Idad02f7bb6bbfcd30947624148ea996a4a8f18b3

libstagefright: Add 2 APIs (suspend and resume) in Mediaplayer

- API:suspend() will just pause the player and release all the decoders
  instead of release the whole player
- API:resume() will just init the decoders again
- Add a check in onVideoEvent()
  to make sure the first seek operation will seek the next i-frame

Signed-off-by: jmeng <jmeng@codeaurora.org>

Change-Id: If16dc1c9dae2f28df8a969b1044ca67d23a8846b

libstagefright: HTTP Streaming fixes

- Stop fetching on reaching EOS
- Disconnect datasource in player's reset
- Send buffering complete when seek is issued
  when player is in buffering state

Change-Id: If1650f02ffda10e0d8ca4a9c7fd0a5681d05e75e
Signed-off-by: jmeng <jmeng@codeaurora.org>

libstagefright: Fix AV sync issues

- Add edit list support for video playback.

Change-Id: I67cb9026255ddfe2d946a6e5972705b1b0c8a527
CRs-Fixed: 362885

libstagefright - Fix timestamp overflow

 - change time related variables to 64 bit to avoid overflow
 - composition time calculations were having overflow in
   SampleIterator and it propagates to the rest of the time
   related information for the frames

Change-Id: I035cbfaced1215eb1afd2c6cb900116e46006994

libstagefright: Add fix for mpeg4 data partition clips

- QC firmware does not support mpeg4 clips with data partition,
  but Google software decoders support these clips.
- Add logic in OMXCodec to parse the VOL header passed from
  QC parser to OMXCodec through kKeyRawCodecSpecificData
  for data partition bit and fallback to software codec if it
  is found.

CRs-fixed: 488740
Signed-off-by: jmeng <jmeng@codeaurora.org>

Change-Id: I04772d7173a075b70f7a34bef2d2877b280c7f07

libstagefright: Fallback to software encoder for high resolutions

Add error check conditions to fallback to software encoder if
q6 encoder fails in configure codec. Q6 encoder fails
for resolutions greater than FWVGA

CRs-Fixed: 511608

Change-Id: I4d765f45cd3b9c128260e7c96f139b671950d0ce

libstagefright: dynamic port reconfig handling

- Add support for dynamic port reconfiguration handling in OMXCodec

CRs-Fixed: 500703
Change-Id: I711d4b1114be791789607bc5dabc6d4496c182c0

libstagefright: Checks before freeing buffers on a port

- OMXCodec calls dequeueBuffer on the NativeWindow in a loop
  and registers output buffers with the OMX component.
- If a dequeueBuffer fails, the buffers already registered
  with the OMX component were not getting freed laeding
  to a memory leak.
- On an error, check state of OMXCodec before freeing buffers on a port.

CRs-Fixed: 393352

(cherry picked from commit f2e982497c5d16db14812ee09cef5cbdf0d96331)

Change-Id: Ib4eb48c189197d253e4175708ce1778b9c92f315

audio: Add A2DP notification support

 * Forward porting this code.
 * Sends notifications to legacy LPAPlayer for routing A2DP thru LPA.

Change-Id: I53eebda30b2e5cd60eeac5eb2a4cdb53e38381c9

Fix SoundPool.play() looping regression in 4.3 DO NOT MERGE

The change I7370d6e59a7ef26dfb284a8b058d5ab2e0a42ccf caused a regression
in SoundPool looping when using SoundPool's streaming implementation.
This reverts a portion of that change.

Bug: https://code.google.com/p/android/issues/detail?id=58113
Bug: 10171337
Change-Id: I8af0dc8683a7c7f225c80f0eb4d39770667b52e5

libmedia: Featurize QCOM's VOIP feature

 * Not all targets will support this.

Change-Id: I89a444c9ac8be3dfcaeedb599179e31383fdfec2

audioflinger: Fix for race conditions in direct audio track

-Issue: Mediaserver crash is observed in direct track functions.
-Rootcause: Between write and flush functions, write and destructor
effectpool buffers are accessed without any synchronization that
might lead to operations on null buffers and cause crash.
-Fix: Use mEffectLock to synchronize access of effectpool buffers.

CRs-Fixed: 515107
cherrypicked from Ib071361c65b390f9486c0a080a9391f176392b30

Change-Id: Id9e14a054d699ec803e23619ef475696b0021d4f

Fix typo

Change-Id: I179187b33f666dff88b57a4c24d7507eee0219cd
Signed-off-by: Rohan Mathur <rohanmathur34@gmail.com>

Merge branch 'cm-10.2' of git://github.com/CyanogenMod/android_frameworks_av into jb-merge

Test Plan: win

Reviewers: randall.rushing, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D354