Media Player Debug Print to show FPS

This patch adds support for displaying FPS print when the property
debug.video.showfps is set from commandline.

This patch is under the OMAP_ENHANCEMENT flag.

Patchset 3: To remove UNLIKELY definition

Signed-off-by: Lakshmana Gowda <lakshman79@ti.com>
Signed-off-by: Poorvaja Ramani <a0756684@ti.com>

Patch Set 4:  Simple cherry-pick on current tree.  No
changes made.  Taking approvals and verifications from patch
set 3.
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: Ic45ed6adb5df122edc75f346fb866fc72c1b32d4
CameraService: Adds support for burst compressed images

Signed-off-by: Emilian Peev <epeev@mm-sol.com>

Moved the changes under OMAP_ENHANCEMENT

Signed-off-by: Solaiyappan Saravanan <saravanan.s@ti.com>
Change-Id: I1f17675b2854793de83c2b7cdecafc039c46f355
GPS: GPS patch to start/create SUPL service.

This patch creates SUPL Service and also creates an entry for SUPL Service
to be started on system boot.

Change-Id: I145cc04a33451be92dccc68a33047aed5ee5dec9
Signed-off-by: Satish Chandra <x0141690@ti.com>
Do Fatal when OMX component returns a serious error.

This patch will create a seg fault leading to Media server to crash
when there is hardware error reported from component.
Signed-Off-By: Rajesh Vandanapu<a0393228@ti.com
Signed-off-by: Vicky Martinez-DeFrain <a0869710@ti.com>
Change-Id: Ia23747ccb6ee0f1f243afc4b4c5c9e8c31668784
Add OMAP_ENHANCEMENT definition to SystemProperties

Adding OMAP_ENHANCEMENT defenition.

Change-Id: Idaad47fabbd9cd2140714a2a9d682e8a3f49b446
Signed-off-by: Vishal Mahaveer <a0271468@ti.com>
WLAN - Initial P2P support for TI driver

Changes for enabling Wi-Fi P2p support in framework for TI solution.
TI uses module based WLAN driver. Change is to load and unload
module when P2P is used.

Change-Id: I61281c8a94fba9ddfe6b8ae3d82519d4887c15ec
Signed-off-by: Vishal Mahaveer <a0271468@ti.com>
Adding MPEG2 Decoder support to Stagefright and media

Add MPEG2 to MediaProfile Decoder capabilities and mpeg2
codec details to MPEG4Extractor

Signed-off-by: Devaraj Rangasamy <dev@ti.com>
Signed-Off-By: Rajesh Vandanapu<a0393228@ti.com

Patch Set 2:  Rebasing to break dependencies.  No changes
made.  Taking approvals and verifications from patch set 1.
Signed-off-by: Jean Johnson <a0271255@ti.com>

Patch Set 3: Fixing the permission problems.
Taking approvals and verifications from patch set 1.
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: I2be9ea76a92b825ab308003718b9d322fff7a272
Stagefright changes for Interlaced video buffers

OMXCodec has been modified to handle an event from
Codec with new Index to detect the interlaced stream.

StagefrightMetadataRetriever is modified to configure
Video frame params appropriately for thumbnail generation.

A new color conversion routine has been added for handling
interlaced buffers.

Note# The Changes are done as per OMX1.2 spec, except the below:
According to omx, the interlaced buffer layout needs to be
communicated to IL as part of buffer payload (at the end of
video data).
Since this is a too much of overhead, the implementation is
done based on event handling mechanism between codec and IL client.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 5:  Cherry-pick to break dependencies.  Taking
approvals and verifications from previous patch set.
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: I8c6287f77698ff7cff8fcb1e93f267b7661cd6a1
MediaController fix for seek bounce issue

Descripiton# The seek threshold is adjusted to avoid bounce effect
during AV playback seek.We will need this logic to eliminate the multiple
seek events coming from user touch events.
Otherwise this would result in seeking to the same IFrame and hence results
in repeating Video and Audio during AV clip seek.

Validation# AV playback seek and normal playback

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: If635907501fdc9b41869dea9bdf85fb68f7b0d82
PowerManagerService: Don't blink the display at power up

During the boot sequence the display backlight can be forced to
off.

If we are booting there is no reason to flash the backlight as we
generally should be displaying a boot animation.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: I3343b172dd8d78ca3ae5858d5308e9e3d74a7196
Improve AV sync logic for accurate frame posting

