-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 | |||
@@ -188,193 +188,197 @@ void MediaPlayer::stopChangingVolume() { | |||
188 | drawnOnScreenDisplay = FALSE; | 188 | drawnOnScreenDisplay = FALSE; |
189 | onScreenDisplayVolume = 0; | 189 | onScreenDisplayVolume = 0; |
190 | int w=0; | 190 | int w=0; |
191 | int h=0; | 191 | int h=0; |
192 | if( !xineControl()->hasVideo() ) { | 192 | if( !xineControl()->hasVideo() ) { |
193 | w = audioUI()->width(); | 193 | w = audioUI()->width(); |
194 | h = audioUI()->height(); | 194 | h = audioUI()->height(); |
195 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 195 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
196 | } else { | 196 | } else { |
197 | w = videoUI()->width(); | 197 | w = videoUI()->width(); |
198 | h = videoUI()->height(); | 198 | h = videoUI()->height(); |
199 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 199 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 204 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
205 | if ( volumeDirection == +1 ) { | 205 | if ( volumeDirection == +1 ) { |
206 | volControl->incVol( 2 ); | 206 | volControl->incVol( 2 ); |
207 | } else if ( volumeDirection == -1 ) { | 207 | } else if ( volumeDirection == -1 ) { |
208 | volControl->decVol( 2 ); | 208 | volControl->decVol( 2 ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | // TODO FIXME | 212 | // TODO FIXME |
213 | // huh?? | 213 | // huh?? |
214 | unsigned int v= 0; | 214 | unsigned int v= 0; |
215 | v = volControl->volume(); | 215 | v = volControl->volume(); |
216 | v = v / 10; | 216 | v = v / 10; |
217 | 217 | ||
218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
219 | return; | 219 | return; |
220 | } | 220 | } |
221 | 221 | ||
222 | int w=0; int h=0; | 222 | int w=0; int h=0; |
223 | if( !xineControl()->hasVideo() ) { | 223 | if( !xineControl()->hasVideo() ) { |
224 | w = audioUI()->width(); | 224 | w = audioUI()->width(); |
225 | h = audioUI()->height(); | 225 | h = audioUI()->height(); |
226 | 226 | ||
227 | if ( drawnOnScreenDisplay ) { | 227 | if ( drawnOnScreenDisplay ) { |
228 | if ( onScreenDisplayVolume > v ) { | 228 | if ( onScreenDisplayVolume > v ) { |
229 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 229 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | drawnOnScreenDisplay = TRUE; | 232 | drawnOnScreenDisplay = TRUE; |
233 | onScreenDisplayVolume = v; | 233 | onScreenDisplayVolume = v; |
234 | QPainter p( audioUI() ); | 234 | QPainter p( audioUI() ); |
235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
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; |
333 | case Key_F13: //mail | 337 | case Key_F13: //mail |
334 | odebug << "Blank here" << oendl; | 338 | odebug << "Blank here" << oendl; |
335 | // mediaPlayerState->toggleBlank(); | 339 | // mediaPlayerState->toggleBlank(); |
336 | break; | 340 | break; |
337 | } | 341 | } |
338 | } | 342 | } |
339 | 343 | ||
340 | void MediaPlayer::cleanUp() {// this happens on closing | 344 | void MediaPlayer::cleanUp() {// this happens on closing |
341 | Config cfg( "OpiePlayer" ); | 345 | Config cfg( "OpiePlayer" ); |
342 | mediaPlayerState.writeConfig( cfg ); | 346 | mediaPlayerState.writeConfig( cfg ); |
343 | playList.writeDefaultPlaylist( ); | 347 | playList.writeDefaultPlaylist( ); |
344 | 348 | ||
345 | // QPEApplication::grabKeyboard(); | 349 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 350 | // QPEApplication::ungrabKeyboard(); |
347 | } | 351 | } |
348 | 352 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() const | 353 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
350 | { | 354 | { |
351 | delete m_skinLoader; | 355 | delete m_skinLoader; |
352 | 356 | ||
353 | delete m_xineControl; | 357 | delete m_xineControl; |
354 | delete m_audioUI; | 358 | delete m_audioUI; |
355 | delete m_videoUI; | 359 | delete m_videoUI; |
356 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 360 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
357 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 361 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
358 | 362 | ||
359 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 363 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
360 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 364 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
361 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 365 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
362 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 366 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
363 | 367 | ||
364 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 368 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
365 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 369 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
366 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 370 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
367 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 371 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
368 | 372 | ||
369 | if ( !xine ) | 373 | if ( !xine ) |
370 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); | 374 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); |
371 | 375 | ||
372 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); | 376 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); |
373 | 377 | ||
374 | xine = 0; | 378 | xine = 0; |
375 | } | 379 | } |
376 | 380 | ||
377 | AudioWidget *MediaPlayer::audioUI() const | 381 | AudioWidget *MediaPlayer::audioUI() const |
378 | { | 382 | { |
379 | if ( !m_audioUI ) | 383 | if ( !m_audioUI ) |
380 | recreateAudioAndVideoWidgets(); | 384 | recreateAudioAndVideoWidgets(); |
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 | |||
@@ -1,299 +1,315 @@ | |||
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 | 7 | ||
8 | /* STD */ | 8 | /* STD */ |
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 <unistd.h> | 16 | #include <unistd.h> |
17 | #include <errno.h> | 17 | #include <errno.h> |
18 | 18 | ||
19 | //extern QtRec *qperec; | 19 | //extern QtRec *qperec; |
20 | 20 | ||
21 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) | 21 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) |
22 | : QObject( parent) | 22 | : QObject( parent) |
23 | { | 23 | { |
24 | dspstr = (char *)dsp; | 24 | dspstr = (char *)dsp; |
25 | mixstr = (char *)mixr; | 25 | mixstr = (char *)mixr; |
26 | 26 | ||
27 | devForm=-1; | 27 | devForm=-1; |
28 | devCh=-1; | 28 | devCh=-1; |
29 | devRate=-1; | 29 | devRate=-1; |
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; |
252 | return true; | 268 | return true; |
253 | } | 269 | } |
254 | 270 | ||
255 | bool Device::setDeviceRate( int rate) { | 271 | bool Device::setDeviceRate( int rate) { |
256 | qDebug( "set rate %d: %d",rate,sd); | 272 | qDebug( "set rate %d: %d",rate,sd); |
257 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { | 273 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { |
258 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 274 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
259 | return false; | 275 | return false; |
260 | } | 276 | } |
261 | 277 | ||
262 | devRate=rate; | 278 | devRate=rate; |
263 | 279 | ||
264 | return true; | 280 | return true; |
265 | } | 281 | } |
266 | 282 | ||
267 | int Device::getRes() { | 283 | int Device::getRes() { |
268 | return devRes; | 284 | return devRes; |
269 | } | 285 | } |
270 | 286 | ||
271 | int Device::getFormat() { | 287 | int Device::getFormat() { |
272 | return devForm; | 288 | return devForm; |
273 | } | 289 | } |
274 | 290 | ||
275 | int Device::getRate() { | 291 | int Device::getRate() { |
276 | return devRate; | 292 | return devRate; |
277 | } | 293 | } |
278 | 294 | ||
279 | int Device::getChannels() { | 295 | int Device::getChannels() { |
280 | return devCh; | 296 | return devCh; |
281 | } | 297 | } |
282 | 298 | ||
283 | int Device::getDeviceFormat() { | 299 | int Device::getDeviceFormat() { |
284 | return 0; | 300 | return 0; |
285 | } | 301 | } |
286 | 302 | ||
287 | 303 | ||
288 | int Device::getDeviceRate() { | 304 | int Device::getDeviceRate() { |
289 | int dRate=0; | 305 | int dRate=0; |
290 | if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) { | 306 | if (ioctl( sd, SOUND_PCM_READ_RATE, &dRate) == -1) { |
291 | perror("ioctl(\"SNDCTL_PCM_READ_RATE\")"); | 307 | perror("ioctl(\"SNDCTL_PCM_READ_RATE\")"); |
292 | } | 308 | } |
293 | return dRate; | 309 | return dRate; |
294 | 310 | ||
295 | } | 311 | } |
296 | 312 | ||
297 | int Device::getDeviceBits() { | 313 | int Device::getDeviceBits() { |
298 | int dBits=0; | 314 | int dBits=0; |
299 | #ifndef QT_QWS_EBX // zaurus doesnt have this | 315 | #ifndef QT_QWS_EBX // zaurus doesnt have this |
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 | |||
@@ -1,181 +1,188 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | // qtrec.cpp | 2 | // qtrec.cpp |
3 | Created: Thu Jan 17 11:19:58 2002 | 3 | Created: Thu Jan 17 11:19:58 2002 |
4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> | 4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #define DEV_VERSION | 6 | #define DEV_VERSION |
7 | 7 | ||
8 | #include "pixmaps.h" | 8 | #include "pixmaps.h" |
9 | #include "qtrec.h" | 9 | #include "qtrec.h" |
10 | #include "waveform.h" | 10 | #include "waveform.h" |
11 | extern "C" { | 11 | extern "C" { |
12 | #include "adpcm.h" | 12 | #include "adpcm.h" |
13 | } | 13 | } |
14 | 14 | ||
15 | /* OPIE */ | 15 | /* OPIE */ |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/storage.h> | 21 | #include <qpe/storage.h> |
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qgroupbox.h> | 28 | #include <qgroupbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
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 | ||
134 | int total = 0; // Total number of bytes read in so far. | 141 | int total = 0; // Total number of bytes read in so far. |
135 | int bytesWritten, number; | 142 | int bytesWritten, number; |
136 | 143 | ||
137 | bytesWritten = 0; | 144 | bytesWritten = 0; |
138 | number = 0; | 145 | number = 0; |
139 | QString num; | 146 | QString num; |
140 | int level = 0; | 147 | int level = 0; |
141 | int threshold = 0; | 148 | int threshold = 0; |
142 | int bits = filePara.resolution; | 149 | int bits = filePara.resolution; |
143 | odebug << "bits " << bits << "" << oendl; | 150 | odebug << "bits " << bits << "" << oendl; |
144 | 151 | ||
145 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 152 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
146 | odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; | 153 | odebug << "AFMT_S16_LE size " << filePara.SecondsToRecord << "" << oendl; |
147 | odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; | 154 | odebug << "samples to record " << filePara.samplesToRecord << "" << oendl; |
148 | odebug << "" << filePara.sd << "" << oendl; | 155 | odebug << "" << filePara.sd << "" << oendl; |
149 | level = 7; | 156 | level = 7; |
150 | threshold = 0; | 157 | threshold = 0; |
151 | 158 | ||
152 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 159 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
153 | odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; | 160 | odebug << "start recording WAVE_FORMAT_DVI_ADPCM" << oendl; |
154 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 161 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
155 | char abuf[ BUFSIZE/2 ]; | 162 | char abuf[ BUFSIZE/2 ]; |
156 | short sbuf[ BUFSIZE ]; | 163 | short sbuf[ BUFSIZE ]; |
157 | short sbuf2[ BUFSIZE ]; | 164 | short sbuf2[ BUFSIZE ]; |
158 | memset( abuf, 0, BUFSIZE/2); | 165 | memset( abuf, 0, BUFSIZE/2); |
159 | memset( sbuf, 0, BUFSIZE); | 166 | memset( sbuf, 0, BUFSIZE); |
160 | memset( sbuf2, 0, BUFSIZE); | 167 | memset( sbuf2, 0, BUFSIZE); |
161 | 168 | ||
162 | for(;;) { | 169 | for(;;) { |
163 | if ( stopped) { | 170 | if ( stopped) { |
164 | odebug << "quickRec:: stopped" << oendl; | 171 | odebug << "quickRec:: stopped" << oendl; |
165 | break; | 172 | break; |
166 | } | 173 | } |
167 | 174 | ||
168 | // number=::read( filePara.sd, sbuf, BUFSIZE); | 175 | // number=::read( filePara.sd, sbuf, BUFSIZE); |
169 | number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); | 176 | number = soundDevice->devRead( filePara.sd, sbuf, BUFSIZE); |
170 | 177 | ||
171 | if(number <= 0) { | 178 | if(number <= 0) { |
172 | perror("recording error "); | 179 | perror("recording error "); |
173 | odebug << "" << filePara.fileName << " " << number << "" << oendl; | 180 | odebug << "" << filePara.fileName << " " << number << "" << oendl; |
174 | stopped = true; | 181 | stopped = true; |
175 | return; | 182 | return; |
176 | } | 183 | } |
177 | //if(stereo == 2) { | 184 | //if(stereo == 2) { |
178 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 185 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
179 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 186 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
180 | 187 | ||
181 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); | 188 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); |