Diffstat (limited to 'core/multimedia/opieplayer/libmad/libmadplugin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 13 |
1 files changed, 9 insertions, 4 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 | |||
@@ -29,12 +29,13 @@ | |||
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #include <locale.h> | 31 | #include <locale.h> |
32 | #include <math.h> | 32 | #include <math.h> |
33 | #include <assert.h> | 33 | #include <assert.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpe/config.h> | ||
35 | 36 | ||
36 | //#define HAVE_MMAP | 37 | //#define HAVE_MMAP |
37 | 38 | ||
38 | #if defined(HAVE_MMAP) | 39 | #if defined(HAVE_MMAP) |
39 | # include <sys/mman.h> | 40 | # include <sys/mman.h> |
40 | #endif | 41 | #endif |
@@ -44,12 +45,13 @@ | |||
44 | extern "C" { | 45 | extern "C" { |
45 | #include "mad.h" | 46 | #include "mad.h" |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | #define MPEG_BUFFER_SIZE 65536 | 50 | #define MPEG_BUFFER_SIZE 65536 |
51 | //#define MPEG_BUFFER_SIZE 32768 //16384 // 8192 | ||
50 | //#define debugMsg(a) qDebug(a) | 52 | //#define debugMsg(a) qDebug(a) |
51 | #define debugMsg(a) | 53 | #define debugMsg(a) |
52 | 54 | ||
53 | 55 | ||
54 | class Input { | 56 | class Input { |
55 | public: | 57 | public: |
@@ -162,13 +164,16 @@ bool LibMadPlugin::isFileSupported( const QString& path ) { | |||
162 | return FALSE; | 164 | return FALSE; |
163 | } | 165 | } |
164 | 166 | ||
165 | 167 | ||
166 | bool LibMadPlugin::open( const QString& path ) { | 168 | bool LibMadPlugin::open( const QString& path ) { |
167 | debugMsg( "LibMadPlugin::open" ); | 169 | debugMsg( "LibMadPlugin::open" ); |
168 | 170 | Config cfg("MediaPlayer"); | |
171 | cfg.setGroup("Options"); | ||
172 | bufferSize = cfg.readNumEntry("MPeg_BufferSize",MPEG_BUFFER_SIZE); | ||
173 | qDebug("buffer size is %d", bufferSize); | ||
169 | d->bad_last_frame = 0; | 174 | d->bad_last_frame = 0; |
170 | d->flush = TRUE; | 175 | d->flush = TRUE; |
171 | info = QString( "" ); | 176 | info = QString( "" ); |
172 | 177 | ||
173 | //qDebug( "Opening %s", path.latin1() ); | 178 | //qDebug( "Opening %s", path.latin1() ); |
174 | 179 | ||
@@ -194,13 +199,13 @@ bool LibMadPlugin::open( const QString& path ) { | |||
194 | } | 199 | } |
195 | d->input.data = (unsigned char *)d->input.fdm; | 200 | d->input.data = (unsigned char *)d->input.fdm; |
196 | } | 201 | } |
197 | #endif | 202 | #endif |
198 | 203 | ||
199 | if (d->input.data == 0) { | 204 | if (d->input.data == 0) { |
200 | d->input.data = (unsigned char *)malloc(MPEG_BUFFER_SIZE); | 205 | d->input.data = (unsigned char *)malloc( bufferSize /*MPEG_BUFFER_SIZE*/); |
201 | if (d->input.data == 0) { | 206 | if (d->input.data == 0) { |
202 | qDebug("error allocating input buffer"); | 207 | qDebug("error allocating input buffer"); |
203 | return FALSE; | 208 | return FALSE; |
204 | } | 209 | } |
205 | d->input.length = 0; | 210 | d->input.length = 0; |
206 | } | 211 | } |
@@ -366,24 +371,24 @@ bool LibMadPlugin::read() { | |||
366 | if (d->stream.next_frame) { | 371 | if (d->stream.next_frame) { |
367 | memmove(d->input.data, d->stream.next_frame, | 372 | memmove(d->input.data, d->stream.next_frame, |
368 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); | 373 | d->input.length = &d->input.data[d->input.length] - d->stream.next_frame); |
369 | } | 374 | } |
370 | 375 | ||
371 | do { | 376 | do { |
372 | len = ::read(d->input.fd, d->input.data + d->input.length, MPEG_BUFFER_SIZE - d->input.length); | 377 | len = ::read(d->input.fd, d->input.data + d->input.length, bufferSize /* MPEG_BUFFER_SIZE*/ - d->input.length); |
373 | } | 378 | } |
374 | while (len == -1 && errno == EINTR); | 379 | while (len == -1 && errno == EINTR); |
375 | 380 | ||
376 | if (len == -1) { | 381 | if (len == -1) { |
377 | qDebug("error reading audio"); | 382 | qDebug("error reading audio"); |
378 | return FALSE; | 383 | return FALSE; |
379 | } | 384 | } |
380 | else if (len == 0) { | 385 | else if (len == 0) { |
381 | d->input.eof = 1; | 386 | d->input.eof = 1; |
382 | 387 | ||
383 | assert(MPEG_BUFFER_SIZE - d->input.length >= MAD_BUFFER_GUARD); | 388 | assert(bufferSize /*MPEG_BUFFER_SIZE*/ - d->input.length >= MAD_BUFFER_GUARD); |
384 | 389 | ||
385 | while (len < MAD_BUFFER_GUARD) | 390 | while (len < MAD_BUFFER_GUARD) |
386 | d->input.data[d->input.length + len++] = 0; | 391 | d->input.data[d->input.length + len++] = 0; |
387 | } | 392 | } |
388 | 393 | ||
389 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); | 394 | mad_stream_buffer(&d->stream, d->input.data, d->input.length += len); |