stagefright: Fix to play a specific Mp4 clip due to SYNCH_LOST_ERROR.

-Unable to play a Specific Mp4 clip.
-Mp3 playback is stopped if the Decoder errors out with SYNCH_LOST_ERROR.
-Ignore the frame with SYNCH_LOST_ERROR and play silence instead.

Change-Id: Id783af8a84f313ea31cd5454c8163928805a7072
stagefright: Remove assert for corrupt clips for AMRNB

Corrupt AMR NB clips were crashing media player
This was due to the assert in the AMRNB decoder.
To avoid this, post error and exit if corrupt
clip is played.
CRs-Fixed: 486681

Change-Id: I8f6809a896b91aaffa8f5ae17d8ae4a3920a4b73
libmedia : Add a NULL pointer check

- Print frame count in AudioTrack::dump() only if the control
  block is valid
CRs-Fixed: 435050

Change-Id: I1c08bd5f65aa5a3e4899d1ed94b5bb77ad510118
Add checks before removing an active buffer in OMXNodeInstance

With this change, OMXNodeInstance will remove a buffer from it's
active list only if OMX_FreeBuffer returns successfully.

Change-Id: I8f6b675cdf1cede60dfe0aebaa902139e44b1233
framewroks/av:Fix ANR at the end of video recording

- While doing video recording, when the recording
  ends ANR observed while doing stress test for
  many hours
- When the recording is stopped, audio HAL receives error
  from driver and  audio HAL propagates this error to
  AudioFlinger.  But AudioFlinger  is not sending error
  status to audio source to stop recording.  Because of
  this audiorecord thread keeps on waiting for buffers
  which is resulting in ANR.
- To avoid indefinite wait, a timeout of 1 sec is set for buffer
  in audioSource and after timeout, -ETIMEDOUT is returned
  to recorder thread.

Change-Id: Ic191c63d2a0f0144eb6d5b53e5c6d7c8602f44ba
CRs-Fixed: 479968
libstagefright: Fix for OMXCodec::read() getting blocked

- Sometimes notification sound is not heard if it is played
  and stopped multiple times in a short duration.
- If OMXCodec::read() gets blocked for filled buffers while
  in pause, it never returns as mFilledBuffers is always empty.
  Due to this AudioTrack destructor never exits as it waits for
  the AudioCallback thread to unblock it.
- Ensure OMXCodec::read() returns even if timeout occurs while
  in pause and handle the same in AudioPlayer by returning zero
  bytes in AudioCallback.
CRs-Fixed: 478768

Change-Id: I295ffa3d7ab836a8f36ae8c10c98c283a4c361d5
libstagefright: Query AudioSystem for suggested record mute duration

- AudioSource mutes a pre-defined duration (defined by kAutoRampStartUs)
  at the beginning of a recording.
- Instead, query the audio system for any ongoing playback streams
  and use its output latency to calculate the duration to mute the incoming PCM stream.
- This assumes all current playback threads will be paused once recording
  is started.
CRs-Fixed: 438149

Change-Id: Ifaf59a9c09c0ece956379e10c801cad4dacfc8f3
libstagefright: Use 64 bit offsets only when needed.

For enabling >2GB recording, 64 bit offsets are
needed for file writing. So, this feature was turned
on by default. This in turn increased the file size.
With this change, by default this feature will be
off and turned on only when required.

- Use 64 bit offsets for resolutions >= 720p.
- Limit maximum file size for recording to 4GB.
- Set max file size only if no value is set from the client
CRs-Fixed: 273144, 285785, 288319, 328461

Change-Id: Ica37cb0414642c68ada18e0b7ba184b55692c6f2
libstagefright: Fix for crash in sound recorder during device switch

 -Crash seen in sound recorder during frequent insertion and removal
  of wired headset

 -During device switch some time Codec's input buffers are too small to
  accomodate buffer read from source. Omx codec doesn't read the fix size
  buffer from source, during device switch scenario sometime buffer read
  from source exceeds input buffer size so it goes in error state which
  leads to crash.

Change-Id: Ica3e5b1c1833077df522bb8f78fb05dd43a45f36
 -Increasing the input buffer size fix this issue
