Diffstat (limited to 'noncore/multimedia/opierec/device.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index 11071d8..ce49e96 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -1,65 +1,67 @@ | |||
1 | // device.cpp | 1 | // device.cpp |
2 | 2 | ||
3 | #include "device.h" | 3 | #include "device.h" |
4 | 4 | ||
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
7 | #include <qpe/custom.h> | 7 | |
8 | 8 | ||
9 | #include <fcntl.h> | 9 | #include <fcntl.h> |
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <sys/ioctl.h> | 12 | #include <sys/ioctl.h> |
13 | #include <sys/soundcard.h> | 13 | #include <sys/soundcard.h> |
14 | #include <unistd.h> | 14 | #include <unistd.h> |
15 | #include<sys/wait.h> | 15 | #include<sys/wait.h> |
16 | // #include <sys/stat.h> | 16 | // #include <sys/stat.h> |
17 | // #include <sys/time.h> | 17 | // #include <sys/time.h> |
18 | // #include <sys/types.h> | 18 | // #include <sys/types.h> |
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | #include <errno.h> | 20 | #include <errno.h> |
21 | 21 | ||
22 | //extern QtRec *qperec; | 22 | //extern QtRec *qperec; |
23 | 23 | ||
24 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) | 24 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) |
25 | : QObject( parent) | 25 | : QObject( parent) |
26 | { | 26 | { |
27 | dspstr = (char *)dsp; | 27 | dspstr = (char *)dsp; |
28 | mixstr = (char *)mixr; | 28 | mixstr = (char *)mixr; |
29 | 29 | ||
30 | devForm=-1; | 30 | devForm=-1; |
31 | devCh=-1; | 31 | devCh=-1; |
32 | devRate=-1; | 32 | devRate=-1; |
33 | 33 | ||
34 | if( !record){ //playing | 34 | if( !record){ //playing |
35 | qDebug("setting up DSP for playing"); | 35 | qDebug("setting up DSP for playing"); |
36 | flags = O_WRONLY; | 36 | flags = O_WRONLY; |
37 | } else { //recording | 37 | } else { //recording |
38 | qDebug("setting up DSP for recording"); | 38 | qDebug("setting up DSP for recording"); |
39 | flags = O_RDWR; | 39 | flags = O_RDWR; |
40 | // flags = O_RDONLY; | 40 | // flags = O_RDONLY; |
41 | selectMicInput(); | 41 | |
42 | // selectMicInput(); | ||
43 | |||
42 | } | 44 | } |
43 | } | 45 | } |
44 | 46 | ||
45 | bool Device::openDsp() { | 47 | bool Device::openDsp() { |
46 | if( openDevice( flags) == -1) { | 48 | if( openDevice( flags) == -1) { |
47 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); | 49 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); |
48 | return false; | 50 | return false; |
49 | } | 51 | } |
50 | return true; | 52 | return true; |
51 | } | 53 | } |
52 | 54 | ||
53 | int Device::getOutVolume( ) { | 55 | int Device::getOutVolume( ) { |
54 | unsigned int volume; | 56 | unsigned int volume; |
55 | int mixerHandle = open( mixstr, O_RDWR ); | 57 | int mixerHandle = open( mixstr, O_RDWR ); |
56 | if ( mixerHandle >= 0 ) { | 58 | if ( mixerHandle >= 0 ) { |
57 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) | 59 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) |
58 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 60 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
59 | ::close( mixerHandle ); | 61 | ::close( mixerHandle ); |
60 | } else | 62 | } else |
61 | perror("open(\"/dev/mixer\")"); | 63 | perror("open(\"/dev/mixer\")"); |
62 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); | 64 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); |
63 | 65 | ||
64 | Config cfg("qpe"); | 66 | Config cfg("qpe"); |
65 | cfg.setGroup("Volume"); | 67 | cfg.setGroup("Volume"); |
@@ -73,177 +75,183 @@ int Device::getInVolume() { | |||
73 | if ( mixerHandle >= 0 ) { | 75 | if ( mixerHandle >= 0 ) { |
74 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) | 76 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) |
75 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 77 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
76 | ::close( mixerHandle ); | 78 | ::close( mixerHandle ); |
77 | } else | 79 | } else |
78 | perror("open(\"/dev/mixer\")"); | 80 | perror("open(\"/dev/mixer\")"); |
79 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); | 81 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); |
80 | Config cfg("qpe"); | 82 | Config cfg("qpe"); |
81 | cfg.setGroup("Volume"); | 83 | cfg.setGroup("Volume"); |
82 | 84 | ||
83 | return cfg.readNumEntry("Mic"); | 85 | return cfg.readNumEntry("Mic"); |
84 | } | 86 | } |
85 | 87 | ||
86 | void Device::changedOutVolume(int vol) { | 88 | void Device::changedOutVolume(int vol) { |
87 | int level = (vol << 8) + vol; | 89 | int level = (vol << 8) + vol; |
88 | int fd = 0; | 90 | int fd = 0; |
89 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 91 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
90 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) | 92 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) |
91 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 93 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
92 | 94 | ||
93 | Config cfg("qpe"); | 95 | Config cfg("qpe"); |
94 | cfg.setGroup("Volume"); | 96 | cfg.setGroup("Volume"); |
95 | cfg.writeEntry("VolumePercent", QString::number( vol )); | 97 | cfg.writeEntry("VolumePercent", QString::number( vol )); |
96 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 98 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
99 | qWarning("changing output vol %d", vol); | ||
97 | } | 100 | } |
98 | ::close(fd); | 101 | ::close(fd); |
99 | } | 102 | } |
100 | 103 | ||
101 | void Device::changedInVolume(int vol ) { | 104 | void Device::changedInVolume(int vol ) { |
102 | int level = (vol << 8) + vol; | 105 | int level = (vol << 8) + vol; |
103 | int fd = 0; | 106 | int fd = 0; |
104 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 107 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
105 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) | 108 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) |
106 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 109 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
107 | Config cfg("qpe"); | 110 | Config cfg("qpe"); |
108 | cfg.setGroup("Volume"); | 111 | cfg.setGroup("Volume"); |
109 | cfg.writeEntry("Mic", QString::number(vol )); | 112 | cfg.writeEntry("Mic", QString::number(vol )); |
110 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; | 113 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; |
114 | qWarning("changing input volume %d", vol); | ||
111 | } | 115 | } |
112 | ::close(fd); | 116 | ::close(fd); |
113 | } | 117 | } |
114 | 118 | ||
115 | bool Device::selectMicInput() { | 119 | bool Device::selectMicInput() { |
116 | /* | 120 | |
117 | int md=0; | 121 | int md=0; |
118 | int info=MIXER_WRITE(SOUND_MIXER_MIC); | 122 | int info=MIXER_WRITE(SOUND_MIXER_MIC); |
119 | md = ::open( "/dev/mixer", O_RDWR ); | 123 | md = ::open( "/dev/mixer", O_RDWR ); |
120 | if ( md == -1) | 124 | if ( md == -1) |
121 | perror("open(\"/dev/mixer\")"); | 125 | perror("open(\"/dev/mixer\")"); |
122 | else { | 126 | else { |
123 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) | 127 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) |
124 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); | 128 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); |
125 | ::close(md); | 129 | ::close(md); |
126 | return false; | 130 | return false; |
127 | } | 131 | } |
128 | ::close(md); | 132 | ::close(md); |
129 | */ | 133 | |
130 | return true; | 134 | return true; |
131 | } | 135 | } |
132 | 136 | ||
133 | int Device::openDevice( int flags) { | 137 | int Device::openDevice( int flags) { |
134 | /* pid_t pid; | 138 | /* pid_t pid; |
135 | int status; | 139 | int status; |
136 | int pipefd[2]; | 140 | int pipefd[2]; |
137 | char message[20]; | 141 | char message[20]; |
138 | if (pipe(pipefd) == -1){ | 142 | if (pipe(pipefd) == -1){ |
139 | perror ("Error creating pipe"); | 143 | perror ("Error creating pipe"); |
140 | exit(1); | 144 | exit(1); |
141 | } | 145 | } |
142 | switch (pid = fork()) { | 146 | switch (pid = fork()) { |
143 | case -1: | 147 | case -1: |
144 | perror("The fork failed!"); | 148 | perror("The fork failed!"); |
145 | break; | 149 | break; |
146 | case 0: { | 150 | case 0: { |
147 | */ | 151 | */ |
148 | if (( sd = ::open( dspstr, flags)) == -1) { | 152 | qDebug("Opening %s",dspstr); |
153 | if (( sd = ::open( dspstr, flags)) == -1) { | ||
149 | perror("open(\"/dev/dsp\")"); | 154 | perror("open(\"/dev/dsp\")"); |
150 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 155 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
151 | +(QString)strerror(errno); | 156 | +(QString)strerror(errno); |
152 | qDebug(errorMsg); | 157 | qDebug("XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg); |
153 | return -1; | 158 | return -1; |
154 | } | 159 | } |
155 | 160 | ||
161 | qDebug("Opening mixer"); | ||
156 | int mixerHandle=0; | 162 | int mixerHandle=0; |
157 | /* Set the input dsp device and its input gain the weird Zaurus way */ | 163 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { |
158 | if (( mixerHandle = open("/dev/mixer1",O_RDWR))<0) { | 164 | perror("open(\"/dev/mixer\")"); |
159 | perror("open(\"/dev/mixer1\")"); | 165 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
166 | +(QString)strerror(errno); | ||
167 | qDebug("XXXXXXXXXXXXXXXXXXXXXX "+errorMsg); | ||
160 | } | 168 | } |
161 | 169 | ||
162 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | 170 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ |
163 | perror("ioctl RESET"); | 171 | perror("ioctl RESET"); |
164 | } | 172 | } |
165 | // sprintf(message, "%d", sd); | 173 | // sprintf(message, "%d", sd); |
166 | 174 | ||
167 | /* QFile f1("/pid"); | 175 | /* QFile f1("/pid"); |
168 | f1.open(IO_WriteOnly ); | 176 | f1.open(IO_WriteOnly ); |
169 | f1.writeBlock(message, strlen(message)); | 177 | f1.writeBlock(message, strlen(message)); |
170 | f1.close(); | 178 | f1.close(); |
171 | */ | 179 | */ |
172 | /* close(pipefd[0]); | 180 | /* close(pipefd[0]); |
173 | write(pipefd[1], message, sizeof(message)); | 181 | write(pipefd[1], message, sizeof(message)); |
174 | close(pipefd[1]); | 182 | close(pipefd[1]); |
175 | // qDebug("%d",soundDevice->sd ); | 183 | // qDebug("%d",soundDevice->sd ); |
176 | _exit(0); | 184 | _exit(0); |
177 | } | 185 | } |
178 | default: | 186 | default: |
179 | // pid greater than zero is parent getting the child's pid | 187 | // pid greater than zero is parent getting the child's pid |
180 | printf("Child's pid is %d\n",pid); | 188 | printf("Child's pid is %d\n",pid); |
181 | QString s; | 189 | QString s; |
182 | close(pipefd[1]); | 190 | close(pipefd[1]); |
183 | read(pipefd[0], message, sizeof(message)); | 191 | read(pipefd[0], message, sizeof(message)); |
184 | s = message; | 192 | s = message; |
185 | close(pipefd[0]); | 193 | close(pipefd[0]); |
186 | 194 | ||
187 | // while(wait(NULL)!=pid) | 195 | // while(wait(NULL)!=pid) |
188 | // ; | 196 | // ; |
189 | printf("child %ld terminated normally, return status is zero\n", (long) pid); | 197 | printf("child %ld terminated normally, return status is zero\n", (long) pid); |
190 | */ | 198 | */ |
191 | // filePara.sd=(long) pid; | 199 | // filePara.sd=(long) pid; |
192 | /* QFile f2("/pid"); | 200 | /* QFile f2("/pid"); |
193 | f2.open(IO_ReadOnly); | 201 | f2.open(IO_ReadOnly); |
194 | QTextStream t(&f2); | 202 | QTextStream t(&f2); |
195 | // for(int f=0; f < t.atEnd() ;f++) { | 203 | // for(int f=0; f < t.atEnd() ;f++) { |
196 | s = t.readLine(); | 204 | s = t.readLine(); |
197 | // } | 205 | // } |
198 | */ | 206 | */ |
199 | // bool ok; | 207 | // bool ok; |
200 | // sd = s.toInt(&ok, 10); | 208 | // sd = s.toInt(&ok, 10); |
201 | // qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s); | 209 | // qDebug("<<<<<<<<<<<<<>>>>>>>>>>>>"+s); |
202 | 210 | ||
203 | // f2.close(); | 211 | // f2.close(); |
204 | // } | 212 | // } |
205 | ::close(mixerHandle ); | 213 | ::close(mixerHandle ); |
206 | qDebug("open device %s", dspstr); | 214 | // qDebug("open device %s", dspstr); |
207 | qDebug("success! %d",sd); | 215 | // qDebug("success! %d",sd); |
208 | return sd; | 216 | return sd; |
209 | } | 217 | } |
210 | 218 | ||
211 | bool Device::closeDevice( bool b) { | 219 | bool Device::closeDevice( bool) { |
212 | // if(b) {//close now | 220 | // if(b) {//close now |
213 | // if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { | 221 | // if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { |
214 | // perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 222 | // perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
215 | // } | 223 | // } |
216 | // } else { //let play | 224 | // } else { //let play |
217 | // if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { | 225 | // if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { |
218 | // perror("ioctl(\"SNDCTL_DSP_SYNC\")"); | 226 | // perror("ioctl(\"SNDCTL_DSP_SYNC\")"); |
219 | // } | 227 | // } |
220 | // } | 228 | // } |
221 | 229 | ||
222 | ::close( sd); //close sound device | 230 | ::close( sd); //close sound device |
223 | // sdfd=0; | 231 | // sdfd=0; |
224 | // sd=0; | 232 | // sd=0; |
225 | qDebug("closed dsp"); | 233 | // qDebug("closed dsp"); |
226 | return true; | 234 | return true; |
227 | } | 235 | } |
228 | 236 | ||
229 | bool Device::setDeviceFormat( int form) { | 237 | bool Device::setDeviceFormat( int form) { |
230 | qDebug("set device res %d %d", form, sd); | 238 | qDebug("set device res %d %d", form, sd); |
231 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format | 239 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format |
232 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 240 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
233 | return false; | 241 | return false; |
234 | } | 242 | } |
235 | devRes=form; | 243 | devRes=form; |
236 | return true; | 244 | return true; |
237 | } | 245 | } |
238 | 246 | ||
239 | bool Device::setDeviceChannels( int ch) { | 247 | bool Device::setDeviceChannels( int ch) { |
240 | qDebug("set channels %d %d", ch, sd); | 248 | qDebug("set channels %d %d", ch, sd); |
241 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { | 249 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { |
242 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 250 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
243 | return false; | 251 | return false; |
244 | } | 252 | } |
245 | devCh=ch; | 253 | devCh=ch; |
246 | return true; | 254 | return true; |
247 | } | 255 | } |
248 | 256 | ||
249 | bool Device::setDeviceRate( int rate) { | 257 | bool Device::setDeviceRate( int rate) { |
@@ -269,67 +277,82 @@ int Device::getFormat() { | |||
269 | int Device::getRate() { | 277 | int Device::getRate() { |
270 | return devRate; | 278 | return devRate; |
271 | } | 279 | } |
272 | 280 | ||
273 | int Device::getChannels() { | 281 | int Device::getChannels() { |
274 | return devCh; | 282 | return devCh; |
275 | } | 283 | } |
276 | 284 | ||
277 | int Device::getDeviceFormat() { | 285 | int Device::getDeviceFormat() { |
278 | return 0; | 286 | return 0; |
279 | } | 287 | } |
280 | 288 | ||
281 | 289 | ||
282 | int Device::getDeviceRate() { | 290 | int Device::getDeviceRate() { |
283 | int dRate=0; | 291 | int dRate=0; |
284 | if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) { | 292 | if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) { |
285 | perror("ioctl(\"SNDCTL_PCM_READ_RATE\")"); | 293 | perror("ioctl(\"SNDCTL_PCM_READ_RATE\")"); |
286 | } | 294 | } |
287 | return dRate; | 295 | return dRate; |
288 | 296 | ||
289 | } | 297 | } |
290 | 298 | ||
291 | int Device::getDeviceBits() { | 299 | int Device::getDeviceBits() { |
292 | int dBits=0; | 300 | int dBits=0; |
293 | #if !defined(OPIE_NO_SOUND_PCM_READ_BITS) // zaurus doesnt have this | 301 | #ifndef QT_QWS_EBX // zaurus doesnt have this |
294 | if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) { | 302 | if (ioctl( sd, SOUND_PCM_READ_BITS, &dBits) == -1) { |
295 | perror("ioctl(\"SNDCTL_PCM_READ_BITS\")"); | 303 | perror("ioctl(\"SNDCTL_PCM_READ_BITS\")"); |
296 | } | 304 | } |
297 | #endif | 305 | #endif |
298 | return dBits; | 306 | return dBits; |
299 | } | 307 | } |
300 | 308 | ||
301 | int Device::getDeviceChannels() { | 309 | int Device::getDeviceChannels() { |
302 | int dCh=0; | 310 | int dCh=0; |
303 | if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) { | 311 | if (ioctl( sd, SOUND_PCM_READ_CHANNELS, &dCh) == -1) { |
304 | perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")"); | 312 | perror("ioctl(\"SNDCTL_PCM_READ_CHANNELS\")"); |
305 | } | 313 | } |
306 | return dCh; | 314 | return dCh; |
307 | } | 315 | } |
308 | 316 | ||
309 | int Device::getDeviceFragSize() { | 317 | int Device::getDeviceFragSize() { |
310 | int frag_size; | 318 | int frag_size; |
311 | 319 | ||
312 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { | 320 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { |
313 | qDebug("no fragsize"); | 321 | qDebug("no fragsize"); |
314 | } else | 322 | } else { |
315 | qDebug("driver says frag size is %d", frag_size); | 323 | qDebug("driver says frag size is %d", frag_size); |
324 | } | ||
316 | return frag_size; | 325 | return frag_size; |
317 | } | 326 | } |
318 | 327 | ||
319 | bool Device::setFragSize(int frag) { | 328 | bool Device::setFragSize(int frag) { |
320 | if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) { | 329 | if (ioctl(sd, SNDCTL_DSP_SETFRAGMENT, &frag)) { |
321 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 330 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
322 | return false; | 331 | return false; |
323 | } | 332 | } |
324 | return true; | 333 | return true; |
325 | } | 334 | } |
326 | 335 | ||
327 | bool Device::reset() { | 336 | bool Device::reset() { |
328 | closeDevice(true); | 337 | closeDevice(true); |
329 | openDsp(); | 338 | openDsp(); |
330 | if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { | 339 | if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { |
331 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 340 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
332 | return false; | 341 | return false; |
333 | } | 342 | } |
334 | return true; | 343 | return true; |
335 | } | 344 | } |
345 | |||
346 | int Device::devRead(int soundDescriptor, short *buf, int size) { | ||
347 | int number = 0; | ||
348 | number = ::read( soundDescriptor, (char *)buf, size); | ||
349 | return number; | ||
350 | } | ||
351 | |||
352 | int Device::devWrite(int soundDescriptor, short * buf, int size) { | ||
353 | int bytesWritten = 0; | ||
354 | bytesWritten = ::write( soundDescriptor, buf, size); | ||
355 | return bytesWritten; | ||
356 | } | ||
357 | |||
358 | |||