audio: Add support for incall music

Add support for STREAM_INCALL_MUSIC in AudioTrack.
This change is needed to support SCH tone playback
for DSDA.

Change-Id: I1933b286b6f1eb782bddf5458f8c53d581859e89
audio: Add pause support for hardware omx component

- ADSP doesn't enter sleep state after wma playback is paused
  and power suspended.
- No support for NT session pause in case of hardware component.
  NT session need to be paused to put ADSP into power collapse.
- Add support of pause in stagefright to ensure device enters
  suspend mode. Also add intermediate states to avoid concurrency
  issues between read and pause.

Change-Id: I41b946b8c8805e6ee303646b63513b5b16514ef6
libstagefright: Drain input buffer on resume

- Buffers returned from codec in paused state are not drained. When
codec is resumed these buffers are not drained until the next flush,
and may cause timed out issue.
- Added change to drain input buffers for sw decoders when resuming.

Change-Id: Ida2ab1d5dc3a1910accdd6fb89548262a912d8e7
CRs-Fixed: 569585, 574967
Framework: Fixing media server crash

Fixing media server crash when dump() is called
from camera framework after camera HAL instance
has been released.

CRs-fixed: 634328

Conflicts:
        services/camera/libcameraservice/api1/CameraClient.cpp

Change-Id: Ia837f5c0e722db4e6a7187062adc5d8bcfc93dca
frameworks/av: Enhance logging for audio usecases

 Add/Enable msg logging
- Start and End of playback
- To print file name
- Mode of playback and component used

Change-Id: I2c92d535ab76c9078af39b50fcfde4613f50a581
audio:Avoid AudioTrackThread if Track creation fails

-mAudioTrackThread is starting before the track creation.
 This thread is used to process the audio buffer, which
 is no longer valid if the track creation itself is
 failing.

-Fix is to check for the result of track creation and
 based on the result need to start the mAudioTrackThread.

Change-Id: Ic69e45f4269408ff60fe83390e9f8d0c895582e3
CRs-Fixed: 611668
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
frameworks/av : Add Null check for Audio Track

- Check if AudioTrack is available before de-referencing
it's pointer to avoid crashes during stability runs

- Rootcause: During Video playback when the audioTrack
init fails due to mediaplayer errors, the getMediaTimeUs
is already getting called resulting in a crash

- Fix: Added NULL pointer check when de-referencing pointer

CRs-Fixed: 658536
Change-Id: I0846e5cd805cb1523edb52ea9c7c04b41f954e6f
Audio: Enable QCOM HW AAC encoder

- Check related system prop to enable QCOM's HW
  AAC encoder
- Use QCOM's HW AAC encoder only for supported
  channels/sample rate/bitrate.
- Use Google's SW AAC encoder if the required AAC
  audio parameter is not supported by QCOM's HW
  AAC encoder
- Extend utils for more generic support

Change-Id: Ib1097611b1dbf59a7cf846aa7f944f604ad8a622
AudioFlinger: Introduce CBLK_STREAM_FATAL_ERROR flag

On a fatal error, PlaybackThread (or its derived classes)
can opt to signal an error back to the AudioTrack using
this flag.

Change-Id: Id323df8693c720432a459fe4d844d39033b24598
libstagefright: Add the conditions to ignore seek and allow sink stop

 -If app issues the multiple seek request to EOF position, player EOS
  gets delayed and app does not move to the next clip.
 -Seek interrupt the sink stop issued at EOF, hence delay in EOS.
 -Do not skip the sink stop if renderer position is EOF and ignore
  seek if seek time is same as player position.

Change-Id: Ic313eabfb738201b6b516555051a7a65c2bf8de2
CRs-Fixed: 667151
libstagefright - Fix seek on audio having empty stss block

Ignore stss block for audio even if its present, all audio
sample are sync samples itself, self decodeable and playable.

Parsing this block for audio restricts audio seek to few entries
available in this block, sometimes 0, which is undesired.

CRs-Fixed: 664870
Change-Id: If3208d5c0557d3eaeddf875d6c6762bd870c439b
libmediaplayerservice:Fix deadlock on gapless start failure

Issue:- Current gapless implementation starts the next clip when
MEDIA_PLAYBACK_COMPLETE event for the first clip is recieved
by MediaPlayerService.
-Even if start for next clip fails, application is notified with
MEDIA_INFO_STARTED_AS_NEXT.
- This causes the framework to trigger mediaplayer start which
again fails as it being for the same clip resulting in a deadlock
in the mediaplayer.
Fix:- Notify application with MEDIA_INFO_STARTED_AS_NEXT only when
start for the next clip is successful.

Change-Id: I77c570074c7c98c996122e275161ba88298e56fc
audiopolicy: support extended feature in audiopolicymanager.

- Add support for extended audio features including:
  COMPRESS_VOIP, EXTN_FORMATS, FM, HDMI_SPK, PCM_OFFLOAD,
  PROXY_DEVICE, SSR, DOLBY_UDC, DOLBY_DAP, and DOLBY_DDP.
- Migrate existing fixes in legacy AudioPolicyMangerBase.cpp and
  policy_hal/AudioPolicyManager.

Conflicts:
services/audiopolicy/AudioPolicyManager.cpp
Change-Id: I1925339b591cd29f11a71c287a2e53c0627e9e62
audiopolicy: additional change for extended feature

- Add support for extended feature in virtual member
  functions of default AudioPolicyManager.
- These changes can be implemented in customized
  AudioPolicyManager when USE_CUSTOM_AUDIO_POLICY is used

Change-Id: I9bad6a294ddd7aee72f6f6a314666b892b730c8e
audiopolicy: minor fixes for audiopolicymanager

- Remove unused Dolby header file path in Android.mk
- Fix commnet for HDMI speaker

Change-Id: I98915fc6296ff27fa2e7f6305b2ffd5f75a940e5
Audio: voice concurrency support for Bear family.

- Modem & Audio uses same DSP on Bear famliy, which will limit
  Audio usecases  during call mode
- Route all audio output sessions to ULL path
  during in call mode
- Route all non music sessions to ULL path if WFD
  session is active(to disable multiple post processing on ADSP)
- All VoIP, compress, deep buffer, record usecases
  need to close before voice call activation.
- All incoming VoIP, compress, deep buffer, record usecases
  need to block during voice call
- setMode(IN_CALL) itself is not sufficient to know if we are
in actual voice call.
- Add keyvalue parameters support to know if we are in voice call
and policy hal can query the same and make decissions based on it.

Change-Id: I6879081dd30969a7d1f162ea73b912442db2bef6
audio: Fix to select correct device for FM usecase

- audio on FM app plays concurrently with Music app audio
- FM should pause when Music app audio starts
- Fix the above issue by selecting the correct default
  device for FM usecase in setDeviceConnectionState

Change-Id: I4be649a229d001a4a13b7dd14044589bcc64d55c
CRs-fixed: 712725
audio: Fix playback of AAC clips in offload mode instead of deep buffer

-AAC clips with duration less than the minimum required duration for offload
playback, still end up in playback through offload path.
-This is because in isOffloadSupported() call, the condition to check AAC clips
is not updated to accommodate AAC subformats.
-Update condition to accommodate AAC subformats as well.

Change-Id: Ib946830bc2f6b9cec33c8f0943910e3aeeb6fa6e
audio: fix conversion from int error

This fixes compiler issue:
 "error: invalid conversion from 'int' to 'audio_output_flags_t'

Change-Id: I99c25d93c4a046021c42478a7a8fc01abdf52f77