diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-12 05:37:01 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-12 05:37:01 +0000 |
commit | ef06c6ab1b912b210abd74eb5e57cde1d2b4eb87 (patch) | |
tree | 693bcc28a03b57fa08bb7fd9099682d4378a11c1 | |
parent | eb3505a105cf082007186575028cb521d94d1b36 (diff) | |
parent | 68d0d8648e08b9a66abeac22ef846eb8587df19d (diff) | |
download | av-android-security-11.0.0_r60.tar.gz |
Merge cherrypicks of [19418348] into security-aosp-rvc-release.android-security-11.0.0_r60
Change-Id: I97bd72f3761c8901987bde219751249e67961223
-rw-r--r-- | services/audioflinger/Threads.cpp | 12 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 21 |
2 files changed, 33 insertions, 0 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 2af27d8a30..015b4fb561 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -8877,6 +8877,12 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client, if (isOutput()) { ret = AudioSystem::startOutput(portId); } else { + { + // Add the track record before starting input so that the silent status for the + // client can be cached. + Mutex::Autolock _l(mLock); + setClientSilencedState_l(portId, false /*silenced*/); + } ret = AudioSystem::startInput(portId); } @@ -8895,6 +8901,7 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client, } else { mHalStream->stop(); } + eraseClientSilencedState_l(portId); return PERMISSION_DENIED; } @@ -8903,6 +8910,9 @@ status_t AudioFlinger::MmapThread::start(const AudioClient& client, mChannelMask, mSessionId, isOutput(), client.clientUid, client.clientPid, IPCThreadState::self()->getCallingPid(), portId); + if (!isOutput()) { + track->setSilenced_l(isClientSilenced_l(portId)); + } if (isOutput()) { // force volume update when a new track is added @@ -8959,6 +8969,7 @@ status_t AudioFlinger::MmapThread::stop(audio_port_handle_t handle) } mActiveTracks.remove(track); + eraseClientSilencedState_l(track->portId()); mLock.unlock(); if (isOutput()) { @@ -9738,6 +9749,7 @@ void AudioFlinger::MmapCaptureThread::setRecordSilenced(audio_port_handle_t port broadcast_l(); } } + setClientSilencedIfExists_l(portId, silenced); } void AudioFlinger::MmapCaptureThread::toAudioPortConfig(struct audio_port_config *config) diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index c1ac2e45b3..518d473932 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -1842,6 +1842,26 @@ class MmapThread : public ThreadBase virtual void setRecordSilenced(audio_port_handle_t portId __unused, bool silenced __unused) {} + void setClientSilencedState_l(audio_port_handle_t portId, bool silenced) { + mClientSilencedStates[portId] = silenced; + } + + size_t eraseClientSilencedState_l(audio_port_handle_t portId) { + return mClientSilencedStates.erase(portId); + } + + bool isClientSilenced_l(audio_port_handle_t portId) const { + const auto it = mClientSilencedStates.find(portId); + return it != mClientSilencedStates.end() ? it->second : false; + } + + void setClientSilencedIfExists_l(audio_port_handle_t portId, bool silenced) { + const auto it = mClientSilencedStates.find(portId); + if (it != mClientSilencedStates.end()) { + it->second = silenced; + } + } + protected: void dumpInternals_l(int fd, const Vector<String16>& args) override; void dumpTracks_l(int fd, const Vector<String16>& args) override; @@ -1861,6 +1881,7 @@ class MmapThread : public ThreadBase AudioHwDevice* const mAudioHwDev; ActiveTracks<MmapTrack> mActiveTracks; float mHalVolFloat; + std::map<audio_port_handle_t, bool> mClientSilencedStates; int32_t mNoCallbackWarningCount; static constexpr int32_t kMaxNoCallbackWarnings = 5; |