summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp106
1 files changed, 59 insertions, 47 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 10a947e..b29ee62 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -399,24 +399,26 @@ int VMemo::openDSP()
399 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { 399 if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) {
400 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); 400 perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
401 return -1; 401 return -1;
402 } 402 }
403 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { 403 if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) {
404 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 404 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
405 return -1; 405 return -1;
406 } 406 }
407 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { 407 if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) {
408 perror("ioctl(\"SOUND_PCM_READ_RATE\")"); 408 perror("ioctl(\"SOUND_PCM_READ_RATE\")");
409 return -1; 409 return -1;
410 } 410 }
411
412 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute
411 413
412 return 1; 414 return 1;
413} 415}
414 416
415int VMemo::openWAV(const char *filename) 417int VMemo::openWAV(const char *filename)
416{ 418{
417 track.setName(filename); 419 track.setName(filename);
418 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { 420 if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) {
419 errorMsg=filename; 421 errorMsg=filename;
420 return -1; 422 return -1;
421 } 423 }
422 424
@@ -444,121 +446,124 @@ int VMemo::openWAV(const char *filename)
444 return 1; 446 return 1;
445} 447}
446 448
447void VMemo::record(void) 449void VMemo::record(void)
448{ 450{
449 int length=0, result, value; 451 int length=0, result, value;
450 QString msg; 452 QString msg;
451 msg.sprintf("Recording format %d", format); 453 msg.sprintf("Recording format %d", format);
452 qDebug(msg); 454 qDebug(msg);
453 455
454 if(systemZaurus) { 456 if(systemZaurus) {
455 457
456 msg.sprintf("Recording format zaurus"); 458 msg.sprintf("Recording format zaurus");
457 qDebug(msg); 459 qDebug(msg);
458 signed short sound[512], monoBuffer[512]; 460 signed short sound[512], monoBuffer[512];
459 461
460 if(format==AFMT_S16_LE) { 462 if(format==AFMT_S16_LE) {
461 463
464
465
462 while(recording) { 466 while(recording) {
463 467
464 result = read(dsp, sound, 512); // 8192 468 result = read(dsp, sound, 512); // 8192
465 int j=0; 469 int j=0;
466 470
467 if(systemZaurus) { 471 // if(systemZaurus) {
468 for (int i = 0; i < result; i++) { //since Z is mono do normally 472 for (int i = 0; i < result; i++) { //since Z is mono do normally
469 monoBuffer[i] = sound[i]; 473 monoBuffer[i] = sound[i];
470 } 474 }
471 475
472 length+=write(wav, monoBuffer, result); 476 length+=write(wav, monoBuffer, result);
473 if(length<0) 477 if(length<0)
474 recording=false; 478 recording=false;
475 479
476 } else { //ipaq /stereo inputs 480 // } else { //ipaq /stereo inputs
477 481
478 482
479 for (int i = 0; i < result; i+=2) { 483 // for (int i = 0; i < result; i+=2) {
480 monoBuffer[j] = sound[i]; 484 // monoBuffer[j] = sound[i];
481 // monoBuffer[j] = (sound[i]+sound[i+1])/2; 485 // // monoBuffer[j] = (sound[i]+sound[i+1])/2;
482 486
483 j++; 487 // j++;
484 } 488 // }
485 489
486 length+=write(wav, monoBuffer, result); 490 // length+=write(wav, monoBuffer, result);
487 if(length<0) 491 // if(length<0)
488 recording=false; 492 // recording=false;
489 // length+=write(wav, monoBuffer, result/2); 493 // // length+=write(wav, monoBuffer, result/2);
490 } 494 // }
491 qApp->processEvents(); 495 qApp->processEvents();
492// printf("%d\r",length); 496 // printf("%d\r",length);
493// fflush(stdout); 497 // fflush(stdout);
494 } 498 }
495 499
496} else { //AFMT_U8 500 } else { //AFMT_U8
497 // 8bit unsigned 501 // 8bit unsigned
498 unsigned short sound[512], monoBuffer[512]; 502 unsigned short sound[512], monoBuffer[512];
499 while(recording) { 503 while(recording) {
500 result = read(dsp, sound, 512); // 8192 504 result = read(dsp, sound, 512); // 8192
501 int j=0; 505 int j=0;
502 506
503 if(systemZaurus) { 507 // if(systemZaurus) {
504 508
505 for (int i = 0; i < result; i++) { //since Z is mono do normally 509 for (int i = 0; i < result; i++) { //since Z is mono do normally
506 monoBuffer[i] = sound[i]; 510 monoBuffer[i] = sound[i];
507 } 511 }
508 512
509 length+=write(wav, monoBuffer, result); 513 length+=write(wav, monoBuffer, result);
510 514
511 } else { //ipaq /stereo inputs 515 // } else { //ipaq /stereo inputs
512 516
513 for (int i = 0; i < result; i+=2) { 517 // for (int i = 0; i < result; i+=2) {
514 monoBuffer[j] = (sound[i]+sound[i+1])/2; 518 // monoBuffer[j] = (sound[i]+sound[i+1])/2;
515 j++; 519 // j++;
516 } 520 // }
517 521
518 length+=write(wav, monoBuffer, result/2); 522 // length+=write(wav, monoBuffer, result/2);
519 523
520 if(length<0) 524 // if(length<0)
521 recording=false; 525 // recording=false;
522 526
523 } 527 // }
524 length += result; 528 length += result;
525// printf("%d\r",length); 529 // printf("%d\r",length);
526// fflush(stdout); 530 // fflush(stdout);
527 } 531 }
528 532
529 qApp->processEvents(); 533 qApp->processEvents();
530 } 534 }
531 535
532 } else { // this is specific for ipaqs that do not have 8 bit capabilities 536 } else { // 16 bit only capabilities
533 537
534 msg.sprintf("Recording format other"); 538
535 qDebug(msg); 539 msg.sprintf("Recording format other");
540 qDebug(msg);
536 541
537 signed short sound[512], monoBuffer[512]; 542 signed short sound[512], monoBuffer[512];
538 543
539 while(recording) { 544 while(recording) {
540 545
541 result = read(dsp, sound, 512); // 8192 546 result = read(dsp, sound, 512); // 8192
542 547
543 write(wav, sound, result); 548 write(wav, sound, result);
544 length += result; 549 length += result;
545 if(length<0) { 550 if(length<0) {
546 551
547 recording=false; 552 recording=false;
548 perror("dev/dsp's is a lookin' messy"); 553 perror("dev/dsp's is a lookin' messy");
549 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 554 QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
550 } 555 }
551// printf("%d\r",length); 556 // printf("%d\r",length);
552// fflush(stdout); 557 // fflush(stdout);
553 qApp->processEvents(); 558 qApp->processEvents();
554 } 559 }
555 // qDebug("file has length of %d lasting %d seconds", 560 // qDebug("file has length of %d lasting %d seconds",
556 // length, (( length / speed) / channels) / 2 ); 561 // length, (( length / speed) / channels) / 2 );
557 // medialplayer states wrong length in secs 562 // medialplayer states wrong length in secs
558 } 563 }
559 564
560 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// 565 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<//
561 566
562 value = length+36; 567 value = length+36;
563 568
564 lseek(wav, 4, SEEK_SET); 569 lseek(wav, 4, SEEK_SET);
@@ -570,24 +575,31 @@ void VMemo::record(void)
570 track.close(); 575 track.close();
571 qDebug("Tracvk closed"); 576 qDebug("Tracvk closed");
572 577
573 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) 578 if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
574 perror("ioctl(\"SNDCTL_DSP_RESET\")"); 579 perror("ioctl(\"SNDCTL_DSP_RESET\")");
575 580
576 ::close(dsp); 581 ::close(dsp);
577 fileName = fileName.left(fileName.length()-4); 582 fileName = fileName.left(fileName.length()-4);
578 // if(useAlerts) 583 // if(useAlerts)
579 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); 584 // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
580 qDebug("done recording "+fileName); 585 qDebug("done recording "+fileName);
581 QSound::play(Resource::findSound("vmemoe")); 586 QSound::play(Resource::findSound("vmemoe"));
587
588 Config cfg("qpe");
589 cfg.setGroup("Volume");
590 QString foo = cfg.readEntry("Mute","TRUE");
591 if(foo.find("TRUE",0,TRUE) != -1)
592 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
593
582} 594}
583 595
584int VMemo::setToggleButton(int tog) { 596int VMemo::setToggleButton(int tog) {
585 597
586 for( int i=0; i < 10;i++) { 598 for( int i=0; i < 10;i++) {
587 switch (tog) { 599 switch (tog) {
588 case 0: 600 case 0:
589 return -1; 601 return -1;
590 break; 602 break;
591 case 1: 603 case 1:
592 return 0; 604 return 0;
593 break; 605 break;