AudioFlinger: mOutput->stream->get_latency must be inside mLock scope

Otherwise lock-ups during simultaneous playback of multiple
audio streams can happen.

Change-Id: Idd392761e50c1754f9740b7151fc90396542b909
camera: remove redundant QCOM_HARDWARE ifdefs

Change-Id: I9bccd7cb2fd3a7a7b3bda8002cf57ad21ce6b37e
camera: add missing symbols for HTC 8660 camera HAL

Forward port of patch from HTC 8660 missing symbols patch from ICS.

Change-Id: I9ed27e3bc1b0d63c437b3cf9518b36e0da546e81
AudioFlinger: Disable AUDIO_WATCHDOG to reduce high audio power

- AudioWatchDog daemon wakes up the app processor every 50ms.
  This causes audio power to increase by ~3.5-4mA.
- Disable AUDIO_WATCHDOG to reduce high audio power.

CRs-fixed: 386481

Change-Id: Id8f038bd082b9aa711411db33c5302e1d12cadd6
libstagefright: Enable suspension policy

- ADSP doesn't enter suspend state after audio playback.
- No support for suspension policy in stagefright.
- Enable suspension policy in stagefright to allow
  component to move into suspend mode.

CRs-fixed: 386381
(cherry picked from commit 735bc83e32e64af25a6163c07e2039eb4354ff00)

Change-Id: If32bfc63bbb25563e14b128712cc90639b15dc5b
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
CameraParameters: Underp non-qcom hardware

Move setPostviewSize to QCOM_HARDWARE

Change-Id: I830d1385be0e784f9fcb6dc40f014bea36b4b65b
framework/av: Fix AudioFlinger create track failure

- AudioFlinger track creation fails after mediaserver crash
- Mediaplayer doesn't register for new sessionId value if
  mediaserver crashes during a song switch of music player
  and it uses the old sessionId though sessionId values are
  reset by AudioFlinger.
  AudioFlinger assigns the same sessionId to Tone Generator
  and since strategies of these two session differ it would
  result in track creation failure.
- Fix this issue by registering for new sessionId for
  mediaplayer if mediaserver crashes in idle state

Change-Id: Icc8d204bec5d2fa97db17a7319904baa29115b19
audoflinger: Add A2DP Notifications.

LPAPlayer needs A2DP Notifications to support LPA over BT-A2DP
devices.

Change-Id: Ib43231fd51070059cbe876ec54ee7c542bf2caa3
libstagefright: Enable LPA playback on BT-A2DP devices.

-Applicable for msm8660, msm7630 & msm7627a.
-LPAPlayer need to be put in a new file for the above
 targets as proxy port kind of implemention that is used
 for LPA on BT in 8960 is not available for the above targets.
-Consider LPA & Tunnel player compilation only for  QCOM
 targets as it was in ICS.

Change-Id: I638bd8427a7420e7e27b711008e9c6a51fb761b5
libstagefright: Fix for LPA crash and timestamp issue

-Timestamps during LPA playback is incorrect.
Crash is observed during moving to next clip.
-Timestamp after seek is incorrect.
AudioFlinger does not call stop of LPA Audio session.
-Manage timestamps in LPAPlayer.
Call stop of LPA Audio session.

CRs-Fixed: 388808

(cherry picked from commit e839365b783893c8070da587dac8aa5cb56d63f4)

Change-Id: Icccfb7d2325beb0f19d85af67a6719171e3fa625
libstagefright: Enable encode and decode with composition offsets

- Add setprop to enable b-frame encoding
- Setup AVC and MPEG4 encoder parameters for b-frame encoding
- Wait for minimum required buffers if b-frame encoding is
  selected for timelapse recording
- Allow decoding clips with ctts version 1

Change-Id: If2d66577b25c4a001cf72f4f84af56d03dfa4e17
CRs-Fixed: 380462
frameworks/av: Fix ANR during voice call recording when call ends

