author | llornkcor <llornkcor> | 2003-12-25 21:52:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-12-25 21:52:44 (UTC) |
commit | f2805565b0d7edd2e72445f6d56e43eadcdac72d (patch) (unidiff) | |
tree | b9a74aec0c5616ae1976198c1f83945b697ed3d2 /noncore/multimedia/opierec/device.cpp | |
parent | 34a7e0451c95e8a19735610553dba064b68823d9 (diff) | |
download | opie-f2805565b0d7edd2e72445f6d56e43eadcdac72d.zip opie-f2805565b0d7edd2e72445f6d56e43eadcdac72d.tar.gz opie-f2805565b0d7edd2e72445f6d56e43eadcdac72d.tar.bz2 |
uhhh.. helps to commit to correct branch
Diffstat (limited to 'noncore/multimedia/opierec/device.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 51 |
1 files changed, 37 insertions, 14 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 | |||
@@ -4,7 +4,7 @@ | |||
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> |
@@ -38,7 +38,9 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco | |||
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 | ||
@@ -94,6 +96,7 @@ void Device::changedOutVolume(int vol) { | |||
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 | } |
@@ -108,12 +111,13 @@ void Device::changedInVolume(int vol ) { | |||
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 ); |
@@ -126,7 +130,7 @@ bool Device::selectMicInput() { | |||
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 | ||
@@ -145,18 +149,22 @@ exit(1); | |||
145 | break; | 149 | break; |
146 | case 0: { | 150 | case 0: { |
147 | */ | 151 | */ |
152 | qDebug("Opening %s",dspstr); | ||
148 | if (( sd = ::open( dspstr, flags)) == -1) { | 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){ |
@@ -203,12 +211,12 @@ exit(1); | |||
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\")"); |
@@ -222,7 +230,7 @@ bool Device::closeDevice( bool b) { | |||
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 | ||
@@ -290,7 +298,7 @@ int Device::getDeviceRate() { | |||
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 | } |
@@ -311,8 +319,9 @@ int Device::getDeviceFragSize() { | |||
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 | ||
@@ -333,3 +342,17 @@ bool Device::reset() { | |||
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 | |||