summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-23 13:46:45 (UTC)
committer llornkcor <llornkcor>2002-06-23 13:46:45 (UTC)
commit6563867791664113808d1b287510ca52b5f840e0 (patch) (unidiff)
tree643d1a90c0df95095b721b2f4c50af6627eec1a1
parentf9c5bf03ae5a89ef5cda69e37cc2732f4e4f2808 (diff)
downloadopie-6563867791664113808d1b287510ca52b5f840e0.zip
opie-6563867791664113808d1b287510ca52b5f840e0.tar.gz
opie-6563867791664113808d1b287510ca52b5f840e0.tar.bz2
automute and unmute
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
@@ -407,8 +407,10 @@ int VMemo::openDSP()
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
@@ -452,88 +454,91 @@ void VMemo::record(void)
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) {
@@ -543,14 +548,14 @@ void VMemo::record(void)
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 );
@@ -578,8 +583,15 @@ void VMemo::record(void)
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