diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-04-01 18:02:28 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-04-01 18:02:28 +0000 |
| commit | 6429b8e08efe1b23e0a766ca15ec4f65424c2ff4 (patch) | |
| tree | 4f2bd8c8c44eebb40c5c545ccbca6e703b59fafd /src/plugins | |
| parent | 9c09ee9d873542bb5bed8a8c334f68ba9d84351f (diff) | |
| download | qmmp-6429b8e08efe1b23e0a766ca15ec4f65424c2ff4.tar.gz qmmp-6429b8e08efe1b23e0a766ca15ec4f65424c2ff4.tar.bz2 qmmp-6429b8e08efe1b23e0a766ca15ec4f65424c2ff4.zip | |
some core fixes and improvements
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@886 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/Input/mad/decoder_mad.cpp | 28 | ||||
| -rw-r--r-- | src/plugins/Output/alsa/outputalsa.cpp | 5 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp index 095d80371..578fc2ab0 100644 --- a/src/plugins/Input/mad/decoder_mad.cpp +++ b/src/plugins/Input/mad/decoder_mad.cpp @@ -18,7 +18,8 @@ #include <math.h> #include <stdio.h> -# define XING_MAGIC (('X' << 24) | ('i' << 16) | ('n' << 8) | 'g') +#define XING_MAGIC (('X' << 24) | ('i' << 16) | ('n' << 8) | 'g') +#define INPUT_BUFFER_SIZE (32*1024) DecoderMAD::DecoderMAD(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o) @@ -95,7 +96,7 @@ bool DecoderMAD::initialize() } if (! input_buf) - input_buf = new char[globalBufferSize]; + input_buf = new char[INPUT_BUFFER_SIZE]; if (! output_buf) output_buf = new char[globalBufferSize]; @@ -247,7 +248,7 @@ bool DecoderMAD::findHeader() memmove (input_buf, stream.next_frame, remaining); } - input_bytes = input()->read(input_buf + remaining, globalBufferSize - remaining); + input_bytes = input()->read(input_buf + remaining, INPUT_BUFFER_SIZE - remaining); if (input_bytes <= 0) break; @@ -358,12 +359,11 @@ void DecoderMAD::stop() void DecoderMAD::flush(bool final) { ulong min = final ? 0 : bks; - - while ((! done && ! m_finish) && output_bytes > min && seekTime == -1.) + while (!done && (output_bytes > min) && seekTime == -1.) { output()->recycler()->mutex()->lock(); - while ((! done && ! m_finish) && output()->recycler()->full()) + while (!done && output()->recycler()->full()) { mutex()->unlock(); output()->recycler()->cond()->wait(output()->recycler()->mutex()); @@ -372,7 +372,7 @@ void DecoderMAD::flush(bool final) done = user_stop; } - if (user_stop || m_finish) + if (user_stop) { inited = FALSE; done = TRUE; @@ -395,7 +395,7 @@ void DecoderMAD::flush(bool final) void DecoderMAD::run() { - int skip_frames = 0; //skip first frame + int skip_frames = 0; mutex()->lock(); if (! inited) @@ -427,7 +427,6 @@ void DecoderMAD::run() eof = false; seekTime = -1; } - m_finish = eof; if (! eof) @@ -438,10 +437,10 @@ void DecoderMAD::run() memmove(input_buf, stream.next_frame, input_bytes); } - if (input_bytes < globalBufferSize) + if (stream.error == MAD_ERROR_BUFLEN) { int len = input()->read((char *) input_buf + input_bytes, - globalBufferSize - input_bytes); + INPUT_BUFFER_SIZE - input_bytes); if (len == 0) { @@ -482,6 +481,9 @@ void DecoderMAD::run() if (stream.error == MAD_ERROR_BUFLEN) break; + if (stream.error == MAD_ERROR_BUFLEN) + continue; + // error in decoding if (!MAD_RECOVERABLE(stream.error)) { @@ -513,7 +515,7 @@ void DecoderMAD::run() mutex()->lock(); - if (! user_stop && eof) + if (!user_stop && eof) { flush(TRUE); @@ -532,7 +534,7 @@ void DecoderMAD::run() } done = TRUE; - if (! user_stop) + if (!user_stop) m_finish = TRUE; } diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp index 5e9c02938..6ed462e16 100644 --- a/src/plugins/Output/alsa/outputalsa.cpp +++ b/src/plugins/Output/alsa/outputalsa.cpp @@ -271,6 +271,7 @@ void OutputALSA::flush() { snd_pcm_uframes_t l = snd_pcm_bytes_to_frames(pcm_handle, m_prebuf_fill); long m; + l = snd_pcm_bytes_to_frames(pcm_handle, l); while (l > 0) { if ((m = alsa_write(m_prebuf, l)) >= 0) @@ -283,6 +284,9 @@ void OutputALSA::flush() else break; } + snd_pcm_nonblock(pcm_handle, 0); + snd_pcm_drain(pcm_handle); + snd_pcm_nonblock(pcm_handle, 1); } long OutputALSA::alsa_write(unsigned char *data, long size) @@ -340,6 +344,7 @@ long OutputALSA::alsa_write(unsigned char *data, long size) } return 0; } + qDebug ("OutputALSA: error: %s", snd_strerror(m)); return -1; } |
