diff options
author | Steve Kondik <steve@cyngn.com> | 2016-04-06 18:35:02 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-04-07 15:19:57 -0700 |
commit | a4123803d0a0e9e0c69faa4207d357cc74a65d58 (patch) | |
tree | 336ade2306784822373a6a18023136090dd6d343 /services/audiopolicy/service/AudioPolicyEffects.cpp | |
parent | e13b58b988ab642d4ae5ca6d0a89013510714956 (diff) | |
download | frameworks_av-a4123803d0a0e9e0c69faa4207d357cc74a65d58.zip frameworks_av-a4123803d0a0e9e0c69faa4207d357cc74a65d58.tar.gz frameworks_av-a4123803d0a0e9e0c69faa4207d357cc74a65d58.tar.bz2 |
audiopolicy: Be a little smarter with auto-attach
* The edge cases, ZOMG!
* Instead of relying on effects to be automatically attached, let's
just always notify userspace and send a bit more information. This
lets the application decide if effects should be attached rather
than relying on a hard-coded configuration file.
* Perform the setup in getOutputForAttr, but do it on the command
thread so we don't block the client.
OPO-593
Change-Id: I3900b349f2e895d51fa3a3dcc2de0c4bdf6dbc08
Diffstat (limited to 'services/audiopolicy/service/AudioPolicyEffects.cpp')
-rw-r--r-- | services/audiopolicy/service/AudioPolicyEffects.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/services/audiopolicy/service/AudioPolicyEffects.cpp b/services/audiopolicy/service/AudioPolicyEffects.cpp index 725bc64..bd1cc33 100644 --- a/services/audiopolicy/service/AudioPolicyEffects.cpp +++ b/services/audiopolicy/service/AudioPolicyEffects.cpp @@ -246,6 +246,7 @@ status_t AudioPolicyEffects::addOutputSessionEffects(audio_io_handle_t output, if (idx < 0) { procDesc = new EffectVector(audioSession); mOutputSessions.add(audioSession, procDesc); + } else { // EffectVector is existing and we just need to increase ref count procDesc = mOutputSessions.valueAt(idx); @@ -273,11 +274,35 @@ status_t AudioPolicyEffects::addOutputSessionEffects(audio_io_handle_t output, } procDesc->setProcessorEnabled(true); - return 1; } return status; } +status_t AudioPolicyEffects::doAddOutputSessionEffects(audio_io_handle_t output, + audio_stream_type_t stream, + int session, + audio_output_flags_t flags, + audio_channel_mask_t channelMask, uid_t uid) +{ + if (uint32_t(stream) >= AUDIO_STREAM_CNT) { + return BAD_VALUE; + } + ALOGV("doAddOutputSessionEffects()"); + + // create audio processors according to stream + status_t status = addOutputSessionEffects(output, stream, session); + if (status <= 0 && (status != NO_ERROR && status != ALREADY_EXISTS)) { + ALOGW("Failed to add effects on session %d", session); + } + + // notify listeners + mAudioPolicyService->onOutputSessionEffectsUpdate(stream, (audio_session_t)session, + flags, channelMask, uid, true); + + // Never return an error if effects setup fails. + return NO_ERROR; +} + status_t AudioPolicyEffects::releaseOutputSessionEffects(audio_io_handle_t output, audio_stream_type_t stream, int audioSession) @@ -335,10 +360,13 @@ status_t AudioPolicyEffects::doReleaseOutputSessionEffects(audio_io_handle_t out procDesc->mEffects.clear(); delete procDesc; mOutputSessions.removeItemsAt(index); - mAudioPolicyService->onOutputSessionEffectsUpdate(stream, audioSession, false); ALOGV("doReleaseOutputSessionEffects(): output processing released from session: %d", audioSession); } + + mAudioPolicyService->onOutputSessionEffectsUpdate(stream, (audio_session_t)audioSession, + AUDIO_OUTPUT_FLAG_NONE, 0, -1, false); + return status; } |