libaudioclient: Use atomic_sp in TrackPlayerBase
TrackPlayerBase::destroy() can race with other methods exposed via the IPlayer interface. For example: - app thread calls Destroy on the OpenSLES player object - PlaybackActivityMonitor (in system_server) calls applyVolumeShaper() Since there's no synchronization on mAudioTrack, this can cause IPlayer methods to access an already destructed AudioTrack object, leading to a crash. Fix it by replacing sp<> with atomic_sp<>. Note: while having a destroy method requires extra care when accessing mAudioTrack, it allows us to destruct the AudioTrack object before its TrackPlayerBase owner, whose lifetime may be extended indefinitely by IPlayer binder proxies (see aosp/2909337). Test: atest trackplayerbase_tests Test: manual - stress test with injected delays to trigger the race Change-Id: I8e00ffd6b5fe0e9dbff7de9294bcdcc878602bb2
Loading
Please register or sign in to comment