audio: Fixed input device check in checkInputsForDevice

- When an input device is disconnected, checkInputsForDevice clears
  dynamic fields of input profiles that are supporting the disconnected
  device. AUDIO_DEVICE_BIT_IN mask is missing while comparing with the
  supported input devices of a profile which is resulting in clearing
  wrong fields

- Fix is to include AUDIO_DEVICE_BIT_IN in this comparison

CRs-Fixed: 753189
Change-Id: Icc94b8353bc49567d8a6d6a75293c3b0dd42d83c
ToneGenerator: Limit tones to 48k

DTMF tones are played at the hardware module sampling rate.
Until now, this rate was limited to 48k. Tones sound not too
pleasant at higher rates (like 96k and 192k). Ergo, limit the rate
to 48k.

Change-Id: I7fbc3185d988628ce3ee478076a322857221dece
AudioTrack: Handle track invalidate on wait for stream done

If a track invalidate is called while waiting for a stream done,
AudioCallback handler is notified with event EVENT_STREAM_END.
This might cause substantial data loss for offload playback. Try to
recreate the track if needed.

Change-Id: Ie663c85e92588ddfd8d633f4bf5024f9fa4f5c2e
Revert "Audio: fix stop issue for compress capture using MPEG4Writer"

- MPEG4Writer is waiting for FBD and camera stops giving buffers,
  then there is no buffer available to writer and thread is not
  joinable results in deadlock.
- Stop audio source before pthread_join to avoid deadlock during
  video recording

Change-Id: I871a969d844d98836b2e05d6d86606400926101f
stagefright: httplive: Propagate target duration to LiveSession

LiveSession's switch-down monitor requires the 'targetDuration'
key to evaluate the switching threshold. Ensure that this key is
set in the access unit metadata.

CRs-Fixed: 759581
Change-Id: Ib30f3b4bd8185a77a06abd755822f96644968a21
stagefright: Add Awesomeplayer statistics using ExtendedStats

Profile Awesomeplayer statistics using ExtendedStats module.

Change-Id: I31cad6ea0e3c4b86e48c47ae4c706c9574cf6a72
stagefright: Fix startup latency profiling

Start first frame profiling before the 1st ETB. Also move the
setDataSource profiling to after reset.

Change-Id: I6ea6c3da838e5dda1f73ec1c0070c72492383227
stagefright: ExtendedStats: Only enable stats with property

Only enable the extendedstats when property:
persist.debug.sf.extendedstats is set to 1. Change the constructor
of AutoProfile to pass the MediaExtendedStats module and do the
NULL check inside it instead of at every call.

Change-Id: I0d41469e41f358506638d76dc995ed3acda2b403
audio: Clear audio source if it is failed to be started

- fallbackToSWDecoder is not deleting mAudioSource, mOmxSource
  when there is an error while starting the source. Due to this,
  play_l calls stop() on mAudioSource even when mAudioSource is
  not started. This is leading to a crash in MPEG4Source
- Fix is to delete mAudioSource and mOmxSource if it is failed
  to be started

Change-Id: I6f555f5094b813a1e4ef3934c9e7a712ba41be02
Stagefright: ExtendedStats: simplify bitrate calculation

Replace usage of stl::SortedVector with a static array to
calculate moving average

Change-Id: Ic8f9d8320c30d01090d7a53ddee9d1b168f76a42
audiopolicy: Add support for multiple offload playback

Add support for multiple concurrent offload playback

Change-Id: Ib7ebf91db0c8c41e8354d2ef65c747e564d265fa
(cherry picked from commit 3cda51ca4117ad7f0f5f95d35bc0e14a272d3ebf)
libstagefright: Fix for testHEVC_flushConfigureDrc

Some CTS test cases are sending the component name instead
of mime type. Check for the same before overriding the component name.

CRs-Fixed: 741059

Change-Id: I31b6052aa4972d6cb44e7e564cef945a18fcca25
stagefright: ExtendedStats: Fix ExtendStats AMessage dup crash.

AMessage setObject should not be called with NULL, as this would
cause a crash in dup(). Call AMessage setObject only if the
ExtendStats object is not NULL.

Change-Id: I61c88f820d5ff8d69e34ff0eef68bae2d28f4f52
audio_policy: Fix for audio routing to speaker though BT is connected

- When voice dialer is active and play is issued from the connected
  BT headset, audio is heard on speaker.
- Speaker is selected in getDeviceForStrategy() although BT is connected
  as the flag 'mA2dpSuspended' remains 'true'. The flag is not updated in
  checkA2dpSuspend() as force usage for communication
  and record remains FORCE_BT_SCO as voice dialer is active.
- Modify the conditional check to set the flag to 'false'.

Change ported from I86ebb66cd165e8009bfa6193d2ad9ab383996283

CRs-Fixed: 750370
Change-Id: Ie6fd9a552386465390b10168f878dfceb82aa86b
libstagefright: use appropriate hevc decoder on 8916 and 8939

8916 supports HEVC s/w decoder and 8939 supports h/w decoder.
Based on media.swhevccodectype property value, Add appropriate
HEVC decoder to the MediaCodecList.

Change-Id: I06a522fee4e54a75555f2b55e03addcace643d9d
Merge branch 'cm-12.0' of git://github.com/CyanogenMod/android_frameworks_av into cm-12.0