aboutsummaryrefslogtreecommitdiffstats
path: root/multimedia/vdr-plugin-xvdr/files/patch-81bde12cd5d36a5bb0f1bc5791977b58cc34f91e
blob: 1e1939e3b0ee92982d8806485a2c0162c221af6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
commit 81bde12cd5d36a5bb0f1bc5791977b58cc34f91e
Author: Alexander Pipelka <alexander.pipelka@gmail.com>
Date:   Mon Dec 19 10:30:16 2011 +0100

    wait until streaming stopped before switching to a new channel, thanks Juergen Lock

diff --git a/src/xvdr/xvdrclient.c b/src/xvdr/xvdrclient.c
index ced735e..8078454 100644
--- a/src/xvdr/xvdrclient.c
+++ b/src/xvdr/xvdrclient.c
@@ -72,6 +72,7 @@ static uint32_t recid2uid(const char* recid)
 }
 
 cMutex cXVDRClient::m_timerLock;
+cMutex cXVDRClient::m_switchLock;
 
 cXVDRClient::cXVDRClient(int fd, unsigned int id, const char *ClientAdr)
 {
@@ -183,6 +184,7 @@ void cXVDRClient::Action(void)
 
 bool cXVDRClient::StartChannelStreaming(const cChannel *channel, uint32_t timeout)
 {
+  cMutexLock lock(&m_switchLock);
   m_Streamer = new cLiveStreamer(timeout);
   m_Streamer->SetLanguage(m_LanguageIndex, m_LangStreamType);
 
@@ -192,12 +194,10 @@ bool cXVDRClient::StartChannelStreaming(const cChannel *channel, uint32_t timeou
 
 void cXVDRClient::StopChannelStreaming()
 {
+  cMutexLock lock(&m_switchLock);
+  delete m_Streamer;
+  m_Streamer = NULL;
   m_isStreaming = false;
-  if (m_Streamer)
-  {
-    delete m_Streamer;
-    m_Streamer = NULL;
-  }
 }
 
 void cXVDRClient::TimerChange(const cTimer *Timer, eTimerChange Change)
@@ -640,8 +640,7 @@ bool cXVDRClient::processChannelStream_Open() /* OPCODE 20 */
   if(timeout == 0)
     timeout = XVDRServerConfig.stream_timeout;
 
-  if (m_isStreaming)
-    StopChannelStreaming();
+  StopChannelStreaming();
 
   Channels.Lock(false);
   const cChannel *channel = NULL;
@@ -679,9 +678,7 @@ bool cXVDRClient::processChannelStream_Open() /* OPCODE 20 */
 
 bool cXVDRClient::processChannelStream_Close() /* OPCODE 21 */
 {
-  if (m_isStreaming)
-    StopChannelStreaming();
-
+  StopChannelStreaming();
   return true;
 }
 
diff --git a/src/xvdr/xvdrclient.h b/src/xvdr/xvdrclient.h
index e602c70..99bae64 100644
--- a/src/xvdr/xvdrclient.h
+++ b/src/xvdr/xvdrclient.h
@@ -64,6 +64,7 @@ private:
   uint32_t         m_protocolVersion;
   cMutex           m_msgLock;
   static cMutex    m_timerLock;
+  static cMutex    m_switchLock;
   int              m_compressionLevel;
   int              m_LanguageIndex;
   eStreamType      m_LangStreamType;