AudioTrack: Reject offloading for non-music streams

Reject AudioTrack initialization if called with non-music
stream type (or attribute) but with AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD.

This will allow the client to fall back to SW decode or
deal with the error appropriately.

CRs-Fixed: 740607
Change-Id: I4d1dda6523bd792ab26b0363e16febcd14b1ad98
audiopolicy: Add support for multiple offload playback

Add support for multiple concurrent offload playback

Change-Id: Ib7ebf91db0c8c41e8354d2ef65c747e564d265fa
(cherry picked from commit 3cda51ca4117ad7f0f5f95d35bc0e14a272d3ebf)
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: 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
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
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
raw : Increase the input/output buffer size of raw omx component.

 -Few specific flac clips are not playing using QTI-FLAC decoder.
 -Nuplayer uses the OMX component of default RAW decoder for FLAC codec,
  So increase the input/output buffer size of raw omx component to
  support specific flac clips.

Change-Id: Ieb528b0b210a8649d86b4ccde940256472b95443
stagefright: httplive: Fix deadlock for low duration clips

PlaylistFetcher buffers up to 3 * target-duration bytes of data,
but if a stream is slow (ie due to bad network conditions), a
buffer threshold of 10s is used to resume playback. This results
in an indefinite freeze as PlaylistFetcher has stopped buffering
before this threshold. Reduce the 10s threshold to be more in-sync
with PlaylistFetcher's buffering size.

CRs-Fixed: 745835
Change-Id: Ife846e7c5b4f9645895873d08250c4bee0164972
stagefright: httplive: Reduce memcpy calls for chunked content

Streams using http chunking will not report the segment's total
content-length. In this case, a 64k buffer is allocated and is
increased by 32k each time the buffer is filled again. For high
bitrate content, this can lead to a large number of copies that
affect the HLS framework delay. Increase fetchFile buffer size
exponentially by 50% or at least 32k instead of by 32k each time
to reduce the number of memcpy calls.

Example for a chunked 6 MB 1080p segment (ie ~3s):
Adding 32k:
190 copies with 572.97 MB copied

Increasing by 50%:
12 copies with 16.09 MB copied

CRs-Fixed: 745835
Change-Id: Iedf0e4437e96026a58d50bce2660f85ac90d0ada
AudioPolicy: Reject offloading for non-music streams

- Reject output request if called with non-music stream
  type but with AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD

- This will allow the client to fall back to SW decode or
  deal with the error appropriately.

Change-Id: Ib7a805a884b02b3e5169da334292dfb776fe41bf
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
Merge "stagefright: ExtendedStats: Fix ExtendStats AMessage dup crash."
Merge "audio: Fixed input device check in checkInputsForDevice"
Merge "audiopolicy: Add support for multiple offload playback"
Merge "AudioPolicy: Reject offloading for non-music streams"
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
Merge "AudioTrack: Handle track invalidate on wait for stream done"
Merge "AudioTrack: Reject offloading for non-music streams"
Merge "ToneGenerator: Limit tones to 48k"
Merge "Revert "Audio: fix stop issue for compress capture using MPEG4Writer""