summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2011-12-07 19:15:38 +0200
committerLaszlo Papp <ext-laszlo.papp@nokia.com>2011-12-07 19:15:38 +0200
commitfe633ce503d5b64fc0676d2325a607a7c617a55b (patch)
tree687139e5ea2d5290963d054fc41bb3d93142a877
parenta6ded3a69f9341c2717df9fa0f511741e660c058 (diff)
Implement the initial version of the readCallback inside the flac decoder
-rw-r--r--src/decoders/qalflacaudiodecoder.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/decoders/qalflacaudiodecoder.cpp b/src/decoders/qalflacaudiodecoder.cpp
index 19d0645..8e94a57 100644
--- a/src/decoders/qalflacaudiodecoder.cpp
+++ b/src/decoders/qalflacaudiodecoder.cpp
@@ -56,7 +56,21 @@ class QALFlacAudioDecoder::Private
FLAC__StreamDecoderReadStatus
QALFlacAudioDecoder::Private::readCallback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
{
- return reinterpret_cast<QALFlacAudioDecoder::Private*>(client_data)->file.read(reinterpret_cast<char*>(ptr), count);
+ Q_UNUSED(decoder)
+
+ if (*bytes <= 0)
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+
+ int retval;
+ if ((retval = reinterpret_cast<QALFlacAudioDecoder::Private*>(client_data)->file.read(reinterpret_cast<char*>(buffer), *bytes)) == -1) {
+ qWarning() << Q_FUNC_INFO << "Failed to read the data from the file";
+ return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+ }
+
+ if (retval != 0)
+ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+
+ return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
}
FLAC__StreamDecoderSeekStatus