Current logic:
1. On Play a 10msec defalt event is posted which has a callback onVideoEvent in awesomeplayer.cpp.
2. If we find a frame in renderer comming from Ducati then we check its time stamp against system / audio time stamp
3. There is a start delta which is always adjusted from the current time.
4. If the frame is late by 50 msec we drop it
5. If the frame is early more than 100 msec then we post a event after 10msec
6. if the frame is within 10 msec of current time then post it.
7. After a frame is posted we trigger a 10msec event to go to next frame

Flaws in current logic
1. we will never post it accurate; a 33 msec frame will get divided in three 10 msec windows and we will post it 3 mec early.
2. 100 msec check was wrong.
3. polling every 10 msec is increasing the MHZ
4. After displaying the frame we start a 10msec event which could have been 1 Msec to get more accurate posting results
5. Audio on OMAP4 increase the timestamp after 42 msec and we need accuracy of 1msec. So we will never have a precise posting

Modified logic
1. We check 10msec for early ness as per google original logic. Required for precise posting
2. For PPM optimization 2 things are done
1. Post the first frame event after 1 msec instead of 10 msec
2. Post the exact time future event for frame posting
e.g 33 msec we will have 1 msec and 32 msec 2 polls only reducing the ARM MHZ and also having precise posting of frame
3. Increase accuracy of audio by interpolating in between 2 audio frame increments. So polling in between 42 msec also provides
accurate results and keeps audio buffer sizes independent of AV sync logic
4. Added safety check so that if audio dies we dont keep playing video via interpolating logic.
5. A safety modulation logic is added so that if we seek we dont wait in the event for huge time.
This will cause hangs if we dont do this in seek case.
6. Added few instrumentation to know the exact delta between to postings

Patchset2:
1. Cosmetic changes: OMAP_ENHANCEMENT macro, whitespace fix, ifdef compilation warning fix

This is a forward-port of:

    commit 25f6d6418cf8b617690923e8deb8dd307a21048d
    Author: Dandawate Saket <dsaket@ti.com>
    Change-Id: I2d9f4728656f204409788107568ee81a86556479

Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Jean Johnson <a0271255@ti.com>
Change-Id: I9729854b6cce999a5c759a6c45c1d8a6d54d0623
Improve posting delta between two frames.

If we monitor the time between 2 frames it is not consitent.
It is expected to have posting around 33 msec for 30fps and 16 msec
for 60fps. We have an interpolation logic to take care of precise audio
time.

Logic for Interpolation:
When there is fillbuffer call presented by Audioflinger we increase the
sample count and mark the system time. In if randomly video queries for
the time then we interpolated on marked system time and use sample count
to provide a precise 1msec time line to video.

Issue with Interpolation:
We have Video posting thread and Audio time updation thread at the same
priority. Audio thread can be preempted while doing the memcpy of the
data from file to input buffer. This will communicate wrong time to
video since updation of bytes have not happened. Also in previous attempts
to read time we have used interpolation to update time. So if we have
a small byte update then we reset the interpolation marker. Then a pre-emption
for next audio time by video is even risky since we will communicate
time in past.

Solution:
To make sure we dont communicate the time in past we increase the potential
bytes we will read upfront before the thread can be pre-empted. Locking the
entire function is not a solution since memcpy delay is around 7 msec which
introduces fixed latentcy.

Defect ID: OMAPS00233908

This is a forward port of the following patch:

    commit fb25d7bee6c567c0da8a829e0bdc3e7ac2f38145
    Author: Dandawate Saket <dsaket@ti.com>
    Change-Id: I4eacc3b802a12a14155c1909bac1e56c0a05053e

Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Change-Id: I8ff9c80935a2cdd9f3bc803b4e9ea85713dd343a
StageFright: repost VideoEvent immediately when dropping frame.

The default behavior is to repost the VideoEvent in 10ms.  However,
since a frame is being dropped this timing is inappropriate and the
next event should be scheduled immediately.

Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Change-Id: I3038cc93b72f8f34e573845f3f401b2def841e2c
Stagefright: AudioPlayer: Fix for build break due to ALOGV macro

ALOGV is used in trace as part of OMAP_ENHANCEMENT changes.
This patch fixes it

Signed-off-by: Devaraj Rangasamy <dev@ti.com>
StageFright: Smooth the audio time reference during A/V playback

The audio clock interpolation logic more or less made the following
assumptions:

* That the time when the callback AudioPlayer::fillBuffer() is
called is an accurate indication of the audio time at the end of
the buffer that it process.

* That the interpolation scheme should be updated at every one or
two calls to fillBuffer(), and unquestioningly use that
timestamp.

