summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2011-12-07 20:16:34 +0200
committerLaszlo Papp <ext-laszlo.papp@nokia.com>2011-12-07 20:16:34 +0200
commitd907f8979c6a5b26d265dea977b03631d7151773 (patch)
treec66135ba5755394f4e526edf3166c019ab0574b1
parent5878c8819fbe009fe6af85e3133692c55e50f066 (diff)
Extend the lengthCallback with proper error management and warning message
-rw-r--r--src/decoders/qalflacaudiodecoder.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/decoders/qalflacaudiodecoder.cpp b/src/decoders/qalflacaudiodecoder.cpp
index 411134c..4be6377 100644
--- a/src/decoders/qalflacaudiodecoder.cpp
+++ b/src/decoders/qalflacaudiodecoder.cpp
@@ -109,7 +109,15 @@ QALFlacAudioDecoder::Private::lengthCallback(const FLAC__StreamDecoder *decoder,
{
Q_UNUSED(decoder)
- *stream_length = reinterpret_cast<QALFlacAudioDecoder::Private*>(client_data)->file.size();
+ QFile &tmpFile = reinterpret_cast<QALFlacAudioDecoder::Private*>(client_data)->file;
+ tmpFile.unsetError();
+
+ *stream_length = tmpFile.size();
+
+ if (tmpFile.error() != QFile::NoError) {
+ qWarning() << Q_FUNC_INFO << "Failed to get the total length of the stream in bytes:" << tmpFile.errorString();
+ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
+ }
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
}