Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 511599f5 authored by Jaideep Sharma's avatar Jaideep Sharma Committed by Andy Hung
Browse files

libmediaplayerservice: Explicitly force callbacks to stop running

This is needed to prevent a race condition with
the callbacks running after a close. MediaPlayerService instance
can go out of scope and callbacks from AudioTrack can lead to crash
in MediaPlayerService or NuPlayer.

Flag: EXEMPT bugfix
Bug: 183765091
Bug: 351695164
Test: see bug for validation
Change-Id: I48ebb5643b65eec8751c7bd345bc1266c4a98659
parent e77867fc
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2514,6 +2514,15 @@ void MediaPlayerService::AudioOutput::close()
    {
        Mutex::Autolock lock(mLock);
        track = mTrack;
    }

    // do not hold lock while joining.
    if (track) {
        track->stopAndJoinCallbacks();
    }

    {
        Mutex::Autolock lock(mLock);
        close_l(); // clears mTrack
    }
    // destruction of the track occurs outside of mutex.