libmedia: add pre jb-4.2.1 signature for AudioSystem::getDeviceConnectionState

With jb-4.2.1 the type audio_devices_t found in system/core/include/system/audio.h
was redefined from a typedef enum to uint32_t.  This causes the signature
of AudioSystem::getDeviceConnectionState to change in libmedia.so.
Any older than 4.2.1 prebuilt audio.primary.___.so binaries (such as mine from ICS)
may refer to the old signature.  This patch adds back in that reference.

Change-Id: Ie4f92eaec20d581c9bebc805cfd25f8558406e30
Signed-off-by: Hashcode <hashcode0f@gmail.com>
libstagefright: Add support to seek to zero

- Add CAN_SEEK_TO_ZERO flag in MediaExtractor to allow
  seek to zero, when previous button is pressed, for clip
  that can't be seeked.

Change-Id: Ic2761cc5bac2403ee1339da77ad02fde942a3437
OMXCodec: Re-implement requires-flush-before-shutdown quirk

Support is already there, but is not in the codec quirk reading list.
Re-implement it as required by Broadcom's OMX

Change-Id: I1beac06af8118dcf0c248b631bc8e6dbbab2c1d5
camera: Don't segfault if we get a NULL parameter

 * Values end up NULL on some drivers, don't crash.

Change-Id: Ic897dbd4629cf3af98c85f93be202c382dde806b
libstagefright: fix indefinate loop in QueryCodec

portFormat.nIndex is being incremented which is not
trustworthy since the nIndex value could be overriden
by the OMX Component,  which causes an indefinate loop
which inturn causes a memory leak and crashes the system.

OMX Component on encore and p970 exhibits this behaviour
(OMX.TI.720P.Decoder). This patch prevents stagefright
freezes when QueryCodec is called during Gallery Thumbnail
generation for videos and Adobe Flash playback.

Change-Id: I825c99ddecacbb927e22ac7d1a53facb26d95ff2
stagefright: Fix to play a specific Mp4 clip due to SYNCH_LOST_ERROR.

-Unable to play a Specific Mp4 clip.
-Mp3 playback is stopped if the Decoder errors out with SYNCH_LOST_ERROR.
-Ignore the frame with SYNCH_LOST_ERROR and play silence instead.

Change-Id: Id783af8a84f313ea31cd5454c8163928805a7072
libstagefright: Fix for FPS drop issue during A-V playback.

Issues:
-The AAC decoder was not updating the timestamp when EOS is reached.
-Logic to smoothen the real time update in AudioPlayer uses system
 time. This introduces corrupt timestamp during EOS.

Fix:
-Update the timestamp in AAC decoder when EOS is reached.
-Extrapolate realtime using system time in AudioPlayer when EOS is
 reached. Cap the value to realtime if  extrapolated time becomes greater
 than realtime.

CRs-Fixed: 384183 515066
Change-Id: Ice54501436431d2527fcd3d710d65d9732fcffdd
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: 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
replace ENABLE_QC_AV_ENHANCEMENTS to ENABLE_AV_ENHANCEMENTS

N/A

Signed-off-by: huangqiwu <huangqiwu@xiaomi.com>
fix build

N/A

Change-Id: Ic3aea6ab89af536e9a2eeb9f25fa6a9845215d88
Signed-off-by: huangqiwu <huangqiwu@xiaomi.com>
fix merge issus

N/A

Change-Id: I0070f37b5957dab91463b3188c7fdb9415ed33de
Signed-off-by: huangqiwu <huangqiwu@xiaomi.com>
audio: Add track to trackToRemove list when it is terminated

- PlaybackThread loop is continuing for direct output even after
  the track is terminated by the client. This is causing 2 direct
  tracks being active when client starts another session
- Fix is add the terminated track to tracksToRemove list so that
  this track is destroyed properly

  CRs-Fixed: 566808

Change-Id: I65f565d9c3a00e071174659ffb92f711dfd8742a
audio: Fixed framecount in AudioRecord

- Incorrect frameCount is passed to AudioRecordClientProxy,
  which is used while user side pointer is incremented
  This is causing distortion in SIP call
- Fix is to use frameCount of the shared block instead of
  frameCount passed by the client
- InputBytes initialization is also done in AudioFlinger

CRs-Fixed: 568988

Change-Id: Iab32234b198ff4d792eea4c4a82097028089013d
audio: update setParameter command time properly

-setParameter is getting delayed regardless of delay is
 present or not. Because setparameter command time is always
 getting updated with wrong values(previous values) with any
 commands.
-Fix is to restrict the updation of command->mTime always.
 Added check to update command->mTime, only when identical
 commands are present.

Change-Id: I10b94b19f64ef4f15495d34f009238a691d1b36c
CRs-Fixed: 568318, 569010
audio: Initialize LPA variables in audioflinger

 - During initialization of audioflinger, a number of
variables related to LPA are not set to default values.
This causes an undesired side effect that the first
effect in the effect chain is considered to be LPA
enabled. Since LPA does not execute effect processing,
switching xLoud on/off does nothing
 - Fixed by initializing member variables in audioflinger.

Change-Id: Ide06fb0e6804558388e6610cc7686f168591e4a5
scale the kMaxCttsOffsetTimeUs for HFR recording

-timestampUs & decodingTimeUs are scaled for HFR recording
-the difference between these is compared against non-scaled
constant(kMaxCttsOffsetTimeUs).
-fix provided to scale this constant(kMaxCttsOffsetTimeUs)
-and compare against the scaled time difference.

Change-Id: I08188423008d8f6a4824f2748d56a1e355d39a89
CRs-Fixed: 566695
AudioFlinger.cpp - audioConfigChanged_l set for srs Tunnel Device Switch

 - During device switch we were only setting the route
   but was not calling audioConfigChanged_l
 - Hence the effects for the new device would apply only
   when there is a config change.
 - Now we call audioConfigChanged_l during device switch
   setPrameter so that the new effects will be apply as
   soon as device is switched.

Change-Id: I641cd8a7d6ffb7423ccfaa45e4c29b1b5352e61e
CRs-Fixed: 548021
Revert "frameworks/av: AAC CSD support for MediaCodec path"

This reverts commit Ic8197138f5107f2a6026c28847e74987d91acc16
Currently AAC CSD is retrieved in MediaCodec using
kKeyAacCodecSpecificData. This support was added as part of
commit Id046b0d4bf96f029c1b6b5d78d753073e38ac841.

Change-Id: I54bc6204c1fe88f4e4545f501e6bd1bb2a8beaf9
CRs-Fixed: 527284

Conflicts:
	media/libstagefright/Utils.cpp