author | llornkcor <llornkcor> | 2004-04-25 20:37:28 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-25 20:37:28 (UTC) |
commit | ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3 (patch) (unidiff) | |
tree | a086457c05142e1ac2749844ffcb458d96550c6f /noncore/multimedia/opierec/device.cpp | |
parent | 22d51bcaa58b90a3ffd4d429c43e6c24e1694ab3 (diff) | |
download | opie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.zip opie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.tar.gz opie-ae76c412a340a0808ed6ece5e4a8fbc04baa4ff3.tar.bz2 |
soundcard descriptor mucking about
Diffstat (limited to 'noncore/multimedia/opierec/device.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index 5319d97..db2d63f 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -26,16 +26,16 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco | |||
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 | odebug << "setting up DSP for playing" << oendl; | 35 | odebug << "setting up DSP for playing" << oendl; |
36 | flags = O_WRONLY; | 36 | flags = O_WRONLY; |
37 | } else { //recording | 37 | } else { //recording |
38 | odebug << "setting up DSP for recording" << oendl; | 38 | odebug << "setting up DSP for recording" << oendl; |
39 | flags = O_RDWR; | 39 | flags = O_RDWR; |
40 | // flags = O_RDONLY; | 40 | // flags = O_RDONLY; |
41 | 41 | ||
@@ -96,7 +96,7 @@ void Device::changedOutVolume(int vol) { | |||
96 | cfg.setGroup("Volume"); | 96 | cfg.setGroup("Volume"); |
97 | cfg.writeEntry("VolumePercent", QString::number( vol )); | 97 | cfg.writeEntry("VolumePercent", QString::number( vol )); |
98 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 98 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
99 | owarn << "changing output vol " << vol << "" << oendl; | 99 | owarn << "changing output vol " << vol << "" << oendl; |
100 | } | 100 | } |
101 | ::close(fd); | 101 | ::close(fd); |
102 | } | 102 | } |
@@ -111,7 +111,7 @@ void Device::changedInVolume(int vol ) { | |||
111 | cfg.setGroup("Volume"); | 111 | cfg.setGroup("Volume"); |
112 | cfg.writeEntry("Mic", QString::number(vol )); | 112 | cfg.writeEntry("Mic", QString::number(vol )); |
113 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; | 113 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; |
114 | owarn << "changing input volume " << vol << "" << oendl; | 114 | owarn << "changing input volume " << vol << "" << oendl; |
115 | } | 115 | } |
116 | ::close(fd); | 116 | ::close(fd); |
117 | } | 117 | } |
@@ -149,22 +149,22 @@ exit(1); | |||
149 | break; | 149 | break; |
150 | case 0: { | 150 | case 0: { |
151 | */ | 151 | */ |
152 | odebug << "Opening " << dspstr << "" << oendl; | 152 | odebug << "Opening " << dspstr << "" << oendl; |
153 | if (( sd = ::open( dspstr, flags)) == -1) { | 153 | if (( sd = ::open( dspstr, flags)) == -1) { |
154 | perror("open(\"/dev/dsp\")"); | 154 | perror("open(\"/dev/dsp\")"); |
155 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 155 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
156 | +(QString)strerror(errno); | 156 | +(QString)strerror(errno); |
157 | odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; | 157 | odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; |
158 | return -1; | 158 | return -1; |
159 | } | 159 | } |
160 | 160 | ||
161 | odebug << "Opening mixer" << oendl; | 161 | odebug << "Opening mixer" << oendl; |
162 | int mixerHandle=0; | 162 | int mixerHandle=0; |
163 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { | 163 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { |
164 | perror("open(\"/dev/mixer\")"); | 164 | perror("open(\"/dev/mixer\")"); |
165 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 165 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
166 | +(QString)strerror(errno); | 166 | +(QString)strerror(errno); |
167 | odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; | 167 | odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; |
168 | } | 168 | } |
169 | 169 | ||
170 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | 170 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ |
@@ -180,7 +180,7 @@ odebug << "Opening mixer" << oendl; | |||
180 | /* close(pipefd[0]); | 180 | /* close(pipefd[0]); |
181 | write(pipefd[1], message, sizeof(message)); | 181 | write(pipefd[1], message, sizeof(message)); |
182 | close(pipefd[1]); | 182 | close(pipefd[1]); |
183 | // odebug << "" << soundDevice->sd << "" << oendl; | 183 | // odebug << "" << soundDevice->sd << "" << oendl; |
184 | _exit(0); | 184 | _exit(0); |
185 | } | 185 | } |
186 | default: | 186 | default: |
@@ -206,13 +206,13 @@ odebug << "Opening mixer" << oendl; | |||
206 | */ | 206 | */ |
207 | // bool ok; | 207 | // bool ok; |
208 | // sd = s.toInt(&ok, 10); | 208 | // sd = s.toInt(&ok, 10); |
209 | // odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl; | 209 | // odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl; |
210 | 210 | ||
211 | // f2.close(); | 211 | // f2.close(); |
212 | // } | 212 | // } |
213 | ::close(mixerHandle ); | 213 | ::close(mixerHandle ); |
214 | // odebug << "open device " << dspstr << "" << oendl; | 214 | // odebug << "open device " << dspstr << "" << oendl; |
215 | // odebug << "success! " << sd << "" << oendl; | 215 | // odebug << "success! " << sd << "" << oendl; |
216 | return sd; | 216 | return sd; |
217 | } | 217 | } |
218 | 218 | ||
@@ -230,12 +230,12 @@ bool Device::closeDevice( bool) { | |||
230 | ::close( sd); //close sound device | 230 | ::close( sd); //close sound device |
231 | // sdfd=0; | 231 | // sdfd=0; |
232 | // sd=0; | 232 | // sd=0; |
233 | // odebug << "closed dsp" << oendl; | 233 | // odebug << "closed dsp" << oendl; |
234 | return true; | 234 | return true; |
235 | } | 235 | } |
236 | 236 | ||
237 | bool Device::setDeviceFormat( int form) { | 237 | bool Device::setDeviceFormat( int form) { |
238 | odebug << "set device res " << form << " " << sd << "" << oendl; | 238 | odebug << "set device res " << form << " " << sd << "" << oendl; |
239 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format | 239 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format |
240 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 240 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
241 | return false; | 241 | return false; |
@@ -245,7 +245,7 @@ bool Device::setDeviceFormat( int form) { | |||
245 | } | 245 | } |
246 | 246 | ||
247 | bool Device::setDeviceChannels( int ch) { | 247 | bool Device::setDeviceChannels( int ch) { |
248 | odebug << "set channels " << ch << " " << sd << "" << oendl; | 248 | odebug << "set channels " << ch << " " << sd << "" << oendl; |
249 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { | 249 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { |
250 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 250 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
251 | return false; | 251 | return false; |
@@ -255,7 +255,7 @@ bool Device::setDeviceChannels( int ch) { | |||
255 | } | 255 | } |
256 | 256 | ||
257 | bool Device::setDeviceRate( int rate) { | 257 | bool Device::setDeviceRate( int rate) { |
258 | odebug << "set rate " << rate << " " << sd << "" << oendl; | 258 | odebug << "set rate " << rate << " " << sd << "" << oendl; |
259 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { | 259 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { |
260 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 260 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
261 | return false; | 261 | return false; |
@@ -316,11 +316,11 @@ int Device::getDeviceChannels() { | |||
316 | 316 | ||
317 | int Device::getDeviceFragSize() { | 317 | int Device::getDeviceFragSize() { |
318 | int frag_size; | 318 | int frag_size; |
319 | 319 | ||
320 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { | 320 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { |
321 | odebug << "no fragsize" << oendl; | 321 | odebug << "no fragsize" << oendl; |
322 | } else { | 322 | } else { |
323 | odebug << "driver says frag size is " << frag_size << "" << oendl; | 323 | odebug << "driver says frag size is " << frag_size << "" << oendl; |
324 | } | 324 | } |
325 | return frag_size; | 325 | return frag_size; |
326 | } | 326 | } |
@@ -345,13 +345,13 @@ bool Device::reset() { | |||
345 | 345 | ||
346 | int Device::devRead(int soundDescriptor, short *buf, int size) { | 346 | int Device::devRead(int soundDescriptor, short *buf, int size) { |
347 | int number = 0; | 347 | int number = 0; |
348 | number = ::read( soundDescriptor, (char *)buf, size); | 348 | number = ::read( sd /*soundDescriptor*/, (char *)buf, size); |
349 | return number; | 349 | return number; |
350 | } | 350 | } |
351 | 351 | ||
352 | int Device::devWrite(int soundDescriptor, short * buf, int size) { | 352 | int Device::devWrite(int soundDescriptor, short * buf, int size) { |
353 | int bytesWritten = 0; | 353 | int bytesWritten = 0; |
354 | bytesWritten = ::write( soundDescriptor, buf, size); | 354 | bytesWritten = ::write( sd /*soundDescriptor*/, buf, size); |
355 | return bytesWritten; | 355 | return bytesWritten; |
356 | } | 356 | } |
357 | 357 | ||