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

Commit 1c2b1998 authored by Vinay Kalia's avatar Vinay Kalia Committed by Steve Kondik
Browse files

libstagefright: Fixing a race condition while stopping video playback.

While closing the video component, two threads
hold the reference to OMXCodec - thread in
which OMXCodec::stop is executed and the thread
in which OMXCodec::on_message is executed. The
thread which holds the last reference is the
one in which OMXCodec's instance gets destroyed.
We want client thread (OMXCodec::stop) to be the
one destroying the instance. If onMessage destroys
the instance then we might hit a situation where
pthread_join is called on the same thread causing
indefinite hang.

Change-Id: I79ef4ce0b71a6bf9f10f7ee0821322d915fb67c5
CRs-fixed: 270937
parent d5d42296
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3167,6 +3167,16 @@ status_t OMXCodec::stop() {

    mSource->stop();

    int i = 0;
    while(getStrongCount() != 1) {
        usleep(100);
        i++;
        if( i > 5) {
            LOGE("Someone else, besides client, is holding the refernce. We might have trouble.");
            break;
        }
    }

    CODEC_LOGV("stopped");

    return OK;