summaryrefslogtreecommitdiff
path: root/audio/liveice/patches/patch-ab
blob: 47e1660bc33c542b7b2a9842172098b6b50b8962 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
$NetBSD: patch-ab,v 1.2 2001/05/05 10:05:34 wiz Exp $

--- streams.c.orig	Tue May 23 20:08:00 2000
+++ streams.c
@@ -36,7 +36,11 @@
 #ifdef HAVE_SYS_SOUNDCARD_H
 #include <sys/soundcard.h>
 #else
+#ifdef __NetBSD__
+#include <sys/audioio.h>
+#else
 #include <machine/soundcard.h>
+#endif /* __NetBSD__ */
 #endif
 #endif
 #include <sys/ioctl.h>
@@ -77,11 +81,23 @@
 {
         int format,stereo,speed,caps;
 #ifdef SOUNDCARD_SUPPORT
+
+#ifdef __NetBSD__
+	audio_info_t ctlinfo;
+#endif /* __NetBSD__ */
+
 	fprintf(stderr,"Initialising Soundcard\n");
 
+#ifdef __NetBSD__
+	if((g_conf.audioctl_fd=open(g_conf.netbsd_audioctl_file,O_RDWR))==-1)
+	        fatal("Failed to open audioctl device");
+	if((g_conf.audio_fd=open(g_conf.netbsd_audio_file,O_RDONLY))==-1)
+#else
 	if((g_conf.audio_fd=open(g_conf.sound_input_file,O_RDWR))==-1)
+#endif /* __NetBSD__ */
 	        fatal("Failed to open sound device");
 
+#ifndef __NetBSD__
         /* see if the card can do full_duplex */
         if(g_conf.full_duplex){
                 ioctl(g_conf.audio_fd, SNDCTL_DSP_GETCAPS, &caps);
@@ -97,7 +113,33 @@
 			g_conf.full_duplex=0;
 		}
 	}
+#endif /* __NetBSD__ */
 
+#ifdef __NetBSD__
+	if(ioctl(g_conf.audioctl_fd, AUDIO_GETINFO, &(g_conf.ctlrestore)) < 0)
+		fatal("ioctl(AUDIO_GETINFO) failed");
+
+	/* in theory, we should pull ctlrestore.record.buffer_size and use
+	   that to malloc() our audio buffer, but in practice, this has 
+	   shown to be unneccesary.  This will minimize impact to the 
+	   original source and reduce the amount of patching we need.
+	*/
+
+	/* somewhere in here, we should be able to check/set full duplex,
+	   but I don't know enough about the internals of this driver yet.
+	*/
+	g_conf.full_duplex = 0;
+
+	AUDIO_INITINFO(&ctlinfo);
+	ctlinfo.record.sample_rate = g_conf.sample_rate;
+	ctlinfo.record.channels = (g_conf.stereo ? 2 : 1);
+	ctlinfo.record.precision = 16;
+	ctlinfo.record.encoding = AUDIO_ENCODING_SLINEAR_LE;
+	ctlinfo.mode = AUMODE_RECORD;
+
+	if(ioctl(g_conf.audioctl_fd, AUDIO_SETINFO, &ctlinfo) < 0)
+		fatal("ioctl(AUDIO_SETINFO) failed");
+#else
 	ioctl(g_conf.audio_fd, SNDCTL_DSP_GETFMTS, &format);
 	if(!(format&AFMT_S16_LE))
 		fatal("16bit mode not supported by driver");
@@ -113,6 +155,7 @@
 	speed=g_conf.sample_rate;
 	if(ioctl(g_conf.audio_fd,SNDCTL_DSP_SPEED,&speed)==-1)
 		fatal("Speed Setting failed\n");
+#endif /* __NetBSD__ */
 
 	
 	fprintf(stderr,"16Bit %dHz ",g_conf.sample_rate);
@@ -121,8 +164,10 @@
 	if(g_conf.full_duplex)
 	 	  fprintf(stderr,"Full Duplex ");
 	fprintf(stderr,"\n");
+#ifndef __NetBSD__
 	close(g_conf.audio_fd);
 	g_conf.audio_fd=0;
+#endif /* __NetBSD__ */
 #else
 	write_message("This executable Doesn't Support Soundcards",0);
 #endif
@@ -136,9 +181,10 @@
 #ifdef SOUNDCARD_SUPPORT
        write_message("Opening Soundcard",1);
         
+#ifndef __NetBSD__
 	if((g_conf.audio_fd=open(g_conf.sound_input_file,flags))==-1)
 	        fatal("Failed to open sound device");
-	
+
         if(g_conf.full_duplex)
 #ifdef HAVE_SYS_SOUNDCARD_H
 	        ioctl(g_conf.audio_fd, SNDCTL_DSP_SETDUPLEX, 0);  
@@ -157,6 +203,7 @@
 	speed=g_conf.sample_rate;
 	if(ioctl(g_conf.audio_fd,SNDCTL_DSP_SPEED,&speed)==-1)
 		fatal("Speed Setting failed\n");
+#endif /* __NetBSD__ */
 #else
 	write_message("This executable Doesn't Support Soundcards",0);
 #endif
@@ -166,8 +213,21 @@
 {
 #ifdef SOUNDCARD_SUPPORT
 	write_message("Closing Soundcard",1);
+#ifdef __NetBSD__
+	close(g_conf.audio_fd);
+
+	/* In theory, we should reset the device.  In practice, this 
+	   segfaults.  I haven't figured out why.
+
+	if(ioctl(g_conf.audioctl_fd, AUDIO_SETINFO, &(g_conf.ctlrestore)) < 0)
+		fatal("ioctl(AUDIO_SETINFO) failed");
+	*/
+
+	close(g_conf.audioctl_fd);
+#else
 	ioctl(g_conf.audio_fd, SNDCTL_DSP_RESET, 0);
         close(g_conf.audio_fd);
+#endif /* __NetBSD__ */
 #else
 	write_message("This executable Doesn't Support Soundcards",0);
 #endif