libstagefright: Fix for seek issue in mp3 streaming playback

-Issue: In LPA playback if seek is issued, the pcm driver
starts after a fill buffer and write is completed. If pause is
issued before the driver starts, audio pause fails and results
to a sudden jump in the playback or to an EOS at random

-Testscenario: Flush,immediately followed by Pause in LPA playback.

-Fix: Pause is handled when the pcm write is completed. This is
acheived by a conditional wait on the pcm write done.

CRs-Fixed: 331099
(cherry picked from commit 6ce15986ee7f2155044f79c505ebcd5a310a6c0d)

Change-Id: I605316bba2d964ba3d52f6a7cc42e7e390d92fdf
libstagefright: Fix A2DP seek to EOS issue in LPA

- In A2dp scenario, when seeked to EOS and 0 bytes returned by decoder,
  eos was not issued to the app. This resulted in no audio.
- Put the buffer back in the request queue in case of 0 decoded bytes
  and post an AudioEOS event to the app.

Change-Id: Icb2cc053d71d02c8adb90fc5be1922ea813331e9
CRs-Fixed: 339608
(cherry picked from commit cdcdc2e6c6967de31476b1ece3702b645989e1df)

Conflicts:

	media/libstagefright/LPAPlayerALSA.cpp
libstagefright: Add wake lock support for LPAPlayerALSA

- LPAPlayerALSA now holds the wake lock while LPA playback is
  on going
- This allows external applications who do not hold wake lock
  to use LPA playback

CRs-Fixed: 342451
(cherry picked from commit 9621db1c1cf2092b1b51983c91434612c4cd8480)

Change-Id: I3ff8bbdc2535e29b3e0b94953d9ce6364b5c0782
libstagefright: Use YAMATO(Adreno semiplanar) color format for 7x27a.

Use YAMATO color format as default for 7x27a. This is required
to reduce the CPU/Power usage while creating surface textures as
GPU natively supports this format.

CRs-Fixed: 337105
(cherry picked from commit 8cc0f8ba5954d15e5a55aab9695ca61fcf7ae2ce)

Change-Id: Ic6d8ba6f43122d9583aa1d391457c80d54a4d9b7
libstagefright: Fix bitrate and I frame interval values for HFR mode
libstagefright: Add support for High Frame Rate Encoding

Based on kkeyhfr key value from meta data, add support in OMXCodec and
MPEG4Writer for HFR mode

Change-Id: I2fe0780865bd01451bf8e77acf028b498c1c9f28
libstagefright: Fix HFR crash in MPEG4Writer

From ICS, for video kkeyframerate is used instead of kkeysamplerate. This
needed correction in MPEG4Writer.
kkeydecoding timestamp is used for sending the decoding timestamp. The
decoding timestamp had to updated for HFR.

Change-Id: I194a218b00ffcd41b1646a0c29c26a7a8f87e819
libstagefright: Add 3D video support

- This is a combination of 5 patches ported from HC:
  I6c9eb55e, I37945d13, I64a8b08d, Ib45911e1, Ia9cdbbc5
- Query the component using the FramePackingArrangement parameter
- Based on the arrangement type and content interpretation flag,
  pass the appopriate flag to the NativeWindow to render the 3D
  clip.
- Notify the encoder that we're recording 3D by setting the
  frame-packing arrangement to left-right.
- Parse the first buffer we get from encoder and extract SEI along with
  SPS/PPS.
- When writing samples into mdat, prefix all sample with the extracted
  SEI.
- Parse the parameters returned from Camera HAL to see if 3d flag is
  set, if so set kKey3D flag in Metadata so we can propagate info to
  OMXCodec.

Change-Id: Ie6d5d276e56759f4c67d755f61ce1aae1a7216a9
libstagefright: Fix to avoid deadlock while audio/video track stop

- Before writing to the file, the lock was released two times which
  is not required. This could lead to uncertain behavior.
- Fixed by removing the second "unlock".

(cherry picked from commit 8715b7f53597d1e3a32df997fca1dc043b98acf2)

Change-Id: I876f96807acf9dce4b0b25f60580b79bd5607ac4
CRs-Fixed: 290916
libstagefright: Remove assert failure for kKeyHfr

- Remove assert failure if kKeyHfr is not present in
  meta data.
- Assume normal mode recording if kKeyHfr is absent

