Ticket #2434: patch2.txt

File patch2.txt, 2.0 KB (added by Matt Holgate <matt-bulk-mythtv@…>, 14 years ago)

New patch which addresses race issue more correctly.

Line 
1Index: libs/libmythtv/NuppelVideoPlayer.cpp
2===================================================================
3--- libs/libmythtv/NuppelVideoPlayer.cpp        (revision 11497)
4+++ libs/libmythtv/NuppelVideoPlayer.cpp        (working copy)
5@@ -396,15 +396,9 @@
6 void NuppelVideoPlayer::Pause(bool waitvideo)
7 {
8+    assert(waitvideo); /* nothing seems to call this with waitvideo == false */
9+
10     PauseDecoder();
11 
12     //cout << "stopping other threads" << endl;
13-    PauseVideo(waitvideo);
14-    if (audioOutput)
15-    {
16-        audio_paused = true;
17-        audioOutput->Pause(true);
18-    }
19-    if (ringBuffer)
20-        ringBuffer->Pause();
21 
22     QMutexLocker locker(&decoder_change_lock);
23@@ -426,9 +420,6 @@
24             .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio));
25 
26-    UnpauseVideo();
27     if (audioOutput && unpauseaudio)
28         audio_paused = false;
29-    if (ringBuffer)
30-        ringBuffer->Unpause();
31 
32     decoder_lock.lock();
33@@ -3182,4 +3173,13 @@
34             decoder_lock.lock();
35 
36+            /* If old play_speed was 0, then we were paused */
37+            if (play_speed == 0.0)
38+            {
39+                UnpauseVideo();
40+
41+                if (ringBuffer)
42+                    ringBuffer->Unpause();
43+            }
44+
45             play_speed = next_play_speed;
46             normal_speed = next_normal_speed;
47@@ -3189,7 +3189,19 @@
48                 GetDecoder()->UpdateDVDFramesPlayed();
49 
50+            /* If new play_speed is 0, then we are paused */
51             if (play_speed == 0.0)
52             {
53                 DoPause();
54+                PauseVideo(true);
55+
56+                if (audioOutput)
57+                {
58+                    audio_paused = true;
59+                    audioOutput->Pause(true);
60+                }
61+
62+                if (ringBuffer)
63+                    ringBuffer->Pause();
64+
65                 decoderThreadPaused.wakeAll();
66             }
67Index: libs/libmythtv/NuppelVideoPlayer.h
68===================================================================