-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 4 |
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 ) { // odebug << "error allocating input buffer" << oendl; return FALSE; } d->input.length = 0; } d->input.eof = 0; mad_stream_init(&d->stream); mad_frame_init(&d->frame); mad_synth_init(&d->synth); return TRUE; } bool LibMadPlugin::close() { debugMsg( "LibMadPlugin::close" ); int result = TRUE; mad_synth_finish(&d->synth); mad_frame_finish(&d->frame); mad_stream_finish(&d->stream); #if defined(HAVE_MMAP) if (d->input.fdm) { if (unmap_file(d->input.fdm, d->input.length) == -1) { // odebug << "error munmapping file" << oendl; result = FALSE; } d->input.fdm = 0; d->input.data = 0; } #endif if (d->input.data) { free(d->input.data); d->input.data = 0; } if (::close(d->input.fd) == -1) { // odebug << "error closing file " << d->input.path << "" << oendl; result = FALSE; } d->input.fd = 0; return result; } bool LibMadPlugin::isOpen() { debugMsg( "LibMadPlugin::isOpen" ); return ( d->input.fd != 0 ); } int LibMadPlugin::audioStreams() { debugMsg( "LibMadPlugin::audioStreams" ); return 1; } int LibMadPlugin::audioChannels( int ) { debugMsg( "LibMadPlugin::audioChannels" ); /* long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); odebug << "LibMadPlugin::audioChannels: " << d->frame.header.mode > 0 ? 2 : 1 << "" << oendl; return d->frame.header.mode > 0 ? 2 : 1; */ return 2; } int LibMadPlugin::audioFrequency( int ) { debugMsg( "LibMadPlugin::audioFrequency" ); long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); // odebug << "LibMadPlugin::audioFrequency: " << d->frame.header.samplerate << "" << oendl; return d->frame.header.samplerate; } int LibMadPlugin::audioSamples( int ) { debugMsg( "LibMadPlugin::audioSamples" ); long t; short t1[5]; audioReadSamples( t1, 2, 1, t, 0 ); mad_header_decode( (struct mad_header *)&d->frame.header, &d->stream ); /* odebug << "LibMadPlugin::audioSamples: " << d->frame.header.duration.seconds << "*" << d->frame.header.samplerate << oendl; return d->frame.header.duration.seconds * d->frame.header.samplerate; */ if ( d->frame.header.bitrate == 0 ) return 0; int samples = (d->input.fileLength / (d->frame.header.bitrate/8)) * d->frame.header.samplerate; - // qDebug( "LibMadPlugin::audioSamples: %i * %i * 8 / %i", (int)d->input.fileLength, - // (int)d->frame.header.samplerate, (int)d->frame.header.bitrate ); + // odebug << "LibMadPlugin::audioSamples: " << (int)d->input.fileLength + // << " * " << (int)d->frame.header.samplerate << " * 8 / " << (int)d->frame.header.bitrate << oendl; // odebug << "LibMadPlugin::audioSamples: " << samples << "" << oendl; return samples; // return 10000000; } bool LibMadPlugin::audioSetSample( long, int ) { debugMsg( "LibMadPlugin::audioSetSample" ); // long totalSamples = audioSamples(0); // if ( totalSamples <= 1 ) // return FALSE; // // Seek to requested position // odebug << "seek pos: " << (int)((double)pos * d->input.fileLength / totalSamples) << "" << oendl; // ::lseek( d->input.fd, (long)((double)pos * d->input.fileLength / totalSamples), SEEK_SET ); // mad_stream_sync(&d->stream); // mad_stream_init(&d->stream); // mad_frame_init(&d->frame); // mad_synth_init(&d->synth); // return TRUE; debugMsg( "LibMadPlugin::audioSetSample" ); return FALSE; } long LibMadPlugin::audioGetSample( int ) { debugMsg( "LibMadPlugin::audioGetSample" ); return 0; } /* bool LibMadPlugin::audioReadSamples( short *, int, long, int ) { debugMsg( "LibMadPlugin::audioReadSamples" ); return FALSE; } bool LibMadPlugin::audioReReadSamples( short *, int, long, int ) { debugMsg( "LibMadPlugin::audioReReadSamples" ); return FALSE; } */ bool LibMadPlugin::read() { debugMsg( "LibMadPlugin::read" ); int len; if (d->input.eof) return FALSE; #if defined(HAVE_MMAP) if (d->input.fdm) { unsigned long skip = 0; if (d->stream.next_frame) { struct stat stat; if (fstat(d->input.fd, &stat) == -1) return FALSE; if (stat.st_size + MAD_BUFFER_GUARD <= (signed)d->input.length) return FALSE; // file size changed; update memory map skip = d->stream.next_frame - d->input.data; if (unmap_file(d->input.fdm, d->input.length) == -1) { d->input.fdm = 0; d->input.data = 0; return FALSE; } d->input.length = stat.st_size; d->input.fdm = map_file(d->input.fd, &d->input.length); if (d->input.fdm == 0) { d->input.data = 0; return FALSE; } d->input.data = (unsigned char *)d->input.fdm; } mad_stream_buffer(&d->stream, d->input.data + skip, d->input.length - skip); } else #endif { if (d->stream.next_frame) { memmove(d->input.data, d->stream.next_frame, d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |