Loading services/audioflinger/AudioFlinger.cpp +13 −10 Original line number Original line Diff line number Diff line Loading @@ -2091,7 +2091,8 @@ void AudioFlinger::removeNotificationClient(pid_t pid) } } } } void AudioFlinger::ioConfigChanged(audio_io_config_event_t event, // Hold either AudioFlinger::mutex or ThreadBase::mutex void AudioFlinger::ioConfigChanged_l(audio_io_config_event_t event, const sp<AudioIoDescriptor>& ioDesc, const sp<AudioIoDescriptor>& ioDesc, pid_t pid) { pid_t pid) { media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL( media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL( Loading Loading @@ -2945,7 +2946,7 @@ status_t AudioFlinger::openOutput(const media::OpenOutputRequest& request, latencyMs = playbackThread->latency(); latencyMs = playbackThread->latency(); // notify client processes of the new output creation // notify client processes of the new output creation playbackThread->ioConfigChanged(AUDIO_OUTPUT_OPENED); playbackThread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); // the first primary output opened designates the primary hw device if no HW module // the first primary output opened designates the primary hw device if no HW module // named "primary" was already loaded. // named "primary" was already loaded. Loading @@ -2959,7 +2960,7 @@ status_t AudioFlinger::openOutput(const media::OpenOutputRequest& request, mHardwareStatus = AUDIO_HW_IDLE; mHardwareStatus = AUDIO_HW_IDLE; } } } else { } else { thread->ioConfigChanged(AUDIO_OUTPUT_OPENED); thread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); } } response->output = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); response->output = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); response->config = VALUE_OR_RETURN_STATUS( response->config = VALUE_OR_RETURN_STATUS( Loading Loading @@ -2992,7 +2993,7 @@ audio_io_handle_t AudioFlinger::openDuplicateOutput(audio_io_handle_t output1, thread->addOutputTrack(thread2); thread->addOutputTrack(thread2); mPlaybackThreads.add(id, thread); mPlaybackThreads.add(id, thread); // notify client processes of the new output creation // notify client processes of the new output creation thread->ioConfigChanged(AUDIO_OUTPUT_OPENED); thread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); return id; return id; } } Loading Loading @@ -3052,7 +3053,7 @@ status_t AudioFlinger::closeOutput_nonvirtual(audio_io_handle_t output) mMmapThreads.removeItem(output); mMmapThreads.removeItem(output); ALOGD("closing mmapThread %p", mmapThread.get()); ALOGD("closing mmapThread %p", mmapThread.get()); } } ioConfigChanged(AUDIO_OUTPUT_CLOSED, sp<AudioIoDescriptor>::make(output)); ioConfigChanged_l(AUDIO_OUTPUT_CLOSED, sp<AudioIoDescriptor>::make(output)); mPatchPanel->notifyStreamClosed(output); mPatchPanel->notifyStreamClosed(output); } } // The thread entity (active unit of execution) is no longer running here, // The thread entity (active unit of execution) is no longer running here, Loading Loading @@ -3155,7 +3156,7 @@ status_t AudioFlinger::openInput(const media::OpenInputRequest& request, if (thread != 0) { if (thread != 0) { // notify client processes of the new input creation // notify client processes of the new input creation thread->ioConfigChanged(AUDIO_INPUT_OPENED); thread->ioConfigChanged_l(AUDIO_INPUT_OPENED); return NO_ERROR; return NO_ERROR; } } return NO_INIT; return NO_INIT; Loading Loading @@ -3314,7 +3315,7 @@ status_t AudioFlinger::closeInput_nonvirtual(audio_io_handle_t input) dumpToThreadLog_l(mmapThread); dumpToThreadLog_l(mmapThread); mMmapThreads.removeItem(input); mMmapThreads.removeItem(input); } } ioConfigChanged(AUDIO_INPUT_CLOSED, sp<AudioIoDescriptor>::make(input)); ioConfigChanged_l(AUDIO_INPUT_CLOSED, sp<AudioIoDescriptor>::make(input)); } } // FIXME: calling thread->exit() without mutex() held should not be needed anymore now that // FIXME: calling thread->exit() without mutex() held should not be needed anymore now that // we have a different lock for notification client // we have a different lock for notification client Loading Loading @@ -3694,7 +3695,8 @@ DeviceTypeSet AudioFlinger::primaryOutputDevice_l() const return {}; return {}; } } return thread->outDeviceTypes(); audio_utils::lock_guard l(thread->mutex()); return thread->outDeviceTypes_l(); } } IAfPlaybackThread* AudioFlinger::fastPlaybackThread_l() const IAfPlaybackThread* AudioFlinger::fastPlaybackThread_l() const Loading Loading @@ -4488,8 +4490,9 @@ bool AudioFlinger::isNonOffloadableGlobalEffectEnabled_l() const } } for (size_t i = 0; i < mPlaybackThreads.size(); i++) { for (size_t i = 0; i < mPlaybackThreads.size(); i++) { sp<IAfEffectChain> ec = const auto thread = mPlaybackThreads.valueAt(i); mPlaybackThreads.valueAt(i)->getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX); audio_utils::lock_guard l(thread->mutex()); const sp<IAfEffectChain> ec = thread->getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX); if (ec != 0 && ec->isNonOffloadableEnabled()) { if (ec != 0 && ec->isNonOffloadableEnabled()) { return true; return true; } } Loading services/audioflinger/AudioFlinger.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -342,7 +342,8 @@ private: // ----- begin IAfThreadCallback interface // ----- begin IAfThreadCallback interface bool isNonOffloadableGlobalEffectEnabled_l() const final REQUIRES(mutex()); bool isNonOffloadableGlobalEffectEnabled_l() const final REQUIRES(mutex()) EXCLUDES_ThreadBase_Mutex; bool btNrecIsOff() const final { return mBtNrecIsOff.load(); } bool btNrecIsOff() const final { return mBtNrecIsOff.load(); } float masterVolume_l() const final REQUIRES(mutex()); float masterVolume_l() const final REQUIRES(mutex()); bool masterMute_l() const final REQUIRES(mutex()); bool masterMute_l() const final REQUIRES(mutex()); Loading Loading @@ -387,7 +388,8 @@ private: const audioflinger::SyncEventCallback& callBack, const audioflinger::SyncEventCallback& callBack, const wp<IAfTrackBase>& cookie) final EXCLUDES_AudioFlinger_Mutex; const wp<IAfTrackBase>& cookie) final EXCLUDES_AudioFlinger_Mutex; void ioConfigChanged(audio_io_config_event_t event, // Hold either AudioFlinger::mutex or ThreadBase::mutex void ioConfigChanged_l(audio_io_config_event_t event, const sp<AudioIoDescriptor>& ioDesc, const sp<AudioIoDescriptor>& ioDesc, pid_t pid = 0) final EXCLUDES_AudioFlinger_ClientMutex; pid_t pid = 0) final EXCLUDES_AudioFlinger_ClientMutex; void onNonOffloadableGlobalEffectEnable() final EXCLUDES_AudioFlinger_Mutex; void onNonOffloadableGlobalEffectEnable() final EXCLUDES_AudioFlinger_Mutex; Loading services/audioflinger/Effects.cpp +8 −2 Original line number Original line Diff line number Diff line Loading @@ -3085,7 +3085,10 @@ uint32_t EffectChain::EffectCallback::sampleRate() const { return t->sampleRate(); return t->sampleRate(); } } audio_channel_mask_t EffectChain::EffectCallback::inChannelMask(int id) const { audio_channel_mask_t EffectChain::EffectCallback::inChannelMask(int id) const NO_THREAD_SAFETY_ANALYSIS // calling function 'hasAudioSession_l' requires holding mutex 'ThreadBase_Mutex' exclusively { const sp<IAfThreadBase> t = thread().promote(); const sp<IAfThreadBase> t = thread().promote(); if (t == nullptr) { if (t == nullptr) { return AUDIO_CHANNEL_NONE; return AUDIO_CHANNEL_NONE; Loading Loading @@ -3121,7 +3124,10 @@ uint32_t EffectChain::EffectCallback::inChannelCount(int id) const { return audio_channel_count_from_out_mask(inChannelMask(id)); return audio_channel_count_from_out_mask(inChannelMask(id)); } } audio_channel_mask_t EffectChain::EffectCallback::outChannelMask() const { audio_channel_mask_t EffectChain::EffectCallback::outChannelMask() const NO_THREAD_SAFETY_ANALYSIS // calling function 'hasAudioSession_l' requires holding mutex 'ThreadBase_Mutex' exclusively { const sp<IAfThreadBase> t = thread().promote(); const sp<IAfThreadBase> t = thread().promote(); if (t == nullptr) { if (t == nullptr) { return AUDIO_CHANNEL_NONE; return AUDIO_CHANNEL_NONE; Loading services/audioflinger/Effects.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -488,8 +488,10 @@ public: bool isBitPerfectCompatible() const final; bool isBitPerfectCompatible() const final; // isCompatibleWithThread_l() must be called with thread->mutex() held // isCompatibleWithThread_l() must be called with thread->mutex() held bool isCompatibleWithThread_l(const sp<IAfThreadBase>& thread) const final; bool isCompatibleWithThread_l(const sp<IAfThreadBase>& thread) const final REQUIRES(audio_utils::ThreadBase_Mutex); // Requires either IAfThreadBase::mutex() or EffectChain::mutex() held bool containsHapticGeneratingEffect_l() final; bool containsHapticGeneratingEffect_l() final; void setHapticIntensity_l(int id, os::HapticScale intensity) final; void setHapticIntensity_l(int id, os::HapticScale intensity) final; Loading Loading
services/audioflinger/AudioFlinger.cpp +13 −10 Original line number Original line Diff line number Diff line Loading @@ -2091,7 +2091,8 @@ void AudioFlinger::removeNotificationClient(pid_t pid) } } } } void AudioFlinger::ioConfigChanged(audio_io_config_event_t event, // Hold either AudioFlinger::mutex or ThreadBase::mutex void AudioFlinger::ioConfigChanged_l(audio_io_config_event_t event, const sp<AudioIoDescriptor>& ioDesc, const sp<AudioIoDescriptor>& ioDesc, pid_t pid) { pid_t pid) { media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL( media::AudioIoConfigEvent eventAidl = VALUE_OR_FATAL( Loading Loading @@ -2945,7 +2946,7 @@ status_t AudioFlinger::openOutput(const media::OpenOutputRequest& request, latencyMs = playbackThread->latency(); latencyMs = playbackThread->latency(); // notify client processes of the new output creation // notify client processes of the new output creation playbackThread->ioConfigChanged(AUDIO_OUTPUT_OPENED); playbackThread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); // the first primary output opened designates the primary hw device if no HW module // the first primary output opened designates the primary hw device if no HW module // named "primary" was already loaded. // named "primary" was already loaded. Loading @@ -2959,7 +2960,7 @@ status_t AudioFlinger::openOutput(const media::OpenOutputRequest& request, mHardwareStatus = AUDIO_HW_IDLE; mHardwareStatus = AUDIO_HW_IDLE; } } } else { } else { thread->ioConfigChanged(AUDIO_OUTPUT_OPENED); thread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); } } response->output = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); response->output = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); response->config = VALUE_OR_RETURN_STATUS( response->config = VALUE_OR_RETURN_STATUS( Loading Loading @@ -2992,7 +2993,7 @@ audio_io_handle_t AudioFlinger::openDuplicateOutput(audio_io_handle_t output1, thread->addOutputTrack(thread2); thread->addOutputTrack(thread2); mPlaybackThreads.add(id, thread); mPlaybackThreads.add(id, thread); // notify client processes of the new output creation // notify client processes of the new output creation thread->ioConfigChanged(AUDIO_OUTPUT_OPENED); thread->ioConfigChanged_l(AUDIO_OUTPUT_OPENED); return id; return id; } } Loading Loading @@ -3052,7 +3053,7 @@ status_t AudioFlinger::closeOutput_nonvirtual(audio_io_handle_t output) mMmapThreads.removeItem(output); mMmapThreads.removeItem(output); ALOGD("closing mmapThread %p", mmapThread.get()); ALOGD("closing mmapThread %p", mmapThread.get()); } } ioConfigChanged(AUDIO_OUTPUT_CLOSED, sp<AudioIoDescriptor>::make(output)); ioConfigChanged_l(AUDIO_OUTPUT_CLOSED, sp<AudioIoDescriptor>::make(output)); mPatchPanel->notifyStreamClosed(output); mPatchPanel->notifyStreamClosed(output); } } // The thread entity (active unit of execution) is no longer running here, // The thread entity (active unit of execution) is no longer running here, Loading Loading @@ -3155,7 +3156,7 @@ status_t AudioFlinger::openInput(const media::OpenInputRequest& request, if (thread != 0) { if (thread != 0) { // notify client processes of the new input creation // notify client processes of the new input creation thread->ioConfigChanged(AUDIO_INPUT_OPENED); thread->ioConfigChanged_l(AUDIO_INPUT_OPENED); return NO_ERROR; return NO_ERROR; } } return NO_INIT; return NO_INIT; Loading Loading @@ -3314,7 +3315,7 @@ status_t AudioFlinger::closeInput_nonvirtual(audio_io_handle_t input) dumpToThreadLog_l(mmapThread); dumpToThreadLog_l(mmapThread); mMmapThreads.removeItem(input); mMmapThreads.removeItem(input); } } ioConfigChanged(AUDIO_INPUT_CLOSED, sp<AudioIoDescriptor>::make(input)); ioConfigChanged_l(AUDIO_INPUT_CLOSED, sp<AudioIoDescriptor>::make(input)); } } // FIXME: calling thread->exit() without mutex() held should not be needed anymore now that // FIXME: calling thread->exit() without mutex() held should not be needed anymore now that // we have a different lock for notification client // we have a different lock for notification client Loading Loading @@ -3694,7 +3695,8 @@ DeviceTypeSet AudioFlinger::primaryOutputDevice_l() const return {}; return {}; } } return thread->outDeviceTypes(); audio_utils::lock_guard l(thread->mutex()); return thread->outDeviceTypes_l(); } } IAfPlaybackThread* AudioFlinger::fastPlaybackThread_l() const IAfPlaybackThread* AudioFlinger::fastPlaybackThread_l() const Loading Loading @@ -4488,8 +4490,9 @@ bool AudioFlinger::isNonOffloadableGlobalEffectEnabled_l() const } } for (size_t i = 0; i < mPlaybackThreads.size(); i++) { for (size_t i = 0; i < mPlaybackThreads.size(); i++) { sp<IAfEffectChain> ec = const auto thread = mPlaybackThreads.valueAt(i); mPlaybackThreads.valueAt(i)->getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX); audio_utils::lock_guard l(thread->mutex()); const sp<IAfEffectChain> ec = thread->getEffectChain_l(AUDIO_SESSION_OUTPUT_MIX); if (ec != 0 && ec->isNonOffloadableEnabled()) { if (ec != 0 && ec->isNonOffloadableEnabled()) { return true; return true; } } Loading
services/audioflinger/AudioFlinger.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -342,7 +342,8 @@ private: // ----- begin IAfThreadCallback interface // ----- begin IAfThreadCallback interface bool isNonOffloadableGlobalEffectEnabled_l() const final REQUIRES(mutex()); bool isNonOffloadableGlobalEffectEnabled_l() const final REQUIRES(mutex()) EXCLUDES_ThreadBase_Mutex; bool btNrecIsOff() const final { return mBtNrecIsOff.load(); } bool btNrecIsOff() const final { return mBtNrecIsOff.load(); } float masterVolume_l() const final REQUIRES(mutex()); float masterVolume_l() const final REQUIRES(mutex()); bool masterMute_l() const final REQUIRES(mutex()); bool masterMute_l() const final REQUIRES(mutex()); Loading Loading @@ -387,7 +388,8 @@ private: const audioflinger::SyncEventCallback& callBack, const audioflinger::SyncEventCallback& callBack, const wp<IAfTrackBase>& cookie) final EXCLUDES_AudioFlinger_Mutex; const wp<IAfTrackBase>& cookie) final EXCLUDES_AudioFlinger_Mutex; void ioConfigChanged(audio_io_config_event_t event, // Hold either AudioFlinger::mutex or ThreadBase::mutex void ioConfigChanged_l(audio_io_config_event_t event, const sp<AudioIoDescriptor>& ioDesc, const sp<AudioIoDescriptor>& ioDesc, pid_t pid = 0) final EXCLUDES_AudioFlinger_ClientMutex; pid_t pid = 0) final EXCLUDES_AudioFlinger_ClientMutex; void onNonOffloadableGlobalEffectEnable() final EXCLUDES_AudioFlinger_Mutex; void onNonOffloadableGlobalEffectEnable() final EXCLUDES_AudioFlinger_Mutex; Loading
services/audioflinger/Effects.cpp +8 −2 Original line number Original line Diff line number Diff line Loading @@ -3085,7 +3085,10 @@ uint32_t EffectChain::EffectCallback::sampleRate() const { return t->sampleRate(); return t->sampleRate(); } } audio_channel_mask_t EffectChain::EffectCallback::inChannelMask(int id) const { audio_channel_mask_t EffectChain::EffectCallback::inChannelMask(int id) const NO_THREAD_SAFETY_ANALYSIS // calling function 'hasAudioSession_l' requires holding mutex 'ThreadBase_Mutex' exclusively { const sp<IAfThreadBase> t = thread().promote(); const sp<IAfThreadBase> t = thread().promote(); if (t == nullptr) { if (t == nullptr) { return AUDIO_CHANNEL_NONE; return AUDIO_CHANNEL_NONE; Loading Loading @@ -3121,7 +3124,10 @@ uint32_t EffectChain::EffectCallback::inChannelCount(int id) const { return audio_channel_count_from_out_mask(inChannelMask(id)); return audio_channel_count_from_out_mask(inChannelMask(id)); } } audio_channel_mask_t EffectChain::EffectCallback::outChannelMask() const { audio_channel_mask_t EffectChain::EffectCallback::outChannelMask() const NO_THREAD_SAFETY_ANALYSIS // calling function 'hasAudioSession_l' requires holding mutex 'ThreadBase_Mutex' exclusively { const sp<IAfThreadBase> t = thread().promote(); const sp<IAfThreadBase> t = thread().promote(); if (t == nullptr) { if (t == nullptr) { return AUDIO_CHANNEL_NONE; return AUDIO_CHANNEL_NONE; Loading
services/audioflinger/Effects.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -488,8 +488,10 @@ public: bool isBitPerfectCompatible() const final; bool isBitPerfectCompatible() const final; // isCompatibleWithThread_l() must be called with thread->mutex() held // isCompatibleWithThread_l() must be called with thread->mutex() held bool isCompatibleWithThread_l(const sp<IAfThreadBase>& thread) const final; bool isCompatibleWithThread_l(const sp<IAfThreadBase>& thread) const final REQUIRES(audio_utils::ThreadBase_Mutex); // Requires either IAfThreadBase::mutex() or EffectChain::mutex() held bool containsHapticGeneratingEffect_l() final; bool containsHapticGeneratingEffect_l() final; void setHapticIntensity_l(int id, os::HapticScale intensity) final; void setHapticIntensity_l(int id, os::HapticScale intensity) final; Loading