summaryrefslogtreecommitdiff
authorar <ar>2004-05-02 21:42:26 (UTC)
committer ar <ar>2004-05-02 21:42:26 (UTC)
commit0bbed7c9d1fe9e617ba3825b0883b7af75ee0733 (patch) (unidiff)
tree245b60310031264faed44d34bf980182257eec54
parent0a4cac124105a5732e55cb34c6b37be75083a395 (diff)
downloadopie-0bbed7c9d1fe9e617ba3825b0883b7af75ee0733.zip
opie-0bbed7c9d1fe9e617ba3825b0883b7af75ee0733.tar.gz
opie-0bbed7c9d1fe9e617ba3825b0883b7af75ee0733.tar.bz2
- convert qDebug to odebug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index 428fc28..7438a45 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -453,258 +453,258 @@ bool LibMadPlugin::open( const QString& path ) {
453 d->input.fd = ::open( d->input.path, O_RDONLY ); 453 d->input.fd = ::open( d->input.path, O_RDONLY );
454 // thats a better place, since it should only seek for ID3 tags on mp3 files, not streams 454 // thats a better place, since it should only seek for ID3 tags on mp3 files, not streams
455 printID3Tags(); 455 printID3Tags();
456 } 456 }
457 if (d->input.fd == -1) { 457 if (d->input.fd == -1) {
458 // odebug << "error opening " << d->input.path << "" << oendl; 458 // odebug << "error opening " << d->input.path << "" << oendl;
459 return FALSE; 459 return FALSE;
460 } 460 }
461 461
462 struct stat stat; 462 struct stat stat;
463 if (fstat(d->input.fd, &stat) == -1) { 463 if (fstat(d->input.fd, &stat) == -1) {
464 // odebug << "error calling fstat" << oendl; return FALSE; 464 // odebug << "error calling fstat" << oendl; return FALSE;
465 } 465 }
466 if (S_ISREG(stat.st_mode) && stat.st_size > 0) 466 if (S_ISREG(stat.st_mode) && stat.st_size > 0)
467 d->input.fileLength = stat.st_size; 467 d->input.fileLength = stat.st_size;
468 else 468 else
469 d->input.fileLength = 0; 469 d->input.fileLength = 0;
470 470
471#if defined(HAVE_MMAP) 471#if defined(HAVE_MMAP)
472 if (S_ISREG(stat.st_mode) && stat.st_size > 0) { 472 if (S_ISREG(stat.st_mode) && stat.st_size > 0) {
473 d->input.length = stat.st_size; 473 d->input.length = stat.st_size;
474 d->input.fdm = map_file(d->input.fd, &d->input.length); 474 d->input.fdm = map_file(d->input.fd, &d->input.length);
475 if (d->input.fdm == 0) { 475 if (d->input.fdm == 0) {
476 // odebug << "error mmapping file" << oendl; return FALSE; 476 // odebug << "error mmapping file" << oendl; return FALSE;
477 } 477 }
478 d->input.data = (unsigned char *)d->input.fdm; 478 d->input.data = (unsigned char *)d->input.fdm;
479 } 479 }
480#endif 480#endif
481 481
482 if (d->input.data == 0) { 482 if (d->input.data == 0) {
483 d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); 483 d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/);
484 if (d->input.data == 0) { 484 if (d->input.data == 0) {
485 // odebug << "error allocating input buffer" << oendl; 485 // odebug << "error allocating input buffer" << oendl;
486 return FALSE; 486 return FALSE;
487 } 487 }
488 d->input.length = 0; 488 d->input.length = 0;
489 } 489 }
490 490
491 d->input.eof = 0; 491 d->input.eof = 0;
492 492
493 mad_stream_init(&d->stream); 493 mad_stream_init(&d->stream);
494 mad_frame_init(&d->frame); 494 mad_frame_init(&d->frame);
495 mad_synth_init(&d->synth); 495 mad_synth_init(&d->synth);
496 496
497 return TRUE; 497 return TRUE;
498} 498}
499 499
500 500
501bool LibMadPlugin::close() { 501bool LibMadPlugin::close() {
502 debugMsg( "LibMadPlugin::close" ); 502 debugMsg( "LibMadPlugin::close" );
503 503
504 int result = TRUE; 504 int result = TRUE;
505 505
506 mad_synth_finish(&d->synth); 506 mad_synth_finish(&d->synth);
507 mad_frame_finish(&d->frame); 507 mad_frame_finish(&d->frame);
508 mad_stream_finish(&d->stream); 508 mad_stream_finish(&d->stream);
509 509
510#if defined(HAVE_MMAP) 510#if defined(HAVE_MMAP)
511 if (d->input.fdm) { 511 if (d->input.fdm) {
512 if (unmap_file(d->input.fdm, d->input.length) == -1) { 512 if (unmap_file(d->input.fdm, d->input.length) == -1) {
513 // odebug << "error munmapping file" << oendl; 513 // odebug << "error munmapping file" << oendl;
514 result = FALSE; 514 result = FALSE;
515 } 515 }
516 d->input.fdm = 0; 516 d->input.fdm = 0;
517 d->input.data = 0; 517 d->input.data = 0;
518 } 518 }
519#endif 519#endif
520 520
521 if (d->input.data) { 521 if (d->input.data) {
522 free(d->input.data); 522 free(d->input.data);
523 d->input.data = 0; 523 d->input.data = 0;
524 } 524 }
525 525
526 if (::close(d->input.fd) == -1) { 526 if (::close(d->input.fd) == -1) {
527 // odebug << "error closing file " << d->input.path << "" << oendl; 527 // odebug << "error closing file " << d->input.path << "" << oendl;
528 result = FALSE; 528 result = FALSE;
529 } 529 }
530 530
531 d->input.fd = 0; 531 d->input.fd = 0;
532 532
533 return result; 533 return result;
534} 534}
535 535
536 536
537bool LibMadPlugin::isOpen() { 537bool LibMadPlugin::isOpen() {
538 debugMsg( "LibMadPlugin::isOpen" ); 538 debugMsg( "LibMadPlugin::isOpen" );
539 return ( d->input.fd != 0 ); 539 return ( d->input.fd != 0 );
540} 540}
541 541
542 542
543int LibMadPlugin::audioStreams() { 543int LibMadPlugin::audioStreams() {
544 debugMsg( "LibMadPlugin::audioStreams" ); 544 debugMsg( "LibMadPlugin::audioStreams" );
545 return 1; 545 return 1;
546} 546}
547 547
548 548
549int LibMadPlugin::audioChannels( int ) { 549int LibMadPlugin::audioChannels( int ) {
550 debugMsg( "LibMadPlugin::audioChannels" ); 550 debugMsg( "LibMadPlugin::audioChannels" );
551/* 551/*
552 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); 552 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
553 odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl; 553 odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl;
554 return d->frame.header.mode > 0 ? 2 : 1; 554 return d->frame.header.mode > 0 ? 2 : 1;
555*/ 555*/
556 return 2; 556 return 2;
557} 557}
558 558
559 559
560int LibMadPlugin::audioFrequency( int ) { 560int LibMadPlugin::audioFrequency( int ) {
561 debugMsg( "LibMadPlugin::audioFrequency" ); 561 debugMsg( "LibMadPlugin::audioFrequency" );
562 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); 562 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
563 // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl; 563 // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl;
564 return d->frame.header.samplerate; 564 return d->frame.header.samplerate;
565} 565}
566 566
567 567
568int LibMadPlugin::audioSamples( int ) { 568int LibMadPlugin::audioSamples( int ) {
569 debugMsg( "LibMadPlugin::audioSamples" ); 569 debugMsg( "LibMadPlugin::audioSamples" );
570 570
571 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); 571 long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 );
572 mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); 572 mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream );
573/* 573/*
574 odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl; 574 odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl;
575 return d->frame.header.duration.seconds * d->frame.header.samplerate; 575 return d->frame.header.duration.seconds * d->frame.header.samplerate;
576*/ 576*/
577 if ( d->frame.header.bitrate == 0 ) 577 if ( d->frame.header.bitrate == 0 )
578 return 0; 578 return 0;
579 int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; 579 int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate;
580 580
581 // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, 581 // odebug << "LibMadPlugin::audioSamples: " << (int)d->input.fileLength
582 // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); 582 // << " * " << (int)d->frame.header.samplerate << " * 8 / " << (int)d->frame.header.bitrate << oendl;
583 // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl; 583 // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl;
584 584
585 return samples; 585 return samples;
586 586
587// return 10000000; 587// return 10000000;
588} 588}
589 589
590 590
591bool LibMadPlugin::audioSetSample( long, int ) { 591bool LibMadPlugin::audioSetSample( long, int ) {
592 debugMsg( "LibMadPlugin::audioSetSample" ); 592 debugMsg( "LibMadPlugin::audioSetSample" );
593 593
594// long totalSamples = audioSamples(0); 594// long totalSamples = audioSamples(0);
595// if ( totalSamples <= 1 ) 595// if ( totalSamples <= 1 )
596// return FALSE; 596// return FALSE;
597 597
598// // Seek to requested position 598// // Seek to requested position
599// odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl; 599// odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl;
600// ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); 600// ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET );
601// mad_stream_sync(&d->stream); 601// mad_stream_sync(&d->stream);
602 602
603// mad_stream_init(&d->stream); 603// mad_stream_init(&d->stream);
604// mad_frame_init(&d->frame); 604// mad_frame_init(&d->frame);
605// mad_synth_init(&d->synth); 605// mad_synth_init(&d->synth);
606 606
607// return TRUE; 607// return TRUE;
608 debugMsg( "LibMadPlugin::audioSetSample" ); 608 debugMsg( "LibMadPlugin::audioSetSample" );
609 return FALSE; 609 return FALSE;
610} 610}
611 611
612 612
613long LibMadPlugin::audioGetSample( int ) { 613long LibMadPlugin::audioGetSample( int ) {
614 debugMsg( "LibMadPlugin::audioGetSample" ); 614 debugMsg( "LibMadPlugin::audioGetSample" );
615 return 0; 615 return 0;
616} 616}
617 617
618/* 618/*
619bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { 619bool LibMadPlugin::audioReadSamples( short *, int, long, int ) {
620debugMsg( "LibMadPlugin::audioReadSamples" ); 620debugMsg( "LibMadPlugin::audioReadSamples" );
621return FALSE; 621return FALSE;
622} 622}
623 623
624 624
625bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { 625bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) {
626debugMsg( "LibMadPlugin::audioReReadSamples" ); 626debugMsg( "LibMadPlugin::audioReReadSamples" );
627 return FALSE; 627 return FALSE;
628 } 628 }
629*/ 629*/
630 630
631bool LibMadPlugin::read() { 631bool LibMadPlugin::read() {
632 debugMsg( "LibMadPlugin::read" ); 632 debugMsg( "LibMadPlugin::read" );
633 int len; 633 int len;
634 634
635 if (d->input.eof) 635 if (d->input.eof)
636 return FALSE; 636 return FALSE;
637 637
638#if defined(HAVE_MMAP) 638#if defined(HAVE_MMAP)
639 if (d->input.fdm) { 639 if (d->input.fdm) {
640 unsigned long skip = 0; 640 unsigned long skip = 0;
641 641
642 if (d->stream.next_frame) { 642 if (d->stream.next_frame) {
643 struct stat stat; 643 struct stat stat;
644 644
645 if (fstat(d->input.fd, &stat) == -1) 645 if (fstat(d->input.fd, &stat) == -1)
646 return FALSE; 646 return FALSE;
647 647
648 if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) 648 if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length)
649 return FALSE; 649 return FALSE;
650 650
651 // file size changed; update memory map 651 // file size changed; update memory map
652 skip = d->stream.next_frame - d->input.data; 652 skip = d->stream.next_frame - d->input.data;
653 653
654 if (unmap_file(d->input.fdm, d->input.length) == -1) { 654 if (unmap_file(d->input.fdm, d->input.length) == -1) {
655 d->input.fdm = 0; 655 d->input.fdm = 0;
656 d->input.data = 0; 656 d->input.data = 0;
657 return FALSE; 657 return FALSE;
658 } 658 }
659 659
660 d->input.length = stat.st_size; 660 d->input.length = stat.st_size;
661 661
662 d->input.fdm = map_file(d->input.fd, &d->input.length); 662 d->input.fdm = map_file(d->input.fd, &d->input.length);
663 if (d->input.fdm == 0) { 663 if (d->input.fdm == 0) {
664 d->input.data = 0; 664 d->input.data = 0;
665 return FALSE; 665 return FALSE;
666 } 666 }
667 667
668 d->input.data = (unsigned char *)d->input.fdm; 668 d->input.data = (unsigned char *)d->input.fdm;
669 } 669 }
670 670
671 mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); 671 mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip);
672 672
673 } else 673 } else
674#endif 674#endif
675 { 675 {
676 if (d->stream.next_frame) { 676 if (d->stream.next_frame) {
677 memmove(d->input.data, d->stream.next_frame, 677 memmove(d->input.data, d->stream.next_frame,
678 d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); 678 d->input.length = &d->input.data[d->input.length] - d->stream.next_frame);
679 } 679 }
680 680
681 do { 681 do {
682 len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); 682 len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length);
683 } 683 }
684 while (len == -1 && errno == EINTR); 684 while (len == -1 && errno == EINTR);
685 685
686 if (len == -1) { 686 if (len == -1) {
687 // odebug << "error reading audio" << oendl; 687 // odebug << "error reading audio" << oendl;
688 return FALSE; 688 return FALSE;
689 } 689 }
690 else if (len == 0) { 690 else if (len == 0) {
691 d->input.eof = 1; 691 d->input.eof = 1;
692 692
693 assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); 693 assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD);
694 694
695 while (len < MAD_BUFFER_GUARD) 695 while (len < MAD_BUFFER_GUARD)
696 d->input.data[d->input.length + len++] = 0; 696 d->input.data[d->input.length + len++] = 0;
697 } 697 }
698 698
699 mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); 699 mad_stream_buffer(&d->stream, d->input.data, d->input.length += len);
700 } 700 }
701 701
702 return TRUE; 702 return TRUE;
703} 703}
704 704
705 705
706static mad_fixed_t left_err, right_err; 706static mad_fixed_t left_err, right_err;
707static const int bits = 16; 707static const int bits = 16;
708static const int shift = MAD_F_FRACBITS + 1 - bits; 708static const int shift = MAD_F_FRACBITS + 1 - bits;
709 709
710 710