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
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
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