Merge remote-tracking branch 'cm/cm-11.0' into kk-4.4

Conflicts:
	media/libstagefright/DataSource.cpp
stagefright: Fix playback for mkv files with lacing

Most mkv files having 'lacing' in their audio section to save space.
Android did not handle this properly, sending all frames in the block
with the same time code, which causes stuttery playback.

Change-Id: I4dc76e7c2a53126c7fbdd3628fe7d339d2e3364e
Merge remote-tracking branch 'cm/cm-11.0' into kk-4.4
DataSource: Split off ffmpeg sniffer to a second pass, and only if necessary

ffmpeg's sniffer is intended as a grab-all-that-doesn't-work-elsewhere
extractor. Unfortunately, this causes two issues:

- As written, it requires ffmpeg to whitelist any extractors supported
by stagefright, or else it will blindly override them. This has codebase
sync issues, as shown by the VP9 and WAV accidental overrides
- It imposes an in-depth analysis of _all_ media, even that which we
want to be processed quickly by shipping stagefright plugins (hardware
or not). This is mostly noticeable in network streams and thumbnail
generation.

This patch moves FFmpegExtractor to an independent sniffer queue, and
it only invokes it when the regular MediaExtractor hits 1 of 3 conditions:

1 - The confidence in the identified container type is low
2 - No container is identified at all
3 - A video container was found by other extractors, but only 1 stream
(audio or video) was identified.

Change-Id: Ib96ff4f6bc06223fe0e819a57560d3c872a79ddd
Merge remote-tracking branch 'cm/cm-11.0' into kk-4.4

Conflicts:
	media/libstagefright/DataSource.cpp
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
Improve MPEG4 track estimates, much more accurate at predicting final file size.

The algorithm improvements addressed the following:
- The stsz table was not collapsed to a single entry if all samples were the same
  size (apparently accidently removed in a previous submission).
- If the moov box exceeded the size of the preallocated space at the head of the
  file, it would be unused and needed to be accounted for.
- Added missing estimates for the variable sized audio/video/codec specific
  entries in the trak box.
- Added missing estimates for the fixed box overhead, allowing much tighter
  margins on the overall estimate, and thus more recording.
- Accurately calculates the size even if the file is streamable; this is
  necessary because applications such as MMS (as discovered in the linked issue
  below) which use larger file sizes have hard limits on what can be
  transferred.

Note that if new additions are made to the moov box, the estimation algorithm
should be updated appropriately now due to the lower margins.

https://bugzilla.mozilla.org/show_bug.cgi?id=987546

Change-Id: I727a37be94bc5f1d6fbc2c66777310a62dc8347c
Signed-off-by: Andrew Osmond <aosmond@mozilla.com>
Merge remote-tracking branch 'cm/cm-11.0' into kk-4.4
Merge tag 'android-4.4.3_r1' into kk-4.4

Method of merging: Reversed Merge and some magic spells

Android 4.4.3 release 1

Conflicts:
	media/libmedia/AudioTrack.cpp
	media/libstagefright/ACodec.cpp
	media/libstagefright/MPEG4Extractor.cpp
	media/libstagefright/MPEG4Writer.cpp
	media/libstagefright/TimedEventQueue.cpp
	media/libstagefright/Utils.cpp
	media/libstagefright/matroska/MatroskaExtractor.cpp
	services/audioflinger/Threads.cpp
Merge tag 'android-4.4.3_r1' into HEAD