File: 09_looper_thread.dpatch

package info (click to toggle)
alsaplayer 0.99.76-9%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 4,752 kB
  • ctags: 2,970
  • sloc: ansic: 16,775; sh: 10,709; cpp: 9,442; makefile: 694
file content (52 lines) | stat: -rw-r--r-- 1,328 bytes parent folder | download | duplicates (2)
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
#! /bin/sh /usr/share/dpatch/dpatch-run
## 09_looper_thread.dpatch by  <hubert@uhoreg.ca>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: check that looper_thread was initialized before trying to join it
## DP: taken from alsaplayer CVS (committed on 2004-01-16)

@DPATCH@
--- alsaplayer-0.99.76/alsaplayer/AlsaNode.h	4 Aug 2003 20:34:37 -0000	1.9
+++ alsaplayer-cvs/alsaplayer/AlsaNode.h	16 Jan 2004 17:31:51 -0000	1.10
@@ -75,6 +75,7 @@
 	char *driver_args;
 	char client_name[32];
 	bool realtime_sched;
+	bool thread_running;
 	bool init;
 	bool looping;
 	static void looper(void *);
--- alsaplayer-0.99.76/app/AlsaNode.cpp	23 Apr 2003 23:21:06 -0000	1.62
+++ alsaplayer-cvs/app/AlsaNode.cpp	16 Jan 2004 17:31:50 -0000	1.63
@@ -66,6 +66,7 @@
 	driver_args = NULL;
 	nr_fragments = fragment_size = external_latency = 0;	
 	init = false;
+	thread_running = false;
 	realtime_sched = realtime;
 	sample_freq = OUTPUT_RATE;
 
@@ -461,6 +462,7 @@
 		return;
 	} 
 	pthread_create(&looper_thread, NULL, (void * (*)(void *))looper, this);
+	thread_running = true;
 }
 
 
@@ -473,9 +475,12 @@
 	}	
 	
 	looping = false;
-	if (pthread_join(looper_thread, NULL)) {
-		// Hmmm
-	}
+	if (thread_running) {
+		if (pthread_join(looper_thread, NULL)) {
+			// Hmmm
+		}
+		thread_running = false;
+	}	
 }