Change-Id: I17e29c943cc8886df9e8976487c05aabc54c3129
(cherry picked from commit 9fb63299bf27bd30f8a0fab5b9c2777e4342f154)
libstagefright: Use writer thread for video only recording.

The MPEG4 writer is currently writing the frames to the file in
the video track thread when doing video only recording. This causes
frame drops when the call to write to the file takes too long.

With this change, frames are written to the file from the writer
thread on video only recording, preventing the video track thread
to get blocked on writes.

(cherry picked from commit f9bc5cead918d8aedea2fc4f3c4f7cd275c3b5b6)

Change-Id: Icdb91be1c9cf919eadb1227481bce07dac547527
CRs-Fixed: 341670
libstagefright: Enable metadata mode recording

- Metada mode video recording is enabled by default.
- use setprop debug.camcorder.disablemeta 1 to disable metadata mode recording.

Change-Id: If994c468c3e24ae03b14462f2311504c3d957426
frameworks/base: enable meta mode for 7x27a video encoder

msm7627a family of chipsets supports only one input frame at
one time. camera expects the input frame to be released before
sending another frame. so send one input buffer and available
output bufefrs to video encoder component. release the input
buffer to camera (to get another frame) after receiving input
frame done callback from video encoder component.

Change-Id: I8fbc911f046ff7e2a3047dd65d8c09ac2d8608e1
libmediaplayerservice: Fix for audio recording test through CTS

- Issue: Failure in stop is observed with the audio recording test
through CTS.
console, the recording session is force closed with a notification
File Size limit exceeded. Further, the stop fails with the same
message(notification of the File size exceeded error).

- Cause: The calculation of nTotalBytesEstimate for the recording
session exceeds the limit 95 percent of mMaxFileSizeLimitBytes.
As a result of size deficit, the recording is stopped at the
beginning of the recording session notifying
MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED.

- Fix: The factor size used in the calculation of nTotalBytesEstimate
has been updated properly for 64bit file offset setting. The
setParam64BitFileOffset in StagefrightRecorder::prepare() is executed
based on two additional validations so that the factor size is updated
appropriately.

(cherry picked from commit 7bffcd1e6842bb7e5d88ba767104c73e84b14b15)

Change-Id: Iad0c45e148311f85dc93b76b7cf258bf97afa13a
TestScenario: When the audio record test is initiated in the CTS
CRs-Fixed: 328461
media: cleanup system property ro.product.device usage

Replace 'ro.product.device' usage with 'ro.board.platform'
to enable qcom chipset specific features.

Using ro.product.device for enabling chipset specific
features requires manual changes for customers who
want build their own device.

CRs-fixed: 338149
(cherry picked from commit 9fa3017fee5de099017b9ccffc93ffdeae79a913)

Change-Id: I71e769ac19a39a636e23afb4d05f46edbcfadc6a
libmediaplayerservice: system property to set video encode rotation

- Define debug.camcorder.rotation to set rotation value during encode
- Value must be set to one of 0,90,180 and 270

Change-Id: I8e55119f6ad33f00f7bcd796f3ff5428880f0442
StagefrightRecorder: Set intra-period to 2 seconds for video recording

Sets the video encoder intra period value to 2 seconds in
StagefrightRecorder.

Change-Id: Ic9fa16e75baa9aa8e90876f0558b3f2bdcfaa2b3
libstagefright: Change thread priority for LPA threads

- Since A2DP behaves like a render thread, there is a need for it
  run at urgent audio priority.

CRs-Fixed: 344793
(cherry picked from commit 3b81741adf7b743cfa72874f63bf561950c9cd22)

Change-Id: I44c40b812f0368ec81d7c11fd45daef6d5e16702
libstagefright: Fix in calculating size of data remaining in cache

- Do not consider interleaving offset while calculating cache size
- Do not update last access position when seek internal is ignored

CRs-Fixed: 349980

(cherry picked from commit 6b406f9832631ba19dd47bfe0be478770166fcec)

Change-Id: I106bad67c87ab0e5813b75c3ecf75c5f211e0931
libstagefright: VP8 playback fixes

- The VP8 input buffer size is hardcoded to 256Kb in
  the VP8 omx component input port definition.
  This is insufficient for 1080p videos.
- Increase input buffer size to 750Kb.

CRs-Fixed: 345892
(cherry picked from commit d8a2ac05962bac053066800707010310ba46aee1)

Change-Id: I5f7749421c7e91d0e0e13786e80d420a3c5d1272