author | schurig <schurig> | 2004-09-10 12:34:40 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 12:34:40 (UTC) |
commit | 85928a3781d9a91b58ea414c0d7982459cc21920 (patch) (unidiff) | |
tree | 10aeedf3a79fe2372c55bda730b6913b5562231b | |
parent | 9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (diff) | |
download | opie-85928a3781d9a91b58ea414c0d7982459cc21920.zip opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.gz opie-85928a3781d9a91b58ea414c0d7982459cc21920.tar.bz2 |
support for DEVFS
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 7 |
3 files changed, 27 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 7b4bfd9..e6afbd8 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -236,97 +236,101 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
237 | 237 | ||
238 | QFont f; | 238 | QFont f; |
239 | f.setPixelSize( 20 ); | 239 | f.setPixelSize( 20 ); |
240 | f.setBold( TRUE ); | 240 | f.setBold( TRUE ); |
241 | p.setFont( f ); | 241 | p.setFont( f ); |
242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
243 | 243 | ||
244 | for ( unsigned int i = 0; i < 10; i++ ) { | 244 | for ( unsigned int i = 0; i < 10; i++ ) { |
245 | if ( v > i ) { | 245 | if ( v > i ) { |
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
247 | } else { | 247 | } else { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } else { | 251 | } else { |
252 | w = videoUI()->width(); | 252 | w = videoUI()->width(); |
253 | h = videoUI()->height(); | 253 | h = videoUI()->height(); |
254 | 254 | ||
255 | if ( drawnOnScreenDisplay ) { | 255 | if ( drawnOnScreenDisplay ) { |
256 | if ( onScreenDisplayVolume > v ) { | 256 | if ( onScreenDisplayVolume > v ) { |
257 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 257 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | drawnOnScreenDisplay = TRUE; | 260 | drawnOnScreenDisplay = TRUE; |
261 | onScreenDisplayVolume = v; | 261 | onScreenDisplayVolume = v; |
262 | QPainter p( videoUI() ); | 262 | QPainter p( videoUI() ); |
263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
265 | 265 | ||
266 | QFont f; | 266 | QFont f; |
267 | f.setPixelSize( 20 ); | 267 | f.setPixelSize( 20 ); |
268 | f.setBold( TRUE ); | 268 | f.setBold( TRUE ); |
269 | p.setFont( f ); | 269 | p.setFont( f ); |
270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
271 | 271 | ||
272 | for ( unsigned int i = 0; i < 10; i++ ) { | 272 | for ( unsigned int i = 0; i < 10; i++ ) { |
273 | if ( v > i ) { | 273 | if ( v > i ) { |
274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
275 | } else { | 275 | } else { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void MediaPlayer::blank( bool b ) { | 283 | void MediaPlayer::blank( bool b ) { |
284 | #ifdef QT_QWS_DEVFS | ||
285 | fd=open("/dev/fb/0",O_RDWR); | ||
286 | #else | ||
284 | fd=open("/dev/fb0",O_RDWR); | 287 | fd=open("/dev/fb0",O_RDWR); |
288 | #endif | ||
285 | #ifdef QT_QWS_SL5XXX | 289 | #ifdef QT_QWS_SL5XXX |
286 | fl= open( "/dev/fl", O_RDWR ); | 290 | fl= open( "/dev/fl", O_RDWR ); |
287 | #endif | 291 | #endif |
288 | if (fd != -1) { | 292 | if (fd != -1) { |
289 | if ( b ) { | 293 | if ( b ) { |
290 | odebug << "do blanking" << oendl; | 294 | odebug << "do blanking" << oendl; |
291 | #ifdef QT_QWS_SL5XXX | 295 | #ifdef QT_QWS_SL5XXX |
292 | ioctl( fd, FBIOBLANK, 1 ); | 296 | ioctl( fd, FBIOBLANK, 1 ); |
293 | if(fl !=-1) { | 297 | if(fl !=-1) { |
294 | ioctl( fl, 2 ); | 298 | ioctl( fl, 2 ); |
295 | ::close(fl); | 299 | ::close(fl); |
296 | } | 300 | } |
297 | #else | 301 | #else |
298 | ioctl( fd, FBIOBLANK, 3 ); | 302 | ioctl( fd, FBIOBLANK, 3 ); |
299 | #endif | 303 | #endif |
300 | isBlanked = TRUE; | 304 | isBlanked = TRUE; |
301 | } else { | 305 | } else { |
302 | odebug << "do unblanking" << oendl; | 306 | odebug << "do unblanking" << oendl; |
303 | ioctl( fd, FBIOBLANK, 0); | 307 | ioctl( fd, FBIOBLANK, 0); |
304 | #ifdef QT_QWS_SL5XXX | 308 | #ifdef QT_QWS_SL5XXX |
305 | if(fl != -1) { | 309 | if(fl != -1) { |
306 | ioctl( fl, 1); | 310 | ioctl( fl, 1); |
307 | ::close(fl); | 311 | ::close(fl); |
308 | } | 312 | } |
309 | #endif | 313 | #endif |
310 | isBlanked = FALSE; | 314 | isBlanked = FALSE; |
311 | } | 315 | } |
312 | close( fd ); | 316 | close( fd ); |
313 | } else { | 317 | } else { |
314 | odebug << "<< /dev/fb0 could not be opened >>" << oendl; | 318 | odebug << "<< /dev/fb0 could not be opened >>" << oendl; |
315 | } | 319 | } |
316 | } | 320 | } |
317 | 321 | ||
318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 322 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
319 | switch ( e->key() ) { | 323 | switch ( e->key() ) { |
320 | ////////////////////////////// Zaurus keys | 324 | ////////////////////////////// Zaurus keys |
321 | case Key_Home: | 325 | case Key_Home: |
322 | break; | 326 | break; |
323 | case Key_F9: //activity | 327 | case Key_F9: //activity |
324 | break; | 328 | break; |
325 | case Key_F10: //contacts | 329 | case Key_F10: //contacts |
326 | break; | 330 | break; |
327 | case Key_F11: //menu | 331 | case Key_F11: //menu |
328 | break; | 332 | break; |
329 | case Key_F12: //home | 333 | case Key_F12: //home |
330 | odebug << "Blank here" << oendl; | 334 | odebug << "Blank here" << oendl; |
331 | // mediaPlayerState->toggleBlank(); | 335 | // mediaPlayerState->toggleBlank(); |
332 | break; | 336 | break; |
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index 683f0a5..cb47b77 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -30,222 +30,238 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco | |||
30 | 30 | ||
31 | if( !record){ //playing | 31 | if( !record){ //playing |
32 | qDebug( "setting up DSP for playing" ); | 32 | qDebug( "setting up DSP for playing" ); |
33 | flags = O_WRONLY; | 33 | flags = O_WRONLY; |
34 | } else { //recording | 34 | } else { //recording |
35 | qDebug( "setting up DSP for recording" ); | 35 | qDebug( "setting up DSP for recording" ); |
36 | flags = O_RDWR; | 36 | flags = O_RDWR; |
37 | // flags = O_RDONLY; | 37 | // flags = O_RDONLY; |
38 | 38 | ||
39 | // selectMicInput(); | 39 | // selectMicInput(); |
40 | 40 | ||
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
44 | bool Device::openDsp() { | 44 | bool Device::openDsp() { |
45 | if( openDevice( flags) == -1) { | 45 | if( openDevice( flags) == -1) { |
46 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); | 46 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); |
47 | return false; | 47 | return false; |
48 | } | 48 | } |
49 | return true; | 49 | return true; |
50 | } | 50 | } |
51 | 51 | ||
52 | int Device::openDevice( int flags) { | 52 | int Device::openDevice( int flags) { |
53 | /* pid_t pid; | 53 | /* pid_t pid; |
54 | int status; | 54 | int status; |
55 | int pipefd[2]; | 55 | int pipefd[2]; |
56 | char message[20]; | 56 | char message[20]; |
57 | if (pipe(pipefd) == -1){ | 57 | if (pipe(pipefd) == -1){ |
58 | perror ("Error creating pipe"); | 58 | perror ("Error creating pipe"); |
59 | exit(1); | 59 | exit(1); |
60 | } | 60 | } |
61 | switch (pid = fork()) { | 61 | switch (pid = fork()) { |
62 | case -1: | 62 | case -1: |
63 | perror("The fork failed!"); | 63 | perror("The fork failed!"); |
64 | break; | 64 | break; |
65 | case 0: { | 65 | case 0: { |
66 | */ | 66 | */ |
67 | qDebug( "Opening %s",dspstr); | 67 | qDebug( "Opening %s",dspstr); |
68 | if (( sd = ::open( dspstr, flags)) == -1) { | 68 | if (( sd = ::open( dspstr, flags)) == -1) { |
69 | perror("open(\"/dev/dsp\")"); | 69 | perror("open(\"/dev/dsp\")"); |
70 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 70 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
71 | +(QString)strerror(errno); | 71 | +(QString)strerror(errno); |
72 | qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); | 72 | qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); |
73 | return -1; | 73 | return -1; |
74 | } | 74 | } |
75 | 75 | ||
76 | qDebug( "Opening mixer" ); | 76 | qDebug( "Opening mixer" ); |
77 | int mixerHandle=0; | 77 | int mixerHandle=0; |
78 | #ifdef QT_QWS_DEVFS | ||
79 | if (( mixerHandle = open("/dev/sound/mixer",O_RDWR))<0) { | ||
80 | #else | ||
78 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { | 81 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { |
82 | #endif | ||
79 | perror("open(\"/dev/mixer\")"); | 83 | perror("open(\"/dev/mixer\")"); |
80 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 84 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
81 | +(QString)strerror(errno); | 85 | +(QString)strerror(errno); |
82 | qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); | 86 | qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); |
83 | } | 87 | } |
84 | 88 | ||
85 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | 89 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ |
86 | perror("ioctl RESET"); | 90 | perror("ioctl RESET"); |
87 | } | 91 | } |
88 | // sprintf(message, "%d", sd); | 92 | // sprintf(message, "%d", sd); |
89 | 93 | ||
90 | /* QFile f1("/pid"); | 94 | /* QFile f1("/pid"); |
91 | f1.open(IO_WriteOnly ); | 95 | f1.open(IO_WriteOnly ); |
92 | f1.writeBlock(message, strlen(message)); | 96 | f1.writeBlock(message, strlen(message)); |
93 | f1.close(); | 97 | f1.close(); |
94 | */ | 98 | */ |
95 | /* close(pipefd[0]); | 99 | /* close(pipefd[0]); |
96 | write(pipefd[1], message, sizeof(message)); | 100 | write(pipefd[1], message, sizeof(message)); |
97 | close(pipefd[1]); | 101 | close(pipefd[1]); |
98 | // qDebug( "" + soundDevice->sd ); | 102 | // qDebug( "" + soundDevice->sd ); |
99 | _exit(0); | 103 | _exit(0); |
100 | } | 104 | } |
101 | default: | 105 | default: |
102 | // pid greater than zero is parent getting the child's pid | 106 | // pid greater than zero is parent getting the child's pid |
103 | printf("Child's pid is %d\n",pid); | 107 | printf("Child's pid is %d\n",pid); |
104 | QString s; | 108 | QString s; |
105 | close(pipefd[1]); | 109 | close(pipefd[1]); |
106 | read(pipefd[0], message, sizeof(message)); | 110 | read(pipefd[0], message, sizeof(message)); |
107 | s = message; | 111 | s = message; |
108 | close(pipefd[0]); | 112 | close(pipefd[0]); |
109 | 113 | ||
110 | // while(wait(NULL)!=pid) | 114 | // while(wait(NULL)!=pid) |
111 | // ; | 115 | // ; |
112 | printf("child %ld terminated normally, return status is zero\n", (long) pid); | 116 | printf("child %ld terminated normally, return status is zero\n", (long) pid); |
113 | */ | 117 | */ |
114 | // filePara.sd=(long) pid; | 118 | // filePara.sd=(long) pid; |
115 | /* QFile f2("/pid"); | 119 | /* QFile f2("/pid"); |
116 | f2.open(IO_ReadOnly); | 120 | f2.open(IO_ReadOnly); |
117 | QTextStream t(&f2); | 121 | QTextStream t(&f2); |
118 | // for(int f=0; f < t.atEnd() ;f++) { | 122 | // for(int f=0; f < t.atEnd() ;f++) { |
119 | s = t.readLine(); | 123 | s = t.readLine(); |
120 | // } | 124 | // } |
121 | */ | 125 | */ |
122 | // bool ok; | 126 | // bool ok; |
123 | // sd = s.toInt(&ok, 10); | 127 | // sd = s.toInt(&ok, 10); |
124 | // qDebug( "<<<<<<<<<<<<<>>>>>>>>>>>>"+s ); | 128 | // qDebug( "<<<<<<<<<<<<<>>>>>>>>>>>>"+s ); |
125 | 129 | ||
126 | // f2.close(); | 130 | // f2.close(); |
127 | // } | 131 | // } |
128 | ::close(mixerHandle ); | 132 | ::close(mixerHandle ); |
129 | // qDebug( "open device " + dspstr ); | 133 | // qDebug( "open device " + dspstr ); |
130 | // qDebug( "success! " + sd ); | 134 | // qDebug( "success! " + sd ); |
131 | return sd; | 135 | return sd; |
132 | } | 136 | } |
133 | 137 | ||
134 | 138 | ||
135 | int Device::getOutVolume( ) { | 139 | int Device::getOutVolume( ) { |
136 | unsigned int volume; | 140 | unsigned int volume; |
137 | int mixerHandle = open( mixstr, O_RDWR ); | 141 | int mixerHandle = open( mixstr, O_RDWR ); |
138 | if ( mixerHandle >= 0 ) { | 142 | if ( mixerHandle >= 0 ) { |
139 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) | 143 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) |
140 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 144 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
141 | ::close( mixerHandle ); | 145 | ::close( mixerHandle ); |
142 | } else | 146 | } else |
143 | perror("open(\"/dev/mixer\")"); | 147 | perror("open(\"/dev/mixer\")"); |
144 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); | 148 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); |
145 | 149 | ||
146 | Config cfg("qpe"); | 150 | Config cfg("qpe"); |
147 | cfg.setGroup("Volume"); | 151 | cfg.setGroup("Volume"); |
148 | 152 | ||
149 | return cfg.readNumEntry("VolumePercent"); | 153 | return cfg.readNumEntry("VolumePercent"); |
150 | } | 154 | } |
151 | 155 | ||
152 | int Device::getInVolume() { | 156 | int Device::getInVolume() { |
153 | unsigned int volume=0; | 157 | unsigned int volume=0; |
154 | int mixerHandle = ::open( mixstr, O_RDWR ); | 158 | int mixerHandle = ::open( mixstr, O_RDWR ); |
155 | if ( mixerHandle >= 0 ) { | 159 | if ( mixerHandle >= 0 ) { |
156 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) | 160 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) |
157 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 161 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
158 | ::close( mixerHandle ); | 162 | ::close( mixerHandle ); |
159 | } else | 163 | } else |
160 | perror("open(\"/dev/mixer\")"); | 164 | perror("open(\"/dev/mixer\")"); |
161 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); | 165 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); |
162 | Config cfg("qpe"); | 166 | Config cfg("qpe"); |
163 | cfg.setGroup("Volume"); | 167 | cfg.setGroup("Volume"); |
164 | 168 | ||
165 | return cfg.readNumEntry("Mic"); | 169 | return cfg.readNumEntry("Mic"); |
166 | } | 170 | } |
167 | 171 | ||
168 | void Device::changedOutVolume(int vol) { | 172 | void Device::changedOutVolume(int vol) { |
169 | int level = (vol << 8) + vol; | 173 | int level = (vol << 8) + vol; |
170 | int fd = 0; | 174 | int fd = 0; |
175 | #ifdef QT_QWS_DEVFS | ||
176 | if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) { | ||
177 | #else | ||
171 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 178 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
179 | #endif | ||
172 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) | 180 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) |
173 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 181 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
174 | 182 | ||
175 | Config cfg("qpe"); | 183 | Config cfg("qpe"); |
176 | cfg.setGroup("Volume"); | 184 | cfg.setGroup("Volume"); |
177 | cfg.writeEntry("VolumePercent", QString::number( vol )); | 185 | cfg.writeEntry("VolumePercent", QString::number( vol )); |
178 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 186 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
179 | qDebug("changing output vol %d" ,vol ); | 187 | qDebug("changing output vol %d" ,vol ); |
180 | } | 188 | } |
181 | ::close(fd); | 189 | ::close(fd); |
182 | } | 190 | } |
183 | 191 | ||
184 | void Device::changedInVolume(int vol ) { | 192 | void Device::changedInVolume(int vol ) { |
185 | int level = (vol << 8) + vol; | 193 | int level = (vol << 8) + vol; |
186 | int fd = 0; | 194 | int fd = 0; |
195 | #ifdef QT_QWS_DEVFS | ||
196 | if ((fd = open("/dev/sound/mixer", O_RDWR))>=0) { | ||
197 | #else | ||
187 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 198 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
199 | #endif | ||
188 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) | 200 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) |
189 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 201 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
190 | Config cfg("qpe"); | 202 | Config cfg("qpe"); |
191 | cfg.setGroup("Volume"); | 203 | cfg.setGroup("Volume"); |
192 | cfg.writeEntry("Mic", QString::number(vol )); | 204 | cfg.writeEntry("Mic", QString::number(vol )); |
193 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; | 205 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; |
194 | qDebug("changing input volume %d",vol); | 206 | qDebug("changing input volume %d",vol); |
195 | } | 207 | } |
196 | ::close(fd); | 208 | ::close(fd); |
197 | } | 209 | } |
198 | 210 | ||
199 | bool Device::selectMicInput() { | 211 | bool Device::selectMicInput() { |
200 | 212 | ||
201 | int md=0; | 213 | int md=0; |
202 | int info=MIXER_WRITE(SOUND_MIXER_MIC); | 214 | int info=MIXER_WRITE(SOUND_MIXER_MIC); |
215 | #ifdef QT_QWS_DEVFS | ||
216 | md = ::open( "/dev/sound/mixer", O_RDWR ); | ||
217 | #else | ||
203 | md = ::open( "/dev/mixer", O_RDWR ); | 218 | md = ::open( "/dev/mixer", O_RDWR ); |
219 | #endif | ||
204 | if ( md == -1) | 220 | if ( md == -1) |
205 | perror("open(\"/dev/mixer\")"); | 221 | perror("open(\"/dev/mixer\")"); |
206 | else { | 222 | else { |
207 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) | 223 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) |
208 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); | 224 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); |
209 | ::close(md); | 225 | ::close(md); |
210 | return false; | 226 | return false; |
211 | } | 227 | } |
212 | ::close(md); | 228 | ::close(md); |
213 | 229 | ||
214 | return true; | 230 | return true; |
215 | } | 231 | } |
216 | 232 | ||
217 | bool Device::closeDevice( bool) { | 233 | bool Device::closeDevice( bool) { |
218 | // if(b) {//close now | 234 | // if(b) {//close now |
219 | // if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { | 235 | // if (ioctl( sd, SNDCTL_DSP_RESET, 0) == -1) { |
220 | // perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 236 | // perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
221 | // } | 237 | // } |
222 | // } else { //let play | 238 | // } else { //let play |
223 | // if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { | 239 | // if (ioctl( sd, SNDCTL_DSP_SYNC, 0) == -1) { |
224 | // perror("ioctl(\"SNDCTL_DSP_SYNC\")"); | 240 | // perror("ioctl(\"SNDCTL_DSP_SYNC\")"); |
225 | // } | 241 | // } |
226 | // } | 242 | // } |
227 | 243 | ||
228 | ::close( sd); //close sound device | 244 | ::close( sd); //close sound device |
229 | // sdfd=0; | 245 | // sdfd=0; |
230 | // sd=0; | 246 | // sd=0; |
231 | // qDebug( "closed dsp" ); | 247 | // qDebug( "closed dsp" ); |
232 | return true; | 248 | return true; |
233 | } | 249 | } |
234 | 250 | ||
235 | bool Device::setDeviceFormat( int form) { | 251 | bool Device::setDeviceFormat( int form) { |
236 | qDebug( "set device res %d: %d ",form, sd ); | 252 | qDebug( "set device res %d: %d ",form, sd ); |
237 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format | 253 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format |
238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 254 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
239 | return false; | 255 | return false; |
240 | } | 256 | } |
241 | devRes=form; | 257 | devRes=form; |
242 | return true; | 258 | return true; |
243 | } | 259 | } |
244 | 260 | ||
245 | bool Device::setDeviceChannels( int ch) { | 261 | bool Device::setDeviceChannels( int ch) { |
246 | qDebug( "set channels %d: %d",ch ,sd); | 262 | qDebug( "set channels %d: %d",ch ,sd); |
247 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { | 263 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { |
248 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 264 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
249 | return false; | 265 | return false; |
250 | } | 266 | } |
251 | devCh=ch; | 267 | devCh=ch; |
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 1141faa..c237726 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -34,100 +34,107 @@ using namespace Opie::Core; | |||
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | /* STD */ | 39 | /* STD */ |
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <fcntl.h> | 41 | #include <fcntl.h> |
42 | #include <math.h> | 42 | #include <math.h> |
43 | #include <mntent.h> | 43 | #include <mntent.h> |
44 | #include <stdio.h> | 44 | #include <stdio.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
47 | #include <sys/soundcard.h> | 47 | #include <sys/soundcard.h> |
48 | #include <sys/stat.h> | 48 | #include <sys/stat.h> |
49 | #include <sys/time.h> | 49 | #include <sys/time.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/vfs.h> | 51 | #include <sys/vfs.h> |
52 | #include <unistd.h> | 52 | #include <unistd.h> |
53 | #include <sys/wait.h> | 53 | #include <sys/wait.h> |
54 | #include <sys/signal.h> | 54 | #include <sys/signal.h> |
55 | #include <pthread.h> | 55 | #include <pthread.h> |
56 | 56 | ||
57 | #ifdef PDAUDIO //ALSA | 57 | #ifdef PDAUDIO //ALSA |
58 | #include <alsa/asoundlib.h> | 58 | #include <alsa/asoundlib.h> |
59 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; | 59 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; |
60 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; | 60 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; |
61 | #else //OSS | 61 | #else //OSS |
62 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; | 62 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; |
63 | static int deviceBitRates[] = { 8, 16, -1 }; | 63 | static int deviceBitRates[] = { 8, 16, -1 }; |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #if defined(QT_QWS_SL5XXX) | 66 | #if defined(QT_QWS_SL5XXX) |
67 | ///#if defined(QT_QWS_EBX) | 67 | ///#if defined(QT_QWS_EBX) |
68 | 68 | ||
69 | #define DSPSTROUT "/dev/dsp" | 69 | #define DSPSTROUT "/dev/dsp" |
70 | #define DSPSTRMIXEROUT "/dev/mixer" | 70 | #define DSPSTRMIXEROUT "/dev/mixer" |
71 | 71 | ||
72 | #ifdef SHARP | 72 | #ifdef SHARP |
73 | #define DSPSTRIN "/dev/dsp1" | 73 | #define DSPSTRIN "/dev/dsp1" |
74 | #define DSPSTRMIXERIN "/dev/mixer1" | 74 | #define DSPSTRMIXERIN "/dev/mixer1" |
75 | #else | 75 | #else |
76 | #define DSPSTRIN "/dev/dsp" | 76 | #define DSPSTRIN "/dev/dsp" |
77 | #define DSPSTRMIXERIN "/dev/mixer" | 77 | #define DSPSTRMIXERIN "/dev/mixer" |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | #else | 80 | #else |
81 | 81 | ||
82 | #ifdef QT_QWS_DEVFS | ||
83 | #define DSPSTROUT "/dev/sound/dsp" | ||
84 | #define DSPSTRIN "/dev/sound/dsp" | ||
85 | #define DSPSTRMIXERIN "/dev/sound/mixer" | ||
86 | #define DSPSTRMIXEROUT "/dev/sound/mixer" | ||
87 | #else | ||
82 | #define DSPSTROUT "/dev/dsp" | 88 | #define DSPSTROUT "/dev/dsp" |
83 | #define DSPSTRIN "/dev/dsp" | 89 | #define DSPSTRIN "/dev/dsp" |
84 | #define DSPSTRMIXERIN "/dev/mixer" | 90 | #define DSPSTRMIXERIN "/dev/mixer" |
85 | #define DSPSTRMIXEROUT "/dev/mixer" | 91 | #define DSPSTRMIXEROUT "/dev/mixer" |
92 | #endif | ||
86 | 93 | ||
87 | #endif | 94 | #endif |
88 | 95 | ||
89 | //#define ZAURUS 0 | 96 | //#define ZAURUS 0 |
90 | struct adpcm_state encoder_state; | 97 | struct adpcm_state encoder_state; |
91 | struct adpcm_state decoder_state; | 98 | struct adpcm_state decoder_state; |
92 | 99 | ||
93 | typedef struct { | 100 | typedef struct { |
94 | int sampleRate; | 101 | int sampleRate; |
95 | /* int fragSize; */ | 102 | /* int fragSize; */ |
96 | /* int blockSize; */ | 103 | /* int blockSize; */ |
97 | int resolution; //bitrate | 104 | int resolution; //bitrate |
98 | int channels; //number of channels | 105 | int channels; //number of channels |
99 | int fd; //file descriptor | 106 | int fd; //file descriptor |
100 | int sd; //sound device descriptor | 107 | int sd; //sound device descriptor |
101 | int numberSamples; //total number of samples | 108 | int numberSamples; //total number of samples |
102 | int SecondsToRecord; // number of seconds that should be recorded | 109 | int SecondsToRecord; // number of seconds that should be recorded |
103 | float numberOfRecordedSeconds; //total number of samples recorded | 110 | float numberOfRecordedSeconds; //total number of samples recorded |
104 | int samplesToRecord; //number of samples to be recorded | 111 | int samplesToRecord; //number of samples to be recorded |
105 | int inVol; //input volume | 112 | int inVol; //input volume |
106 | int outVol; //output volume | 113 | int outVol; //output volume |
107 | int format; //wavfile format PCM.. ADPCM | 114 | int format; //wavfile format PCM.. ADPCM |
108 | const char *fileName; //name of fiel to be played/recorded | 115 | const char *fileName; //name of fiel to be played/recorded |
109 | } fileParameters; | 116 | } fileParameters; |
110 | 117 | ||
111 | fileParameters filePara; | 118 | fileParameters filePara; |
112 | 119 | ||
113 | bool monitoring, recording, playing; | 120 | bool monitoring, recording, playing; |
114 | bool stopped; | 121 | bool stopped; |
115 | QLabel *timeLabel; | 122 | QLabel *timeLabel; |
116 | QSlider *timeSlider; | 123 | QSlider *timeSlider; |
117 | int sd; | 124 | int sd; |
118 | 125 | ||
119 | Waveform* waveform; | 126 | Waveform* waveform; |
120 | Device *soundDevice; | 127 | Device *soundDevice; |
121 | 128 | ||
122 | 129 | ||
123 | #ifdef THREADED | 130 | #ifdef THREADED |
124 | void quickRec() | 131 | void quickRec() |
125 | #else | 132 | #else |
126 | void QtRec::quickRec() | 133 | void QtRec::quickRec() |
127 | #endif | 134 | #endif |
128 | { | 135 | { |
129 | 136 | ||
130 | odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; | 137 | odebug << ( filePara.numberSamples/filePara.sampleRate * filePara.channels ) << oendl; |
131 | odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate | 138 | odebug << "samples " << filePara.numberSamples << ", rate " << filePara.sampleRate |
132 | << ", channels " << filePara.channels << oendl; | 139 | << ", channels " << filePara.channels << oendl; |
133 | 140 | ||