Release AudioTrackCallback when the track is removed.
The AudioTrackCallback is cached as a strong pointer in PlaybackThread.
Remove the callback when the corresponding track is removed to avoid
memory leak.
Bug: 168675247
Test: repo steps in the bug
Change-Id: I09d78ca31c43db4d017f9e8c540628bcb6c44727
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index f95e0b8..6b33ad5 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1187,7 +1187,7 @@
Mutex mAudioTrackCbLock;
// Record of IAudioTrackCallback
- std::set<sp<media::IAudioTrackCallback>> mAudioTrackCallbacks;
+ std::map<sp<Track>, sp<media::IAudioTrackCallback>> mAudioTrackCallbacks;
private:
// The HAL output sink is treated as non-blocking, but current implementation is blocking