- While doing voice call recording, when the call ends ANR observed
- When the call is disconnected, audio HAL receives -1 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: Ifffa1a33a796c83ac819681b2bf4158c8a16f6ce
libstagefright: Fix for data loss in qcp recording

- For evrc and qcelp recording, nearly 1 sec of data which is
  recorded is not writtern to the recorded clip.
- The writer thread which writes the encoded data to .qcp file,
  is not getting enough CPU time. This results in ~500ms of data
  loss in the recorded clip.
- Fix is to increase the priority of the writer thread to
  ANDROID_PRIORITY_AUDIO

Change-Id: I19125593ade2697251df976c81cb4df8dcf7b80b
CRs-fixed: 386398
libstagefright: Fix for CTS recording testcase failure

- AMR WB record is failing through CTS because of incorrect
  sample rate and bitrate values. Fix AMR WB encode
  bitrate and sampling rate values to fix this issue.
- Back to back recording in CTS testcase
  MediaRecorderTest#testRecordingAudioInRawFormats fails.
  Add a fix to release audio source node reference on stop
  recording as well as before creating new audio source.

Change-Id: Ia4b1f2331b0b6f9c6c7d23cd40e8c5b5cec76e28
CRs-fixed: 384336
libstagefright: Fix for FPS drop issue during A-V playback.

Issues:
-The AAC decoder was not updating the timestamp when EOS is reached.
-Logic to smoothen the real time update in AudioPlayer uses system
 time. This introduces corrupt timestamp during EOS.

Fix:
-Update the timestamp in AAC decoder when EOS is reached.
-Extrapolate realtime using system time in AudioPlayer when EOS is
 reached. Cap the value to realtime if  extrapolated time becomes greater
 than realtime.

CRs-Fixed: 384183
Change-Id: Ice54501436431d2527fcd3d710d65d9732fcffdd
frameworks/av : Added key to query a2dp device support

Change-Id: I0440ab83cfcabbecb336c12e2e8db0778e7b936b
libstagefright: Reduce number of video events posted when frame is early

Current av sync logic posts an early video frame with a delay of 10 ms.
This may result in multiple video events being posted before the frame
gets rendered. Update the delay for posting an early frame to the difference
between the lateness and early margin.

Change-Id: I619b75cf1b2ed83ab9e07bf26ad759d7c03fb4f4
frameworks/av: Fix for video playback failure in browser

- Issue: After camping the Signal to 3G network, open the browser
and go to www.youtube.com and play any video. Video playback is
failing after trying to load the video for few seconds. Browser is
coming back to video's list.

- Cause: At the beginning of playback, as there was a seek request
pending, seek is done before starting the AudioPlayer. After
AudioSource seeking, AudioPlayer start is called with OMX in PAUSED
state, causing assert check fail for OMX state.

- Fix: Call AudioSource start before calling AudioPlayer start, so that
OMX moves to EXECUTING state.

(Fix is ported from ICS I4e746bf0b5167d4998fd900bbce3966a2dc1273d)
CRs-Fixed: 395384

Change-Id: Id4f7e8658ba96b28533d11d34d4622ea6106615d
libstagefright: Checks before freeing buffers on a port

- OMXCodec calls dequeueBuffer on the NativeWindow in a loop
  and registers output buffers with the OMX component.
- If a dequeueBuffer fails, the buffers already registered
  with the OMX component were not getting freed laeding
  to a memory leak.
- On an error, check state of OMXCodec before freeing buffers on a port.

CRs-Fixed: 393352

Change-Id: I0d745fc299a9f55fcbf0f9e14744d12198e96f42
framework/av: Fix to handle corrupted .m4a clips

- Some m4a clips with corrupted header causes native crash
  in mediaserver.
- This is due to a wrong sample size which had to read from the clip.
- Fixed this by checking for the sample size extracted from the clip
  against the mediabuffer size.

Change-Id: If19b4bb2b99fb5558ed78d55d4e53fd03f6f8c73