author | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-10 19:13:40 (UTC) |
commit | 9237a75548f9b932fbb1900d8ea28dbee9da81ac (patch) (side-by-side diff) | |
tree | a0249408df5ce581af8bcee5b6f58bcee1db461a /core/multimedia/opieplayer/libmad | |
parent | 11d754ffa429875b526c49f125d8a844c5cda3d8 (diff) | |
download | opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.zip opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.gz opie-9237a75548f9b932fbb1900d8ea28dbee9da81ac.tar.bz2 |
bug fix
Diffstat (limited to 'core/multimedia/opieplayer/libmad') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index 9f8ba65..8ede537 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -27,31 +27,33 @@ #include <string.h> #include <ctype.h> #include <errno.h> #include <time.h> #include <locale.h> #include <math.h> #include <assert.h> #include <qapplication.h> +#include <qpe/config.h> //#define HAVE_MMAP #if defined(HAVE_MMAP) # include <sys/mman.h> #endif #include "libmadplugin.h" extern "C" { #include "mad.h" } #define MPEG_BUFFER_SIZE 65536 +//#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 //#define debugMsg(a) qDebug(a) #define debugMsg(a) class Input { public: char const *path; int fd; @@ -160,17 +162,20 @@ bool LibMadPlugin::isFileSupported( const QString& path ) { } return FALSE; } bool LibMadPlugin::open( const QString& path ) { debugMsg( "LibMadPlugin::open" ); - + Config cfg("MediaPlayer"); + cfg.setGroup("Options"); + bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); + qDebug("buffer size is %d", bufferSize); d->bad_last_frame = 0; d->flush = TRUE; info = QString( "" ); //qDebug( "Opening %s", path.latin1() ); d->input.path = path.latin1(); d->input.fd = ::open( d->input.path, O_RDONLY ); @@ -192,17 +197,17 @@ bool LibMadPlugin::open( const QString& path ) { if (d->input.fdm == 0) { qDebug("error mmapping file"); return FALSE; } d->input.data = (unsigned char *)d->input.fdm; } #endif if (d->input.data == 0) { - d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); + d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); if (d->input.data == 0) { qDebug("error allocating input buffer"); return FALSE; } d->input.length = 0; } d->input.eof = 0; @@ -364,28 +369,28 @@ bool LibMadPlugin::read() { #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); } do { - len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); + len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); } while (len == -1 && errno == EINTR); if (len == -1) { qDebug("error reading audio"); return FALSE; } else if (len == 0) { d->input.eof = 1; - assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); + assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); while (len < MAD_BUFFER_GUARD) d->input.data[d->input.length + len++] = 0; } mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); } diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index b240b77..46cd4a1 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h @@ -98,13 +98,13 @@ public: bool supportsStereo() { return TRUE; } bool supportsScaling() { return FALSE; } long getPlayTime() { return -1; } private: LibMadPluginData *d; QString info; - +int bufferSize; }; #endif |