Diffstat (limited to 'core/multimedia/opieplayer/libmad/libmadplugin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9a1ab2a..9d1ff8c 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp | |||
@@ -76,4 +76,5 @@ public: | |||
76 | void *fdm; | 76 | void *fdm; |
77 | #endif | 77 | #endif |
78 | unsigned long fileLength; | ||
78 | unsigned char *data; | 79 | unsigned char *data; |
79 | unsigned long length; | 80 | unsigned long length; |
@@ -454,9 +455,14 @@ bool LibMadPlugin::open( const QString& path ) { | |||
454 | } | 455 | } |
455 | 456 | ||
456 | #if defined(HAVE_MMAP) | ||
457 | struct stat stat; | 457 | struct stat stat; |
458 | if (fstat(d->input.fd, &stat) == -1) { | 458 | if (fstat(d->input.fd, &stat) == -1) { |
459 | //qDebug("error calling fstat"); return FALSE; | 459 | qDebug("error calling fstat"); return FALSE; |
460 | } | 460 | } |
461 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) | ||
462 | d->input.fileLength = stat.st_size; | ||
463 | else | ||
464 | d->input.fileLength = 0; | ||
465 | |||
466 | #if defined(HAVE_MMAP) | ||
461 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { | 467 | if (S_ISREG(stat.st_mode) && stat.st_size > 0) { |
462 | d->input.length = stat.st_size; | 468 | d->input.length = stat.st_size; |
@@ -558,10 +564,22 @@ int LibMadPlugin::audioSamples( int ) { | |||
558 | debugMsg( "LibMadPlugin::audioSamples" ); | 564 | debugMsg( "LibMadPlugin::audioSamples" ); |
559 | 565 | ||
560 | // long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); | 566 | long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); |
561 | // mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); | 567 | mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); |
562 | // qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, d->frame.header.samplerate ); | 568 | /* |
563 | // return d->frame.header.duration.seconds * d->frame.header.samplerate; | 569 | qDebug( "LibMadPlugin::audioSamples: %i*%i", d->frame.header.duration.seconds, |
570 | d->frame.header.samplerate ); | ||
571 | return d->frame.header.duration.seconds * d->frame.header.samplerate; | ||
572 | */ | ||
573 | if ( d->frame.header.bitrate == 0 ) | ||
574 | return 0; | ||
575 | int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; | ||
564 | 576 | ||
565 | return 10000000; | 577 | qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, |
578 | (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); | ||
579 | qDebug( "LibMadPlugin::audioSamples: %i", samples ); | ||
580 | |||
581 | return samples; | ||
582 | |||
583 | // return 10000000; | ||
566 | } | 584 | } |
567 | 585 | ||
@@ -569,4 +587,20 @@ int LibMadPlugin::audioSamples( int ) { | |||
569 | bool LibMadPlugin::audioSetSample( long, int ) { | 587 | bool LibMadPlugin::audioSetSample( long, int ) { |
570 | debugMsg( "LibMadPlugin::audioSetSample" ); | 588 | debugMsg( "LibMadPlugin::audioSetSample" ); |
589 | |||
590 | // long totalSamples = audioSamples(0); | ||
591 | // if ( totalSamples <= 1 ) | ||
592 | // return FALSE; | ||
593 | |||
594 | // // Seek to requested position | ||
595 | // qDebug( "seek pos: %i", (int)((double)pos * d->input.fileLength / totalSamples) ); | ||
596 | // ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); | ||
597 | // mad_stream_sync(&d->stream); | ||
598 | |||
599 | // mad_stream_init(&d->stream); | ||
600 | // mad_frame_init(&d->frame); | ||
601 | // mad_synth_init(&d->synth); | ||
602 | |||
603 | // return TRUE; | ||
604 | debugMsg( "LibMadPlugin::audioSetSample" ); | ||
571 | return FALSE; | 605 | return FALSE; |
572 | } | 606 | } |