Introduce AUDIO_LEGACY_HACK to extend support for legacy devices

this is a dirty hack but does what it should.

if we build for legacy device, eg LG Optimus Black P970, we have to use
the ICS_AUDIO_BLOBS flag to get audio.

but if we add it, we get build breakages and if we remove it, we dont have
audio at all.

this hack allows us to set the AUDIO_LEGACY_HACK flag in the BoardConfig and
prevents build breakages.

as i am unsure if every device needs that, i couldnt wrap it around the
ICS_AUDIO_BLOBS flag, thus this new flag is added.

Change-Id: Id545a684fcdc0508f4135eb7a722a9b617595532
Introduce CAMERA_LEGACY_HACK to extend support for legacy devices

same typo of patch like AUDIO_LEGACY_HACK
fixes build breakage on p970 with the following flags set
-DICS_CAMERA_BLOB -DOMAP_ICS_CAMERA

if we remove these flags, it builds fine but we have no camera as well

Change-Id: Ie91a5059153ace383d8f2a7f1539cb77861dce05
screenrecord: Add audio support

Adds audio recording to the screenrecord system. Note that
while recording, the audio is muted from the device output,
and that the audio volume is controlled separately (so make
sure to turn up your volume if you hear nothing).
Audio from the microphone can also be recorded by adding
--microphone to the command line.

Change-Id: I97dfcaf3d93b786c5466e1f4215549e3d015bcf0
screenrecord: Enable SUBMIX_IN as well and cleanup on exit

While on Nexus 5/Nexus 7 (AOSP QCOM audio), trying to turn on
SUBMIX_IN fails and is not needed, it is required on Find 5
and N1 (CAF QCOM audio), or otherwise SUBMIX_OUT won't turn
on.
We also now release the audio routing as it wouldn't revive
the audio speakers otherwise.

Change-Id: I0f80a232304733e0b0a834b188b8cfa5b88915f3
[2/3] av: Audio Themes Support

On the Java side, Android has support for both a
Video Record Start sound, and a different Video
Record Stop sound. However, this part here only
supports one video recording sound.
We added support for RECORDING_STOP sound (by default,
the same as RECORDING).

Change-Id: Iaebddd8ebf8b21633e802589a4a6175492df8f29
libstagefright: bring back mistakenly removed codec quirks

http://review.cyanogenmod.org/#/c/59396/ has mistakenly removed
3 of the codec quirks that are required for certain audio codecs
on OMAP3.

https://github.com/CyanogenMod/android_device_lge_p970/blob/cm-10.1/configs/media_codecs.xml#L28

The implementation of the quirks are still in the upstream code
and they have nothing to do with Legacy HTC.

Change-Id: I2d47bc9cbb451675c5bac6e725c59b367ff458dc
libstagefright: Set initial buffer size for H264 codec

For Google h264 decoder, the input port buffer size is
set to 8192 bytes, and for usecases where data source
does not specify input buffer size, there is a crash on
assert when the buffer size is larger than 8192 bytes.

Added change to set input buffer size for H264 to 80k.

Change-Id: I5bc177cc5078b2acfc930ee2746960dc26ab9662
stagefright: OMXCodec: free allocated port-buffers if init fails

If an error is encountered while allocating port buffers, init
would fail and buffers already allocated would not be freed.
Move OMXCodec to ERROR state and explicitly stop omx component,
hence forcing free-ing up of allocated buffers.
Also defer setting port-status to ENABLED only after having
moved the component to IDLE and add graphicBuffer to port-
buffers-list only if setBuffer is successful.

Change-Id: I54ffb2a299376bf1716473e94948c36648d24b92
CRs-Fixed: 610702
NuPlayer: Fix parsing RTSP play response from special server

- In some non-standard server, a different play response will be returned,
  which will cause CHECK failure
- Change in parsePlayResponse(), to get the current track index

Change-Id: I467e3000732cf1506095b17dc29eed25e6701150
CRs-Fixed: 621854
stagefright: Omit audio from timelapse recording use-case

Timelapse recording is only valid for video encoding, but audio
is subjected to the same infinite wait. This can result in an ANR
if encoded data is not being produced. Only wait forever in video
use cases.

Change-Id: I37d34c2235d110dc8954b66d830891fdccc50c0c
Camera: Remove merge artifact

Change-Id: I5817d9f2a9410ef6ba4f5f0242406b410afbf0be
Camera: Avoid redefinition of ISO params

Change-Id: I5f283f6d3affb35ef6a24f00fdaac0ca8aa348ba
ACodec: Add video codec fallback logic

- Check while onAllocate if codec is capable of handling video
  resolution. If not fallback\retry other capable components in the
  list

Change-Id: I3203275be23651dbd9ad7a7397526ac601a3350a
audioflinger: Fix cleanup of asynccallback thread

AsyncCallbackThread will not be spawned if the output
profile does not support non-blocking output or if the HAL does not
support set_callback API.

Add a check for validity of callback thread object before deleting it.

Change-Id: I3943f80abba3fd7f18fbfd6190bb884f773772b5
libstagefright: Fix in AudioPlayer media time mapping

- Use seektime as the play position when player is still
  seeking.

Change-Id: Id92a07e3291280b17b83d53ff2e218acc3ee6020
stagefright: Fix AV sync issue for cached audio sources

Non-HTTP sources may continue to fetch audio data after video has
already seen a seek request causing audio to run ahead. When video
sees a seek request, audio should pause, resuming once it too has
handled the seek request.

Change-Id: Iddbf3d79f29bbe8bcdb4b07338c4a00734acd8e2
AudioFlinger: Offload track transition fix

Trigger state changes in OffloadThread on adding a new offload track.

Bug: 12530661
Change-Id: I95b62764c7ac041d470702e86b951f812eb0e70f
audioflinger: Handle pause /resume in stopping state

-Pre-requisite:
 Perform seek on the clip. After seek the data remaining till EOS
 is little more than the driver and common block buffering.
-Framework state:
 Offload thread is waiting for signal from the HAL for a free
 buffer. Audio Player calls sink stop on reaching EOS. Audio
 track is waiting on obtain buffer for a free space in common
 block to send the last buffer. The track is moved to stopping
 state as input EOS is reached.
-Issue:
 Perform pause/ resume in this state(STOPPING), Audio playback
 does not resume.
-Fix
 Ensure resume is called in stopping state if frames ready is
 greater than zero.

Change-Id: I9268ab2a6cd1cc69a3ff23801f978f7a9f75a11b
AudioFlinger: Modify flush handling for offload path

Do not allow an offload track to directly control the offload thread
behavior. OffloadThread can check for any pending flush reporting
by its active tracks and decide to flush the HW or not.

Bug: 12530661
Change-Id: Ib33f023c942f6c091b618004136b153c38a6eef6
libstagefright: Handle offload fallback for WAV content

- For WAV content there is no OMX Source, use the AudioTrack
  as OMX Source for fallback.

Change-Id: Ifeaeb2cf8dd777d167b74eebd11803b7f130e857