camera: Disable extra HDR frame on QCOM_HARDWARE

Qualcomm camera HALs default to adding an extra zero-exposure frame
to HDR snapshots; this is breaking third-party apps, and we don't
use it in system-bundled apps, so disable it unless explicitly
requested by the client

Change-Id: Iecb868c5c344d972de7f36dc1bd9cc9fdbabaf4e
audio: mute duration at the beginning of recording

-AudioSource mutes for predefined duration (kAutoRampStartUs)
 at the beginning of a recording. Current kAutoRampStartUs
 is not sufficient to mute the shutter sound click on
 B-Family devices. Sometime shutter sound is getting recorded
 with the current kAutoRampStartUs.

-Issue with calculating muteDuration from getOutputLatency is,
 more delay is getting added for Bt(~1 sec) which is really not
 required.

-Fix is to use constant mute delay which is appropriate

Change-Id: Ied20dc44c56cc74c74fb001383d3c533cb54b632
CRs-Fixed: 636491
libstagefright: Fix to handle EAGAIN error on first read to source

 -Some of AV streaming clips are not played
 -In streaming use case when source does not have sufficent data it
  return error EAGAIN on first read request, player ignore this error
  and treat it as a first buffer.
 -Make the read request again to source on EAGAIN error.

Change-Id: I3feaccce757c17c4e80e6d62375c3d700ca29e72
stagefright: yield callbackDispatcher to writer only for video

Letting Writer run increases the probability of dispatcher
not getting the lock when it comes back with the next message.
This adds an extra sleep-wakeup and increase power consumption.

Since Audio dispatcher handles more messages, this behavior
is profound in case of audio. Contain yielding business to
video only since this optimization is not required for audio.

CRs-Fixed: 651233
Change-Id: Ie24be4522b29fa191a88a777293d39f8e7c91353
MediaExtractor: Add more skip conditions for the second-pass extractors

If the stream's container is opaque (DRM) or a known skip condition
(cached-source MPEG4), don't push it through the deep scanner

Change-Id: Ia9d60180b5d177714d206fc7dc94da93b37a048e
audio:Avoid VideoLagUpdate if there is no AudioPlayer

-When AudioTrack is failed to initialized, mAudioPlayer
 is deleted in onVideoEvent but onVideoLagUpdate() is still
 trying to access mAudioPlayer which is leading to a crash.
 The function onVideoLagUpdate() is used to notify if video
 is lagging behind audio. So this function is no longer
 valid if AudioPlayer is deleted.

-Fix is to add a check for AudioPlayer in onVideoLagUpdate,
 which will avoid onVideoLagUpdate() if there is no
 AudioPlayer

Change-Id: Ie8dbfc1995a3da88a4a435ec2de86b1c22a07c65
CRs-Fixed: 647200
NuPlayer: Fix ANR while resetting RTSP playback

- When network is poor, the response of RTSP teardown won't be received
  in time, so ANR will happen.
- With this patch, a teardown message will be sent when timeout expires,
  in order to avoid ANR.

Change-Id: I3f9efd9fefa66104ad452559ced5ff5218d73a66
CRs-Fixed: 650866
libstagefright: Fix to free buffers in error scenarios

- MediaBuffer objects are not freed if component transitions 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.

CRs-Fixed: 640236

Change-Id: I62bdcde5d52ee65cba457a9b5e938e0390d8d9b4
audio: Fixed condition to load AAC HW Encoder

- UseQCHWAACEncoder checks if the bitrate passed by the
  client is in the supported bit rate range of the
  AAC Hw Encoder. It is wrongly compared with the
  sample rate passed by the client instead of bitrate
  This is leading to loading of Hw Encoder even when
  unsupported bitrate is passed

- Fix is to correct the condition to compare with bitrate
  instead of sample rate

Change-Id: I88f4cbcf476dab8bd2bd44860b75ee3ffc3a5bb9
CRs-fixed: 659716
libstagefright - Fix seek on audio having empty stss block

Ignore stss block for audio even if its present, all audio
sample are sync samples itself, self decodeable and playable.

Parsing this block for audio restricts audio seek to few entries
available in this block, sometimes 0, which is undesired.

CRs-Fixed: 664870
Change-Id: If3208d5c0557d3eaeddf875d6c6762bd870c439b
libstagefright: set frame packing from codec config

- From ACodec call to configure codec is triggered but there is no frame
  packing call
- In default configuration, clips may fail if the proper frame packing
  mode is not set
- Codec config and frame packing are currently done in two separate calls.
  Fix is to trigger frame packing from within the codec config call as
  there is no reason to call each separately

Change-Id: I0455d446cd862b5e7373e3bcb9ad4bfdf7826d18
CRs-Fixed: 648894
stagefright: Fix mismerge

Change-Id: I893d4731bb9152c72ee680954efc44693ef49ada
Fix memory leak when filtering commands in insertCommand_l()

When AudioPolicyService::AudioCommandThread::insertCommand_l filters
a command from the queue, the AudioCommand* is removed from the
vector mAudioCommands by calling mAudioCommands.removeAt(). This will
destroy the pointer and compact the vector, but not delete the
AudioCommand object.

This patch adds code to delete a filtered out AudioCommand and its
data object mParam. However, mParam was void* and deleting a void
pointer is undefined behavior according to the C++
standard. Therefore, the data classes are modified to inherit
from an abstract base class with a virtual destructor.

The deletion of non-filtered commands in
AudioPolicyService::AudioCommandThread::threadLoop() was already
correct, as each case casts mParam to the proper type before
deleting.

This also fixes AOSP issue 36370.

Change-Id: I2b63838aff3608132aa496f964a929f78c4b6267

Conflicts:
	services/audioflinger/AudioPolicyService.h
av: QC AAC encoder supports 320KBps

Change-Id: Ic937a79cd081aa1ccde395d29c02111019454003
audio:Avoid AudioTrackThread if Track creation fails

-mAudioTrackThread is starting before the track creation.
 This thread is used to process the audio buffer, which
 is no longer valid if the track creation itself is
 failing.

-Fix is to check for the result of track creation and
 based on the result need to start the mAudioTrackThread.

Change-Id: Ic69e45f4269408ff60fe83390e9f8d0c895582e3
CRs-Fixed: 611668
stagefright: add ClockEstimator API and WindowedLinearFitEstimator

Change-Id: I74474c385848a8eab2ac0da7c069510378e2b217
Smooth out AwesomePlayer

Use clock estimator to smooth out audio time stamps.

Change-Id: Iec1ff30c011069d06ff8051fc4839d00895463d6
audioflinger: Stop resetting compress offload streams

 * This code should only be invoked for legacy DirectTrack.
 * Fixes issues with compress offload failing due to lack
   of metadata after skip / seek.

Change-Id: I4e2eef6421421532556ba411542cfe2f9c1e3802