author | llornkcor <llornkcor> | 2002-06-23 14:43:54 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-23 14:43:54 (UTC) |
commit | 6382b7352205a71557bd87b4f43d7f19f7f3330e (patch) (unidiff) | |
tree | 16097c620467a774336a717dba4b4f316e6208c4 | |
parent | 8672a04720e7421e7f41bbf49364bcc1df910bb2 (diff) | |
download | opie-6382b7352205a71557bd87b4f43d7f19f7f3330e.zip opie-6382b7352205a71557bd87b4f43d7f19f7f3330e.tar.gz opie-6382b7352205a71557bd87b4f43d7f19f7f3330e.tar.bz2 |
took out unreachable code
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 4278f46..cfa07b4 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -384,240 +384,223 @@ int VMemo::openDSP() | |||
384 | } else { | 384 | } else { |
385 | dsp = open("/dev/dsp", O_RDWR); | 385 | dsp = open("/dev/dsp", O_RDWR); |
386 | } | 386 | } |
387 | 387 | ||
388 | if(dsp == -1) { | 388 | if(dsp == -1) { |
389 | perror("open(\"/dev/dsp\")"); | 389 | perror("open(\"/dev/dsp\")"); |
390 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 390 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
391 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 391 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
392 | return -1; | 392 | return -1; |
393 | } | 393 | } |
394 | 394 | ||
395 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 395 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
396 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 396 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
397 | return -1; | 397 | return -1; |
398 | } | 398 | } |
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 | 411 | ||
412 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 412 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
413 | 413 | ||
414 | return 1; | 414 | return 1; |
415 | } | 415 | } |
416 | 416 | ||
417 | int VMemo::openWAV(const char *filename) | 417 | int VMemo::openWAV(const char *filename) |
418 | { | 418 | { |
419 | track.setName(filename); | 419 | track.setName(filename); |
420 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 420 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
421 | errorMsg=filename; | 421 | errorMsg=filename; |
422 | return -1; | 422 | return -1; |
423 | } | 423 | } |
424 | 424 | ||
425 | wav=track.handle(); | 425 | wav=track.handle(); |
426 | 426 | ||
427 | WaveHeader wh; | 427 | WaveHeader wh; |
428 | 428 | ||
429 | wh.main_chunk = RIFF; | 429 | wh.main_chunk = RIFF; |
430 | wh.length=0; | 430 | wh.length=0; |
431 | wh.chunk_type = WAVE; | 431 | wh.chunk_type = WAVE; |
432 | wh.sub_chunk = FMT; | 432 | wh.sub_chunk = FMT; |
433 | wh.sc_len = 16; | 433 | wh.sc_len = 16; |
434 | wh.format = PCM_CODE; | 434 | wh.format = PCM_CODE; |
435 | wh.modus = channels; | 435 | wh.modus = channels; |
436 | wh.sample_fq = speed; | 436 | wh.sample_fq = speed; |
437 | wh.byte_p_sec = speed * channels * resolution/8; | 437 | wh.byte_p_sec = speed * channels * resolution/8; |
438 | wh.byte_p_spl = channels * (resolution / 8); | 438 | wh.byte_p_spl = channels * (resolution / 8); |
439 | wh.bit_p_spl = resolution; | 439 | wh.bit_p_spl = resolution; |
440 | wh.data_chunk = DATA; | 440 | wh.data_chunk = DATA; |
441 | wh.data_length= 0; | 441 | wh.data_length= 0; |
442 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 442 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
443 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 443 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
444 | write (wav, &wh, sizeof(WaveHeader)); | 444 | write (wav, &wh, sizeof(WaveHeader)); |
445 | 445 | ||
446 | return 1; | 446 | return 1; |
447 | } | 447 | } |
448 | 448 | ||
449 | void VMemo::record(void) | 449 | void VMemo::record(void) |
450 | { | 450 | { |
451 | int length=0, result, value; | 451 | int length=0, result, value; |
452 | QString msg; | 452 | QString msg; |
453 | msg.sprintf("Recording format %d", format); | 453 | msg.sprintf("Recording format %d", format); |
454 | qDebug(msg); | 454 | qDebug(msg); |
455 | 455 | ||
456 | if(systemZaurus) { | 456 | if(systemZaurus) { |
457 | 457 | ||
458 | msg.sprintf("Recording format zaurus"); | 458 | msg.sprintf("Recording format zaurus"); |
459 | qDebug(msg); | 459 | qDebug(msg); |
460 | signed short sound[512], monoBuffer[512]; | 460 | signed short sound[512], monoBuffer[512]; |
461 | 461 | ||
462 | if(format==AFMT_S16_LE) { | 462 | if(format==AFMT_S16_LE) { |
463 | 463 | ||
464 | 464 | ||
465 | 465 | ||
466 | while(recording) { | 466 | while(recording) { |
467 | 467 | ||
468 | result = read(dsp, sound, 512); // 8192 | 468 | result = read(dsp, sound, 512); // 8192 |
469 | int j=0; | 469 | int j=0; |
470 | 470 | ||
471 | // if(systemZaurus) { | 471 | // if(systemZaurus) { |
472 | 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 |
473 | monoBuffer[i] = sound[i]; | 473 | monoBuffer[i] = sound[i]; |
474 | } | 474 | } |
475 | 475 | ||
476 | length+=write(wav, monoBuffer, result); | 476 | length+=write(wav, monoBuffer, result); |
477 | if(length<0) | 477 | if(length<0) |
478 | recording=false; | 478 | recording=false; |
479 | 479 | ||
480 | // } else { //ipaq /stereo inputs | ||
481 | |||
482 | |||
483 | // for (int i = 0; i < result; i+=2) { | 480 | // for (int i = 0; i < result; i+=2) { |
484 | // monoBuffer[j] = sound[i]; | 481 | // monoBuffer[j] = sound[i]; |
485 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 482 | // // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
486 | 483 | ||
487 | // j++; | 484 | // j++; |
488 | // } | 485 | // } |
489 | |||
490 | // length+=write(wav, monoBuffer, result); | ||
491 | // if(length<0) | ||
492 | // recording=false; | ||
493 | // // length+=write(wav, monoBuffer, result/2); | ||
494 | // } | ||
495 | qApp->processEvents(); | 486 | qApp->processEvents(); |
496 | // printf("%d\r",length); | 487 | // printf("%d\r",length); |
497 | // fflush(stdout); | 488 | // fflush(stdout); |
498 | } | 489 | } |
499 | 490 | ||
500 | } else { //AFMT_U8 | 491 | } else { //AFMT_U8 |
501 | // 8bit unsigned | 492 | // 8bit unsigned |
502 | unsigned short sound[512], monoBuffer[512]; | 493 | unsigned short sound[512], monoBuffer[512]; |
503 | while(recording) { | 494 | while(recording) { |
504 | result = read(dsp, sound, 512); // 8192 | 495 | result = read(dsp, sound, 512); // 8192 |
505 | int j=0; | 496 | int j=0; |
506 | 497 | ||
507 | // if(systemZaurus) { | 498 | // if(systemZaurus) { |
508 | 499 | ||
509 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 500 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
510 | monoBuffer[i] = sound[i]; | 501 | monoBuffer[i] = sound[i]; |
511 | } | 502 | } |
512 | 503 | ||
513 | length+=write(wav, monoBuffer, result); | 504 | length+=write(wav, monoBuffer, result); |
514 | 505 | ||
515 | // } else { //ipaq /stereo inputs | ||
516 | |||
517 | // for (int i = 0; i < result; i+=2) { | 506 | // for (int i = 0; i < result; i+=2) { |
518 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; | 507 | // monoBuffer[j] = (sound[i]+sound[i+1])/2; |
519 | // j++; | 508 | // j++; |
520 | // } | 509 | // } |
521 | |||
522 | // length+=write(wav, monoBuffer, result/2); | 510 | // length+=write(wav, monoBuffer, result/2); |
523 | |||
524 | // if(length<0) | ||
525 | // recording=false; | ||
526 | |||
527 | // } | ||
528 | length += result; | 511 | length += result; |
529 | // printf("%d\r",length); | 512 | // printf("%d\r",length); |
530 | // fflush(stdout); | 513 | // fflush(stdout); |
531 | } | 514 | } |
532 | 515 | ||
533 | qApp->processEvents(); | 516 | qApp->processEvents(); |
534 | } | 517 | } |
535 | 518 | ||
536 | } else { // 16 bit only capabilities | 519 | } else { // 16 bit only capabilities |
537 | 520 | ||
538 | 521 | ||
539 | msg.sprintf("Recording format other"); | 522 | msg.sprintf("Recording format other"); |
540 | qDebug(msg); | 523 | qDebug(msg); |
541 | 524 | ||
542 | signed short sound[512], monoBuffer[512]; | 525 | signed short sound[512], monoBuffer[512]; |
543 | 526 | ||
544 | while(recording) { | 527 | while(recording) { |
545 | 528 | ||
546 | result = read(dsp, sound, 512); // 8192 | 529 | result = read(dsp, sound, 512); // 8192 |
547 | 530 | ||
548 | write(wav, sound, result); | 531 | write(wav, sound, result); |
549 | length += result; | 532 | length += result; |
550 | if(length<0) { | 533 | if(length<0) { |
551 | 534 | ||
552 | recording=false; | 535 | recording=false; |
553 | perror("dev/dsp's is a lookin' messy"); | 536 | perror("dev/dsp's is a lookin' messy"); |
554 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 537 | QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
555 | } | 538 | } |
556 | // printf("%d\r",length); | 539 | // printf("%d\r",length); |
557 | // fflush(stdout); | 540 | // fflush(stdout); |
558 | qApp->processEvents(); | 541 | qApp->processEvents(); |
559 | } | 542 | } |
560 | // qDebug("file has length of %d lasting %d seconds", | 543 | // qDebug("file has length of %d lasting %d seconds", |
561 | // length, (( length / speed) / channels) / 2 ); | 544 | // length, (( length / speed) / channels) / 2 ); |
562 | // medialplayer states wrong length in secs | 545 | // medialplayer states wrong length in secs |
563 | } | 546 | } |
564 | 547 | ||
565 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// | 548 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// |
566 | 549 | ||
567 | value = length+36; | 550 | value = length+36; |
568 | 551 | ||
569 | lseek(wav, 4, SEEK_SET); | 552 | lseek(wav, 4, SEEK_SET); |
570 | write(wav, &value, 4); | 553 | write(wav, &value, 4); |
571 | lseek(wav, 40, SEEK_SET); | 554 | lseek(wav, 40, SEEK_SET); |
572 | 555 | ||
573 | write(wav, &length, 4); | 556 | write(wav, &length, 4); |
574 | 557 | ||
575 | track.close(); | 558 | track.close(); |
576 | qDebug("Tracvk closed"); | 559 | qDebug("Tracvk closed"); |
577 | 560 | ||
578 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 561 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
579 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 562 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
580 | 563 | ||
581 | ::close(dsp); | 564 | ::close(dsp); |
582 | fileName = fileName.left(fileName.length()-4); | 565 | fileName = fileName.left(fileName.length()-4); |
583 | // if(useAlerts) | 566 | // if(useAlerts) |
584 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); | 567 | // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); |
585 | qDebug("done recording "+fileName); | 568 | qDebug("done recording "+fileName); |
586 | QSound::play(Resource::findSound("vmemoe")); | 569 | QSound::play(Resource::findSound("vmemoe")); |
587 | 570 | ||
588 | Config cfg("qpe"); | 571 | Config cfg("qpe"); |
589 | cfg.setGroup("Volume"); | 572 | cfg.setGroup("Volume"); |
590 | QString foo = cfg.readEntry("Mute","TRUE"); | 573 | QString foo = cfg.readEntry("Mute","TRUE"); |
591 | if(foo.find("TRUE",0,TRUE) != -1) | 574 | if(foo.find("TRUE",0,TRUE) != -1) |
592 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 575 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
593 | 576 | ||
594 | } | 577 | } |
595 | 578 | ||
596 | int VMemo::setToggleButton(int tog) { | 579 | int VMemo::setToggleButton(int tog) { |
597 | 580 | ||
598 | for( int i=0; i < 10;i++) { | 581 | for( int i=0; i < 10;i++) { |
599 | switch (tog) { | 582 | switch (tog) { |
600 | case 0: | 583 | case 0: |
601 | return -1; | 584 | return -1; |
602 | break; | 585 | break; |
603 | case 1: | 586 | case 1: |
604 | return 0; | 587 | return 0; |
605 | break; | 588 | break; |
606 | case 2: | 589 | case 2: |
607 | return Key_Escape; | 590 | return Key_Escape; |
608 | break; | 591 | break; |
609 | case 3: | 592 | case 3: |
610 | return Key_Space; | 593 | return Key_Space; |
611 | break; | 594 | break; |
612 | case 4: | 595 | case 4: |
613 | return Key_F12; | 596 | return Key_F12; |
614 | break; | 597 | break; |
615 | case 5: | 598 | case 5: |
616 | return Key_F9; | 599 | return Key_F9; |
617 | break; | 600 | break; |
618 | case 6: | 601 | case 6: |
619 | return Key_F10; | 602 | return Key_F10; |
620 | break; | 603 | break; |
621 | case 7: | 604 | case 7: |
622 | return Key_F11; | 605 | return Key_F11; |
623 | break; | 606 | break; |