libstagefright: Add support for PCM in offload path

- If compress offload fails try to offload PCM
- Set PCM offload format if the audio mime is RAW/PCM

Change-Id: Ibab5cb2d73edd6e2e38cd32c05ef27612cbe1425
libstagefright: Fix for video can't be played if BT is connected

-Issue: Video can't be played if BT is connected.
-Rootcause: Source code to handle fallback to software decoder
 if offload audio track creation fails is not present.
-Fix: Add source code to handle fallback to software decoder
 if offload audio track creation fails.

Change-Id: Ie136a2117dd3f028c962b8b73ebc238bc982d79b
CRs-Fixed:  593230
libstagefright: Enhance compress offload logging

Add/Enable msg logging
-Statemachine transitions
-Salient funtion calls to Audio HAL
-Salient funtion calls to awesomeplayer
-Events received from HAL
-Miscellaneous other important events.

Change-Id: Ib54954590f913afe473f20ccb56c46fed0aa000f
[frameworks/av] : added .mov extension

- while scanning the a/v files in sdcard it takes the container
  format extension and checks for whether it supports or not.
  So added support for mov extension in StagefrightMediaScanner.

CRs-Fixed: 515036

Change-Id: I140a96cd535178b64b5d7c8bafe20eece2243953
libmediaplayerservice: Avoid writing silence for offload tracks

-Audio Sink writes silence to the track if size returned from AudioPlayer
 is zero and when there is no subsequent output.
-Avoid writing silence for offload tracks as decoders do not expected
 any raw data.

CRs-Fixed: 615468
Change-Id: I5044d514126c413f56971e80815f232298f9685c
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

Conflicts:
	media/libstagefright/AwesomePlayer.cpp
audioflinger: remove unecessary call to HAL

On a flush, OffloadThread resets its state about HAL being paused.
For the sake of consistency, it is now expected that after a flush
as HW is no longer paused, the resume call is unnecessary.

Change-Id: I47d8b685dd23427bb44e24593124b4e42e4a315e
audioflinger: OffloadThread fix for resume underrun

AudioFlinger can miss resuming h/w on a pause->resume transition
if sufficient data isn't available.

Change-Id: I3632b44571201bb47155f2ed3ad425fe68e04492
CRs-Fixed: 616599
libmedia: Set the correct audio latency in offload mode

- In offload mode latency is decided by Audio HAL.

Change-Id: I0f46ce9cb43e59907c07e77ec57fda47e841b094
CRs-Fixed: 609259
audioflinger: forward device change to effects in direct thread

Device change during offload playback is not informed to effect chain
which causes effects still work on unexpected output devices. Add device
change notification in direct output thread.

CRs-Fixed: 630408

Change-Id: I094a99bdf540479cee2fca6614ec35c2fa7d6046

Conflicts:
	services/audioflinger/Threads.cpp
audio: mute duration at the beginning of recording

-AudioSource mutes for predefined duration (kAutoRampStartUs)
 at the beginning of a recording. Current kAutoRampStartUs
 is not sufficient to mute the shutter sound click on
 B-Family devices. Sometime shutter sound is getting recorded
 with the current kAutoRampStartUs.

-Issue with calculating muteDuration from getOutputLatency is,
 more delay is getting added for Bt(~1 sec) which is really not
 required.

-Fix is to use constant mute delay which is appropriate

Change-Id: Ied20dc44c56cc74c74fb001383d3c533cb54b632
CRs-Fixed: 636491
stagefright: Handle missing text track language

Only set timed text language if kKeyMediaLanguage is found.

Crs-Fixed: 641896

Change-Id: Ie471bc458e42f5728064e447ac5c33b07311d3fd
audio: calculate mute duration using getOutputLatency

-AudioSource mutes for predefined duration
 (kAutoRampStartUs)  at the beginning of a recording.
 Since kAutoRampStartUs is zero, video recording tone
 is also getting recorded in the beggining.

-Fix is to get the output latency of current playback
 stream from audio system to calculate mute duration.

Change-Id: Ib9f4d38fcc8478d148719b70358644c581ba2f25
CRs-fixed: 615511

Conflicts:
	media/libstagefright/AudioSource.cpp
Avoid jumps to faulty position after seeks

When seeking multiple times it is possible that some seeks
are discarded in AwesomePlayer, which causes unwanted jumps
to faulty positions.
The reason is that a seek flag is reset twice in AwesomePlayer.
At first when the video seek is completed and then again when the
audio seek is completed. If a new seek is made after the previous
video seek completed but before the previous audio seek completed,
the new seek position is discarded by the previous audio seek
completion.

This fix makes sure that the seek flag is reset only when video
has completed the seek.

Change-Id: I8f8741d4cb8682345f1d1855bbad57c05f4e3c8d
stagefright: add rendering statistics

 - adds extra fps statistics
 - report via dumpsys
 - prints statistics before reset at the end of playback onto
   logcat
 - adds resume latency, from play_l to render
 - adds seek latency, from seek_l to render
 - enables using persist.debug.sf.statistics 1
 - prints all statistics when seek or resume is issued

Change-Id: I6fa34f3d0180c1b8bbad40da42bd241fb89e6866
libeffect: Fix enabled effect count calculation error

When switching from tunnel to arm effects, effect chain will be moved
from offload thread to mixer thread. During this procedure effect instance
is not destroyed, instead it's preserved and mounted onto new chain.

The migrant sequence is 1) disable instance -> 2) move to new effect
chain -> 3) enable instance again. However, the accumulated effect
enabled count is not decreased when effect instance is disabled.

As a result, LvmBundle_process() is only called once when Effect_process()
called twice, which causes input buffer get processed alternately and
glitch sound appears.

Change-Id: Idd3b8753a73694cc36617ed55b40fda93155abed
CRs-Fixed: 636353
audio: do not allow FAST output for voice call stream type

- Some VoIP applications set AUDIO_OUTPUT_FLAG_FAST while opening
audio output which causes low latency path to be selected. Clear
the flag explictly if the stream type is STREAM_VOICE_CALL
- Add debug messages in Audio Track and Record to print
the requested audio parameters

Change-Id: I7b3d1353ab107effc3f99b99bd9f78270f63097f