diff options
author | Laszlo Papp <lpapp@kde.org> | 2011-12-13 23:53:12 +0200 |
---|---|---|
committer | Laszlo Papp <ext-laszlo.papp@nokia.com> | 2011-12-13 23:53:12 +0200 |
commit | 77b64f231144c0a93a9714dfdeca99dce029302a (patch) | |
tree | 2cc8538665e4d8f8cddc085b1be8a2a9057bcfc6 /src | |
parent | 3bb575a35f000cc2f25f84cea723ee5456afd5f5 (diff) |
Make a dirty and nasty hackaround for compilation, but needs to be revisited..
Diffstat (limited to 'src')
-rw-r--r-- | src/decoders/qalflacaudiodecoder.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/decoders/qalflacaudiodecoder.cpp b/src/decoders/qalflacaudiodecoder.cpp index c25ad03..5f854ce 100644 --- a/src/decoders/qalflacaudiodecoder.cpp +++ b/src/decoders/qalflacaudiodecoder.cpp @@ -23,6 +23,7 @@ #include <QtCore/QString> #include <QtCore/QUrl> #include <QtCore/QDebug> +#include <QtCore/QtGlobal> #include <FLAC/stream_decoder.h> @@ -263,12 +264,29 @@ qint64 QALFlacAudioDecoder::decodeData(char *decodedData, qint64 maxlen) { if (FLAC__stream_decoder_get_state(d->flacStreamDecoder) == FLAC__STREAM_DECODER_SEEK_ERROR - && FLAC__stream_decoder_reset(d->flacStreamDecoder) == false) + && FLAC__stream_decoder_reset(d->flacStreamDecoder) == false) { { qWarning() << Q_FUNC_INFO << "Failed to allocate memory while resetting before decoding";; return -1; } } - return sf_readf_short(d->sndFile, reinterpret_cast<short*>(decodedData), maxlen); + int tmplen = 0; + + if (d->initialData.size() > 0) + { + tmplen = qMin(qint64(d->initialData.size()), maxlen); + decodedData = reinterpret_cast<char*>(d->initialData.mid(0, tmplen).data()); + d->initialData.remove(0, tmplen); + } + + while (tmplen < maxlen) + { + if (FLAC__stream_decoder_process_single(d->flacStreamDecoder) == false + || FLAC__stream_decoder_get_state(d->flacStreamDecoder) == FLAC__STREAM_DECODER_END_OF_STREAM) { + break; + } + } + + return tmplen; } |