CRs-Fixed: 488449
media, audioflinger: check for divide by zero possibilities and err

When output stream is not available to audioflinger due to any reason
, sampleRate and frameCount have zero values when trying to create
new Audiotrack. This might result in divide by 0 situation.
CRs-Fixed: 478480

Change-Id: I1236452594f125cbd08ec434afdc540c0bb5ac76
audio: update mFrameCount to fix audio playback failure

- mFrameCount was removed by mistake in AudioTrack::createTrack_l.
  This results in normal audio playback failure
- Fix this issue by updating mFrameCount with frameCount

Change-Id: If642e810b867314c613c1dbcc5e014d8b1de3733
frameworks/av: Add support for Quality Of Experience (QOE) events in MediaPlayer

- Add MEDIA_QOE event type
- Allow MEDIA_QOE event to be passed to Application after reset
  is completed, similar to MEDIA_ERROR

Change-Id: I71e3d9e1f5f934c5844d80c65c653b2702a22ca1
Indicate client process during streaming rebuffering

Change-Id: I199eb3bbbe398ef442dd03290c89592efb39dae4
 - Audio was not playing after buffering done during streaming
   of audio-video playback
 - Changed to indicate to client process that the track was disabled
   because of underrun.
 - It will then automatically call start() when data is available
CRs-Fixed: 491525
audioflinger: Fix monkey crash in audioflinger set parameter.

-Track ref ptr is initialized to direct track pointer only in create
 Direct Track although the descriptor is created in open Output
-If there is a set parameter coming in during this time it could
 result in a crash as track ref ptr is not initialized.
-Initialize track ref ptr to NULL when descriptor is created.

Change-Id: Iee887baee45a9e7b381f6e2ea2ab523a23689f6b
frameworks/av: Fix for failure in CTS MediaRecorderTest cases

 -Issue: MediaRecorder CTS test cases are failing.

 -Root Cause: Running the CTS test "testRecorderRandomAction" at beginning
  sets the huge file size and stargeFrightRecorder set the 64 bit file
  offset.
  In MPEG4 writer estimateMoovBoxSize depends on a static const
  variable which uses this file offset info.
  As the variable to calculate estimateMoovBoxSize is static const it
  remains same for next media recording session even if file size is small.

 -Fix: Don't use static const variable which is used to calculate
  estimateMoovBoxSize as its value may change depending on file offsets.

Change-Id: I6bd859fcd7951a4e78abc50bc99dab38e8284877
libstagefright: Flush the pending buffers when EOS is received

For the use case where the first frame in the buffer is EOS, decode
the aac config frame buffer to update the sample rate and channel
mode and flush out the buffer.
CRs-Fixed: 459334

Change-Id: I175dc531e00ec36a366a818366fa869cd6ccf5a1
libstagefright: Fix crash in media server mpeg2 playback.

Change-Id: Ifcbb8ed95751efb8aded6cdeb217fab82762a782
 -There is a check in dequeueAccessUnitMPEGAudio function in
  ESQueue that time stamp returned by fetchTimeStamp is always
  greater than 0
 -In the current scenario, valid time stamp set on the first
  frame is getting replaced in the sub sequent code by -1.
 -Fix is to reset the flag after first frame is identified
CRs-Fixed: 512218
libstagefright: post video events dynamically

Change-Id: Ie4c1ff727afc7b84db94f48d9d70e5c52dd6f98e
 - calculate amount of time to delay video event after render
   using the formula:
   delay = (us between frames)-(us taken by event)-(lateness)
CRs-Fixed: 434540, 514013
libvideoeditor: use vWidth and vHeight for buffer allocation

Change-Id: I2ab01b8ef79a3ad9b1eb737b2e9f1211a6e668c2
 - video editor detects crop information from decoder, crop
   width and height will override metadata width and height.
 - decoder is capable of sending crop information where
   crop width and height are smaller than actual resolution.
 - use actual metadata width and height for calculating
   buffer size.
CRs-Fixed: 452511
Camera: Enable Histogram feature.

Link the histogram enable/disable commands from
application to the HAL layer.

Change-Id: I7803da586a85720a8ec9ca98d61f6d67d75f40d5