summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show 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
@@ -485,194 +485,194 @@ bool LibMadPlugin::open( const QString& path ) {
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);