Loading services/audioflinger/IAfTrack.h +8 −0 Original line number Diff line number Diff line Loading @@ -382,6 +382,14 @@ public: virtual audio_output_flags_t getOutputFlags() const = 0; virtual float getSpeed() const = 0; /** * Inform AudioService of any potential playback restriction due to fg state. * Should be called when evaluating playback restrictions due to fg state * (see {@link isPlaybackRestrictedControl()}). This function * internally checks the OP state and dispatches to AudioService for metrics */ virtual void maybeLogPlaybackHardening(media::IAudioManagerNative& am) const = 0; /** * Updates the mute state and notifies the audio service. Call this only when holding player * thread lock. Loading services/audioflinger/PlaybackTracks.h +3 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ public: bool isSpatialized() const final { return mIsSpatialized; } bool isBitPerfect() const final { return mIsBitPerfect; } void maybeLogPlaybackHardening(media::IAudioManagerNative& am) const final; /** * Updates the mute state and notifies the audio service. Call this only when holding player * thread lock. Loading Loading @@ -367,6 +368,8 @@ protected: bool mIsExemptedFromOpControl = false; std::atomic<bool> mHasOpControlPartial {true}; mutable std::atomic<bool> mPlaybackHardeningLogged {false}; bool mHapticPlaybackEnabled = false; // indicates haptic playback enabled or not // scale to play haptic data os::HapticScale mHapticScale = os::HapticScale::mute(); Loading services/audioflinger/Threads.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -5865,6 +5865,8 @@ PlaybackThread::mixer_state MixerThread::prepareTracks_l( volume = masterVolume * track->getPortVolume(); } } track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); handleVoipVolume_l(&volume); // cache the combined master volume and stream type volume for fast mixer; this Loading Loading @@ -6062,6 +6064,8 @@ PlaybackThread::mixer_state MixerThread::prepareTracks_l( } } handleVoipVolume_l(&v); track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); if (track->isPausing()) { vl = vr = 0; Loading Loading @@ -6891,6 +6895,9 @@ void DirectOutputThread::processVolume_l(IAfTrack* track, bool lastTrack) track->getPortMute(), track->isPlaybackRestrictedControl()}); } track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); if (lastTrack) { track->setFinalVolume(left, right); Loading services/audioflinger/Tracks.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1904,6 +1904,20 @@ void Track::setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) { mTeePatchesToUpdate = std::move(teePatchesToUpdate); } void Track::maybeLogPlaybackHardening(media::IAudioManagerNative& am) const { using media::IAudioManagerNative::HardeningType::PARTIAL; // The op state deviates from if the track is actually muted if the playback was exempted for // some compat reason. // The state could have technically TOCTOU, but this is for metrics and that is very unlikely if (!hasOpControlPartial()) { if (!mPlaybackHardeningLogged.exchange(true, std::memory_order_acq_rel)) { am.playbackHardeningEvent(uid(), PARTIAL, /* bypassed= */ !isPlaybackRestrictedControl()); } } } // must be called with player thread lock held void Track::processMuteEvent_l(const sp< IAudioManager>& audioManager, mute_state_t muteState) Loading Loading
services/audioflinger/IAfTrack.h +8 −0 Original line number Diff line number Diff line Loading @@ -382,6 +382,14 @@ public: virtual audio_output_flags_t getOutputFlags() const = 0; virtual float getSpeed() const = 0; /** * Inform AudioService of any potential playback restriction due to fg state. * Should be called when evaluating playback restrictions due to fg state * (see {@link isPlaybackRestrictedControl()}). This function * internally checks the OP state and dispatches to AudioService for metrics */ virtual void maybeLogPlaybackHardening(media::IAudioManagerNative& am) const = 0; /** * Updates the mute state and notifies the audio service. Call this only when holding player * thread lock. Loading
services/audioflinger/PlaybackTracks.h +3 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ public: bool isSpatialized() const final { return mIsSpatialized; } bool isBitPerfect() const final { return mIsBitPerfect; } void maybeLogPlaybackHardening(media::IAudioManagerNative& am) const final; /** * Updates the mute state and notifies the audio service. Call this only when holding player * thread lock. Loading Loading @@ -367,6 +368,8 @@ protected: bool mIsExemptedFromOpControl = false; std::atomic<bool> mHasOpControlPartial {true}; mutable std::atomic<bool> mPlaybackHardeningLogged {false}; bool mHapticPlaybackEnabled = false; // indicates haptic playback enabled or not // scale to play haptic data os::HapticScale mHapticScale = os::HapticScale::mute(); Loading
services/audioflinger/Threads.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -5865,6 +5865,8 @@ PlaybackThread::mixer_state MixerThread::prepareTracks_l( volume = masterVolume * track->getPortVolume(); } } track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); handleVoipVolume_l(&volume); // cache the combined master volume and stream type volume for fast mixer; this Loading Loading @@ -6062,6 +6064,8 @@ PlaybackThread::mixer_state MixerThread::prepareTracks_l( } } handleVoipVolume_l(&v); track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); if (track->isPausing()) { vl = vr = 0; Loading Loading @@ -6891,6 +6895,9 @@ void DirectOutputThread::processVolume_l(IAfTrack* track, bool lastTrack) track->getPortMute(), track->isPlaybackRestrictedControl()}); } track->maybeLogPlaybackHardening( *mAfThreadCallback->getOrCreateAudioManager()->getNativeInterface()); if (lastTrack) { track->setFinalVolume(left, right); Loading
services/audioflinger/Tracks.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -1904,6 +1904,20 @@ void Track::setTeePatchesToUpdate_l(TeePatches teePatchesToUpdate) { mTeePatchesToUpdate = std::move(teePatchesToUpdate); } void Track::maybeLogPlaybackHardening(media::IAudioManagerNative& am) const { using media::IAudioManagerNative::HardeningType::PARTIAL; // The op state deviates from if the track is actually muted if the playback was exempted for // some compat reason. // The state could have technically TOCTOU, but this is for metrics and that is very unlikely if (!hasOpControlPartial()) { if (!mPlaybackHardeningLogged.exchange(true, std::memory_order_acq_rel)) { am.playbackHardeningEvent(uid(), PARTIAL, /* bypassed= */ !isPlaybackRestrictedControl()); } } } // must be called with player thread lock held void Track::processMuteEvent_l(const sp< IAudioManager>& audioManager, mute_state_t muteState) Loading