]> git.sesse.net Git - mlt/commitdiff
rtaudio/consumer_rtaudio.cpp: use mutex when changing refresh_count
authorMikko Rapeli <mikko.rapeli@iki.fi>
Wed, 1 Aug 2012 13:06:22 +0000 (15:06 +0200)
committerMikko Rapeli <mikko.rapeli@iki.fi>
Mon, 6 Aug 2012 16:37:28 +0000 (18:37 +0200)
Fixes Coverity CID 710859: Data race condition (MISSING_LOCK)
Accessing variable "this->refresh_count" (RtAudioConsumer.refresh_count) requires the RtAudioConsumer.refresh_mutex lock.
225                refresh_count = 0;
...
Locking "this->refresh_mutex".
282                                        pthread_mutex_lock( &refresh_mutex );
283                                        if ( refresh == 0 && refresh_count <= 0 )
284                                        {
285                                                play_video( frame );
286                                                pthread_cond_wait( &refresh_cond, &refresh_mutex );
287                                        }
288                                        mlt_frame_close( frame );
RtAudioConsumer.refresh_count is being accessed with lock "this->refresh_mutex" held.
289                                        refresh_count --;
290                                        pthread_mutex_unlock( &refresh_mutex );
...
Locking "rtaudio->refresh_mutex".
561                pthread_mutex_lock( &rtaudio->refresh_mutex );
RtAudioConsumer.refresh_count is being accessed with lock "rtaudio->refresh_mutex" held.
562                rtaudio->refresh_count = rtaudio->refresh_count <= 0 ? 1 : rtaudio->refresh_count + 1;
563                pthread_cond_broadcast( &rtaudio->refresh_cond );
564                pthread_mutex_unlock( &rtaudio->refresh_mutex );

src/modules/rtaudio/consumer_rtaudio.cpp

index 57e59d241fd6c1f5b1d09ada282417da2bc5b3e0..1526e335e964dbac888e31c813ad03077bfedfb0 100644 (file)
@@ -225,7 +225,10 @@ public:
                int64_t playtime = 0;
                struct timespec tm = { 0, 100000 };
        //      int last_position = -1;
+
+               pthread_mutex_lock( &refresh_mutex );
                refresh_count = 0;
+               pthread_mutex_unlock( &refresh_mutex );
 
                // Loop until told not to
                while ( running )