* That gettimeofday() is monotonic

Further, getRealTimeUs() would sometimes provide an earlier timestamp
than one in a previous call. While this strategy is one the whole
very effective, on ICS it still results in occasional frame drops at
30 fps and a little more frame jitter than is acceptable.

The strategy is modified as follows:

* The time when the callback AudioPlayer::fillBuffer() is called is
a reasonable estimation of the audio time at the end of the
PREVIOUS call to fillBuffer().

* If fillBuffer() is called multiple times quickly, the data is
aggregated and treated as though it were a single call to
fillBuffer().

* Once a timestamp is selected as the basis for the time
interpolation scheme (i.e. an epoch), we continue to use that
epoch (advancing the base timestamp based on theory instead of
measurement). We only redefine the epoch on a new timestamp if
it deviates from the audio buffer feed by more than the size of
the AudioHAL's default buffer size.

* The system monotonic clock [clock_gettime(CLOCK_MONOTONIC, ...)]
is used instead of the wall clock [gettimeofday()].

* The return value of AudioPlayer::getRealTimeUs() is made nearly
monotonic (it may repeat a previosly returned value, but never
less than a previous value).

Using this scheme, the audio time reference is very smooth and results
in less video frame jitter and fewer frame drops.

Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Jean Johnson <a0271255@ti.com>
Signed-off-by: Jean Johnson <a0271255@ti.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>
To print video playback termination log when FPS automation is on

In ICS the log "video decoder shutdown completed" is currently
a LOGV. This patch changes it to LOGD if debugFps is enabled.
Similarly, it also shows frames dropped if FPS measurement is ON.

The patch is enclosed within #ifdef OMAP_ENHANCEMENT

This patch is required for automation of the video playback
regression test suite.

Redoing this patch since the previous time the patch was not
uploaded correctly to Gerrit.

Signed-off-by: a0756684@ti.com
Signed-off-by: Jean Johnson <a0271255@ti.com>
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>
BatteryStatsImpl: disable Log.wtf() in getNetworkStatsDetailGroupedById()

When ActivityManager starts the BatteryStats service, it starts it in
a locked mode.  When NetworkStatsFactory throws an exception, the
exception handling code is calling Log.wtf().  This triggers a
deadlock in ActivityManager.  This is worked around by not calling
Log.wtf() here.  Replacing with Log.e() which is safer.

This is a workaround, because it appears to be a bug in
ActivityManager and also the NetworkStats/BatteryStats interaction.

Change-Id: I34ab5446cf3e109fe0f370c469ee07a2082634a8
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Camera Service: Change max number of cameras to 3

Maximum number of cameras increased to 3 in order to support Stereo camera
in addition to the existing ones.

Change-Id: I63279daa17723669a8f116798b2687b73ddb5516
Signed-off-by: Dejan Ivanovski <x0162121@ti.com>
StageFright: Commit a new time interpolator.

When the previous audio clock (a.k.a. time interpolator) would get too
far ahead, it didn't have a good way to slow down.  In some use-cases
this was causing sync errors.

This patch implements a scheme that allows time-scaling to slow down
or speed up the audio clock as it tracks the hardware.  It was
inspired by the paper "Using a DLL to Filter Time" (F. Adriaensen,
2005)[1].  It differs from the paper because we are more disconnected
from the hardware, do not have constant buffer sizes, and are not
mapping frames to time-stamps.

This time source is no longer monotonic or semi-monotonic, and will
sometime "rewind" time.

[1] http://kokkinizita.linuxaudio.org/papers/usingdll.pdf

Change-Id: I43d462eb23bba19b6dd34b32b01a3c5cb7bd5d5d
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
AV Streaming: fix race condition during seek

When cached duration hits kLowWaterMarkUs, AwesomePlayer will pause
and wait for NuCachedSource3 to be filled up to high water mark again.
If audio seek complete event happens when paused, because all pending
events are canceled, MEDIA_SEEK_COMPLETE notification is not sent. As
a result, all subsequent seek requests are quequed because outstanding
seek complete notification not received by MediaPlayer.

Patch taken from GB: http://review.omapzoom.org/#change,11650

DR# OMAPS00254775

Signed-off-by: Yong Zhi <y-zhi@ti.com>
Signed-off-by: Anu Sundararajan <a0868449@ti.com>
Signed-off-by: Jorge E. Solano <jsolano@ti.com>

Change-Id: I060ff57fc42dd775465cdd0f1847a7f6dc9f47f4