Add AudioFlinger to Thread thread safety annotations
Test: atest AudioTrackTest AudioRecordTest
Test: atest AAudioTests AudioTrackOffloadTest
Test: atest AudioPlaybackCaptureTest
Test: Camera YouTube
Bug: 275748373
Merged-In: I9b4573be8f5f6546d6979f69a9ad8d19e5d95bc6
Change-Id: I9b4573be8f5f6546d6979f69a9ad8d19e5d95bc6
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 1541ebe..01a8a22 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -390,7 +390,8 @@
status_t *status /*non-NULL*/,
bool pinned,
bool probe,
- bool notifyFramesProcessed) final;
+ bool notifyFramesProcessed) final
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
// return values for hasAudioSession (bit field)
enum effect_state {
@@ -429,7 +430,8 @@
// add and effect module. Also creates the effect chain is none exists for
// the effects audio session. Only called in a context of moving an effect
// from one thread to another
- status_t addEffect_l(const sp<IAfEffectModule>& effect) final;
+ status_t addEffect_ll(const sp<IAfEffectModule>& effect) final
+ REQUIRES(audio_utils::AudioFlinger_Mutex, mutex());
// remove and effect module. Also removes the effect chain is this was the last
// effect
void removeEffect_l(const sp<IAfEffectModule>& effect, bool release = false) final;
@@ -508,7 +510,7 @@
// deliver stats to mediametrics.
void sendStatistics(bool force) final;
- audio_utils::mutex& mutex() const final {
+ audio_utils::mutex& mutex() const final RETURN_CAPABILITY(audio_utils::ThreadBase_Mutex) {
return mMutex;
}
mutable audio_utils::mutex mMutex;
@@ -535,8 +537,10 @@
}
}
- void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) override;
- void stopMelComputation_l() override;
+ void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) override
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
+ void stopMelComputation_l() override
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
protected:
@@ -936,7 +940,8 @@
audio_port_handle_t portId,
const sp<media::IAudioTrackCallback>& callback,
bool isSpatialized,
- bool isBitPerfect) final;
+ bool isBitPerfect) final
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
bool isTrackActive(const sp<IAfTrack>& track) const final {
return mActiveTracks.indexOf(track) >= 0;
@@ -1062,8 +1067,10 @@
return INVALID_OPERATION;
}
- void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) override;
- void stopMelComputation_l() override;
+ void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) override
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
+ void stopMelComputation_l() override
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
void setStandby() final {
std::lock_guard _l(mutex());
@@ -1861,7 +1868,8 @@
pid_t tid,
status_t *status /*non-NULL*/,
audio_port_handle_t portId,
- int32_t maxSharedAudioHistoryMs) final;
+ int32_t maxSharedAudioHistoryMs) final
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
status_t start(IAfRecordTrack* recordTrack,
AudioSystem::sync_event_t event,
@@ -2219,8 +2227,10 @@
status_t reportData(const void* buffer, size_t frameCount) final;
- void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) final;
- void stopMelComputation_l() final;
+ void startMelComputation_l(const sp<audio_utils::MelProcessor>& processor) final
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
+ void stopMelComputation_l() final
+ REQUIRES(audio_utils::AudioFlinger_Mutex);
protected:
void dumpInternals_l(int fd, const Vector<String16>& args) final;