]> git.vomp.tv Git - vompclient.git/blob - signal.cc
Display channel name, duration, resume point and size on recording info screen
[vompclient.git] / signal.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20 #include "signal.h"
21
22
23 Signal::Signal()
24 {
25         pthread_cond_init(&cond, NULL);
26         pthread_mutex_init(&condMutex, NULL);
27 }
28
29 Signal::~Signal()
30 {
31         pthread_cond_destroy(&cond);
32         pthread_mutex_destroy(&condMutex);
33 }
34
35
36
37 void Signal::signal()
38 {
39 #ifndef WIN32
40   pthread_mutex_lock(&condMutex);
41   pthread_cond_signal(&cond);
42   pthread_mutex_unlock(&condMutex);
43 #else
44 #error "Not ported yet"
45 #endif
46 }
47
48 void Signal::waitForSignal()
49 {
50 #ifndef WIN32
51   pthread_mutex_lock(&condMutex);
52   pthread_cond_wait(&cond, &condMutex);
53   pthread_mutex_unlock(&condMutex);
54 #else
55 #error "Not ported yet"
56 #endif
57 }
58
59 void Signal::waitForSignalTimed(struct timespec* ts)
60 {
61 #ifndef WIN32
62   pthread_mutex_lock(&condMutex);
63   pthread_cond_timedwait(&cond, &condMutex, ts);
64   pthread_mutex_unlock(&condMutex);
65 #else
66 #error "Not ported yet"
67 #endif
68 }
69
70 void Signal::waitForSignalTimed(unsigned int ts)
71 {
72         struct timespec target_time;
73         clock_gettime(CLOCK_REALTIME,&target_time);
74         target_time.tv_nsec+=1000000LL*ts;
75         if (target_time.tv_nsec>999999999) {
76                 target_time.tv_nsec-=1000000000L;
77                 target_time.tv_sec+=1;
78         }
79         waitForSignalTimed(&target_time);
80 }