-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 7dd5b4b..622b1df 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -14,2 +14,6 @@ | |||
14 | 14 | ||
15 | /* OPIE */ | ||
16 | #include <opie2/odebug.h> | ||
17 | using namespace Opie::Core; | ||
18 | |||
15 | extern "C" { | 19 | extern "C" { |
@@ -31,3 +35,3 @@ typedef struct _waveheader { | |||
31 | u_long sub_chunk; /* 'fmt ' */ | 35 | u_long sub_chunk; /* 'fmt ' */ |
32 | u_long sc_len; /* length of sub_chunk, =16 | 36 | u_long sc_len; /* length of sub_chunk, =16 |
33 | (chunckSize) format len */ | 37 | (chunckSize) format len */ |
@@ -200,6 +204,6 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
200 | setFixedWidth( 14 ); | 204 | setFixedWidth( 14 ); |
201 | 205 | ||
202 | t_timer = new QTimer( this ); | 206 | t_timer = new QTimer( this ); |
203 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 207 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
204 | 208 | ||
205 | Config vmCfg("Vmemo"); | 209 | Config vmCfg("Vmemo"); |
@@ -209,8 +213,8 @@ VMemo::VMemo( QWidget *parent, const char *_name ) | |||
209 | 213 | ||
210 | qDebug("toggleKey %d", toggleKey); | 214 | odebug << "toggleKey " << toggleKey << "" << oendl; |
211 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 215 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
212 | systemZaurus=TRUE; | 216 | systemZaurus=TRUE; |
213 | else | 217 | else |
214 | systemZaurus=FALSE; | 218 | systemZaurus=FALSE; |
215 | 219 | ||
216 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 220 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
@@ -247,3 +251,3 @@ int VMemo::position() | |||
247 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 251 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
248 | qDebug("receive"); | 252 | odebug << "receive" << oendl; |
249 | QDataStream stream( data, IO_ReadOnly ); | 253 | QDataStream stream( data, IO_ReadOnly ); |
@@ -269,3 +273,3 @@ void VMemo::mousePressEvent( QMouseEvent * me) { | |||
269 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 273 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
270 | 274 | ||
271 | // if (!systemZaurus && me != NULL) | 275 | // if (!systemZaurus && me != NULL) |
@@ -295,3 +299,3 @@ bool VMemo::startRecording() { | |||
295 | 299 | ||
296 | qDebug("Start recording engines"); | 300 | odebug << "Start recording engines" << oendl; |
297 | recording = TRUE; | 301 | recording = TRUE; |
@@ -302,3 +306,3 @@ bool VMemo::startRecording() { | |||
302 | } | 306 | } |
303 | 307 | ||
304 | config.setGroup("Defaults"); | 308 | config.setGroup("Defaults"); |
@@ -320,3 +324,3 @@ bool VMemo::startRecording() { | |||
320 | fileName=fileName.right(fileName.length()-s-2); | 324 | fileName=fileName.right(fileName.length()-s-2); |
321 | qDebug("pathname will be "+fileName); | 325 | odebug << "pathname will be "+fileName << oendl; |
322 | 326 | ||
@@ -327,10 +331,10 @@ bool VMemo::startRecording() { | |||
327 | fName = "vm_"+ date+ ".wav"; | 331 | fName = "vm_"+ date+ ".wav"; |
328 | 332 | ||
329 | fileName+=fName; | 333 | fileName+=fName; |
330 | qDebug("filename is "+fileName); | 334 | odebug << "filename is "+fileName << oendl; |
331 | // open tmp file here | 335 | // open tmp file here |
332 | char *pointer; | 336 | char *pointer; |
333 | pointer=tmpnam(NULL); | 337 | pointer=tmpnam(NULL); |
334 | qDebug("Opening tmp file %s",pointer); | 338 | odebug << "Opening tmp file " << pointer << "" << oendl; |
335 | 339 | ||
336 | if(openWAV(pointer ) == -1) { | 340 | if(openWAV(pointer ) == -1) { |
@@ -351,3 +355,3 @@ bool VMemo::startRecording() { | |||
351 | // move tmp file to regular file here | 355 | // move tmp file to regular file here |
352 | 356 | ||
353 | system(cmd.latin1()); | 357 | system(cmd.latin1()); |
@@ -356,3 +360,3 @@ bool VMemo::startRecording() { | |||
356 | cats[0] = config.readNumEntry("Category", 0); | 360 | cats[0] = config.readNumEntry("Category", 0); |
357 | 361 | ||
358 | QString dlName("vm_"); | 362 | QString dlName("vm_"); |
@@ -368,3 +372,3 @@ bool VMemo::startRecording() { | |||
368 | return FALSE; | 372 | return FALSE; |
369 | 373 | ||
370 | } | 374 | } |
@@ -373,3 +377,3 @@ void VMemo::stopRecording() { | |||
373 | show(); | 377 | show(); |
374 | qDebug("Stopped recording"); | 378 | odebug << "Stopped recording" << oendl; |
375 | recording = FALSE; | 379 | recording = FALSE; |
@@ -390,3 +394,3 @@ int VMemo::openDSP() { | |||
390 | cfg.setGroup("Record"); | 394 | cfg.setGroup("Record"); |
391 | 395 | ||
392 | speed = cfg.readNumEntry("SampleRate", 22050); | 396 | speed = cfg.readNumEntry("SampleRate", 22050); |
@@ -401,3 +405,3 @@ int VMemo::openDSP() { | |||
401 | 405 | ||
402 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 406 | odebug << "samplerate: " << speed << ", channels " << channels << ", resolution " << resolution << "" << oendl; |
403 | 407 | ||
@@ -409,3 +413,3 @@ int VMemo::openDSP() { | |||
409 | } | 413 | } |
410 | 414 | ||
411 | if(dsp == -1) { | 415 | if(dsp == -1) { |
@@ -414,3 +418,3 @@ int VMemo::openDSP() { | |||
414 | delete msgLabel; | 418 | delete msgLabel; |
415 | 419 | ||
416 | perror("open(\"/dev/dsp\")"); | 420 | perror("open(\"/dev/dsp\")"); |
@@ -420,3 +424,3 @@ int VMemo::openDSP() { | |||
420 | } | 424 | } |
421 | 425 | ||
422 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 426 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
@@ -439,3 +443,3 @@ int VMemo::openDSP() { | |||
439 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 443 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
440 | 444 | ||
441 | return 1; | 445 | return 1; |
@@ -454,3 +458,3 @@ int VMemo::openWAV(const char *filename) { | |||
454 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 458 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
455 | 459 | ||
456 | WaveHeader wh; | 460 | WaveHeader wh; |
@@ -458,3 +462,3 @@ int VMemo::openWAV(const char *filename) { | |||
458 | wh.main_chunk = RIFF; | 462 | wh.main_chunk = RIFF; |
459 | wh.length=0; | 463 | wh.length=0; |
460 | wh.chunk_type = WAVE; | 464 | wh.chunk_type = WAVE; |
@@ -465,3 +469,3 @@ int VMemo::openWAV(const char *filename) { | |||
465 | else | 469 | else |
466 | wh.format = PCM_CODE; | 470 | wh.format = PCM_CODE; |
467 | wh.modus = channels; | 471 | wh.modus = channels; |
@@ -469,6 +473,6 @@ int VMemo::openWAV(const char *filename) { | |||
469 | wh.byte_p_sec = speed * channels * resolution/8; | 473 | wh.byte_p_sec = speed * channels * resolution/8; |
470 | wh.byte_p_spl = channels * (resolution / 8); | 474 | wh.byte_p_spl = channels * (resolution / 8); |
471 | wh.bit_p_spl = resolution; | 475 | wh.bit_p_spl = resolution; |
472 | wh.data_chunk = DATA; | 476 | wh.data_chunk = DATA; |
473 | wh.data_length= 0; | 477 | wh.data_length= 0; |
474 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 478 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
@@ -476,3 +480,3 @@ int VMemo::openWAV(const char *filename) { | |||
476 | write (wav, &wh, sizeof(WaveHeader)); | 480 | write (wav, &wh, sizeof(WaveHeader)); |
477 | 481 | ||
478 | return 1; | 482 | return 1; |
@@ -485,3 +489,3 @@ bool VMemo::record() { | |||
485 | msg.sprintf("Recording format %d", format); | 489 | msg.sprintf("Recording format %d", format); |
486 | qDebug(msg); | 490 | odebug << msg << oendl; |
487 | Config config("Vmemo"); | 491 | Config config("Vmemo"); |
@@ -496,3 +500,3 @@ bool VMemo::record() { | |||
496 | msg.sprintf("Recording format other"); | 500 | msg.sprintf("Recording format other"); |
497 | qDebug(msg); | 501 | odebug << msg << oendl; |
498 | 502 | ||
@@ -515,3 +519,3 @@ bool VMemo::record() { | |||
515 | perror("recording error "); | 519 | perror("recording error "); |
516 | // qDebug(currentFileName); | 520 | // odebug << currentFileName << oendl; |
517 | QMessageBox::message(tr("Note"),tr("error recording")); | 521 | QMessageBox::message(tr("Note"),tr("error recording")); |
@@ -542,3 +546,3 @@ bool VMemo::record() { | |||
542 | } | 546 | } |
543 | // printf("%d\r",length); | 547 | // odebug << "" << length << "\r" << oendl; |
544 | // fflush(stdout); | 548 | // fflush(stdout); |
@@ -561,4 +565,4 @@ bool VMemo::record() { | |||
561 | track.close(); | 565 | track.close(); |
562 | qDebug("Track closed"); | 566 | odebug << "Track closed" << oendl; |
563 | 567 | ||
564 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 568 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
@@ -575,3 +579,3 @@ bool VMemo::record() { | |||
575 | QString currentFile = "vm_"+ date; | 579 | QString currentFile = "vm_"+ date; |
576 | 580 | ||
577 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; | 581 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; |
@@ -585,3 +589,3 @@ bool VMemo::record() { | |||
585 | cfgO.writeEntry( currentFileName, time ); | 589 | cfgO.writeEntry( currentFileName, time ); |
586 | // qDebug("writing config numberOfRecordedSeconds "+time); | 590 | // odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
587 | 591 | ||
@@ -589,3 +593,3 @@ bool VMemo::record() { | |||
589 | 593 | ||
590 | qDebug("done recording "+fileName); | 594 | odebug << "done recording "+fileName << oendl; |
591 | 595 | ||
@@ -604,28 +608,28 @@ int VMemo::setToggleButton(int tog) { | |||
604 | case 0: | 608 | case 0: |
605 | return -1; | 609 | return -1; |
606 | break; | 610 | break; |
607 | case 1: | 611 | case 1: |
608 | return 0; | 612 | return 0; |
609 | break; | 613 | break; |
610 | case 2: | 614 | case 2: |
611 | return Key_F24; //was Escape | 615 | return Key_F24; //was Escape |
612 | break; | 616 | break; |
613 | case 3: | 617 | case 3: |
614 | return Key_Space; | 618 | return Key_Space; |
615 | break; | 619 | break; |
616 | case 4: | 620 | case 4: |
617 | return Key_F12; | 621 | return Key_F12; |
618 | break; | 622 | break; |
619 | case 5: | 623 | case 5: |
620 | return Key_F9; | 624 | return Key_F9; |
621 | break; | 625 | break; |
622 | case 6: | 626 | case 6: |
623 | return Key_F10; | 627 | return Key_F10; |
624 | break; | 628 | break; |
625 | case 7: | 629 | case 7: |
626 | return Key_F11; | 630 | return Key_F11; |
627 | break; | 631 | break; |
628 | case 8: | 632 | case 8: |
629 | return Key_F13; | 633 | return Key_F13; |
630 | break; | 634 | break; |
631 | }; | 635 | }; |