diff options
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 0a89fbb..cd493f6 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -278,7 +278,9 @@ status_t AudioTrack::set( } // handle default values first. - if (streamType == AUDIO_STREAM_DEFAULT) { + // TODO once AudioPolicyManager fully supports audio_attributes_t, + // remove stream "text-to-speech" redirect + if ((streamType == AUDIO_STREAM_DEFAULT) || (streamType == AUDIO_STREAM_TTS)) { streamType = AUDIO_STREAM_MUSIC; } @@ -1826,7 +1828,7 @@ status_t AudioTrack::restoreTrack_l(const char *from) status_t result; // refresh the audio configuration cache in this process to make sure we get new - // output parameters in createTrack_l() + // output parameters and new IAudioFlinger in createTrack_l() AudioSystem::clearAudioConfigCache(); if (isOffloadedOrDirect_l()) { @@ -2124,17 +2126,30 @@ void AudioTrack::setStreamTypeFromAttributes(audio_attributes_t& aa) { mStreamType = AUDIO_STREAM_BLUETOOTH_SCO; return; } + // TODO once AudioPolicyManager fully supports audio_attributes_t, + // remove stream remap, the flag will be enough + if ((aa.flags & AUDIO_FLAG_BEACON) == AUDIO_FLAG_BEACON) { + mStreamType = AUDIO_STREAM_TTS; + return; + } // usage to stream type mapping switch (aa.usage) { - case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY: + case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY: { // TODO once AudioPolicyManager fully supports audio_attributes_t, - // remove stream change based on phone state - if (AudioSystem::getPhoneState() == AUDIO_MODE_RINGTONE) { + // remove stream change based on stream activity + bool active; + status_t status = AudioSystem::isStreamActive(AUDIO_STREAM_RING, &active, 0); + if (status == NO_ERROR && active == true) { mStreamType = AUDIO_STREAM_RING; break; } - /// FALL THROUGH + status = AudioSystem::isStreamActive(AUDIO_STREAM_ALARM, &active, 0); + if (status == NO_ERROR && active == true) { + mStreamType = AUDIO_STREAM_ALARM; + break; + } + } /// FALL THROUGH case AUDIO_USAGE_MEDIA: case AUDIO_USAGE_GAME: case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE: @@ -2174,7 +2189,7 @@ void AudioTrack::setStreamTypeFromAttributes(audio_attributes_t& aa) { bool AudioTrack::isValidAttributes(const audio_attributes_t *paa) { // has flags that map to a strategy? - if ((paa->flags & (AUDIO_FLAG_AUDIBILITY_ENFORCED | AUDIO_FLAG_SCO)) != 0) { + if ((paa->flags & (AUDIO_FLAG_AUDIBILITY_ENFORCED | AUDIO_FLAG_SCO | AUDIO_FLAG_BEACON)) != 0) { return true; } |