audio: Fixup BT A2DP for QCOM A-family

A- Family doesn't support separate output for a2dp , removed the
getA2dpOutput(). getDeviceForStrategy() is selecting the proper
device using mA2dpSuspended flag.

Change-Id: I0721e5cb9943f888645f6220334ee6707df96e0b
stagefright: Add more latency profiling

Measuring the startup latency from StagefrightRecoder start to
first frame camera callback. Also add profiling to CameraSource
start and StagefrightRecoder start.
Add profiling to measure reconfig.

Change-Id: I037da0b9bfbcea01522b19310d142247d4f02e96
stagefright: extendedstats: Synchronize logging mechanism

Add a lock to all public functions of extendedstats to prevent
clients from modifying the same resource at the same time. For example
two clients can call getLogEntry and without locks one will end
up traversing the vector while the other is modifying it, leading
to a crash.

Change-Id: I908e0ebcc01026c258554214338f43c5d1226eb7
libstagefright: Small buffer hint for PCM offload

Audioplayer when explicitly requesting PCM offload
needs to inform audio track that small buffers have
to be used. This is required to make sure that pcm
offloaded tracks work very similar to deep buffer
path. This hint is passed to the HAL which makes
the write calls are blocking. Handle the new
properties for pcm 16 and 24 bit offload in policy
manager

CRs-fixed: 749148
Change-Id: Ia7b2260ec6e4821a7dbbfcc3ec7719c334aa40f6
audio: Force audio to Speaker if requested during VOIP call

getDeviceForStrategy is returning AUDIO_DEVICE_OUT_USB even
when setForceUse is called with Speaker during VOIP call.
Actual Intention is to route audio for phone strategy to USB
device even after setForceUse is called with Speaker when not
in voice call. It is supposed to exclude VOIP call too

Added additional check for MODE_IN_COMMUNICATION so that
it returns SPEAKER when setForceUse is called with speaker

CRs-Fixed: 762521
Change-Id: I1c51128cc1c7bfce1cf6f1fde60b428d3a9379fc
libstagefright: Fix heap corruption from AudioSource

AudioSource allocates memory for member variable
mTempBuf in its constructor and deallocates during
reset, but mTempBuf can be dereferenced on event
EVENT_NEW_POS even after reset, since AudioRecord
instance can post this event while exiting threadloop
even after stop is called on AudioRecord.
Also reset is called from destructor only if mStarted
is true, which means the memory can miss deallocation
if start is not called before AudioSource instance is
destroyed.
Moving deallocation of mTempBuf to destructor
will solve both the issues.

Change-Id: Ie42f0894e6b3e7c7ea734814ab90d46ee2d7c753
Stagefright: use get(Input/Output)Buffer in async mode

Non-async mode uses get(Input/Output)Buffers to get the
buffer handles at start; buffer-IDs obtained after
dequeue() are used to directly reference the handles.
In async mode, MediaCodec calls-back when an input/output
is available. Relying on the initial buffer-list can lead
to race conditions when buffers are allocated or changed.
Hence use get(Input/Output)Buffer to query the buffer
handle each time and just-in-time.

CRs-Fixed: 765324
Change-Id: Ifc0b7558564a57bd9316d0f80ae9cf88dfd6a1f3
libstagefright: Fixed PCM Offload format check

Small buffer hint is getting enabled for other formats
too due to in-correct checks in AudioTrack and AudioPlayer

Fixed the checks so that it gets enabled only for PCM
Offload formats

CRs-Fixed: 767824

Change-Id: I46cce8d66d0299c8ec8b8b12592c69cfe0abde18
stagefright: Allow deep buffer mode for audio-only playback

 * NuPlayer is used across the board now, allow deep buffer for
   audio tracks if offload isn't available.

Change-Id: I0ad6bbcaa29d44d47b37b2f2d08a2af43c3fced5
stagefright: Cleanup of PCM offload checks

 * Put the checks in a single place.

Change-Id: I2d0d5b542593896e78bf989296de1a1d1e3a4963
Fix video/audio sync issue when audio track is changed

After user resumes playback in short period of time after audio track
switching, audio decoder will be null due to failure of fetching
stream type. However current routine is to resume video playback even
though audio decoder is null, which causes video/audio sync problem.

Change-Id: I4efeff18f55d46daa34ead71f77dbfa1016798a2
NuPlayer: Disable widevine flag for L3 content

Disable widevine flag for L3 content. This is
needed because Generic source considers widevine
playback to be L1 by default, without checking if
secure buffers are requested by the widevine source.

Change-Id: I4e33836dfa98554d5ae0cb8cc01c1c960ba86fb1
stagefright: Fix QCOM_BSP ifdef

Change-Id: I57d3f4111017ef23a1928e8d0caab0a1e0bded37
Revert "libstagefright: Fix QCOM_BSP_LEGACY cflags"

* This is unneeded now that the flags are set in build makefile

This reverts commit 965f5389194fe9922ddea75564ea72e4fba39f96.

Change-Id: I7b849bf2b8442b576d1c2bee26795ffdb90581b1
stagefright: Remove unnecessary QCOM_BSP flag

* Already provided by build makefile

Change-Id: Ica244932f82c93e0f883c603261d16c764a375f1