From d907f8979c6a5b26d265dea977b03631d7151773 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Wed, 7 Dec 2011 20:16:34 +0200 Subject: Extend the lengthCallback with proper error management and warning message --- src/decoders/qalflacaudiodecoder.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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(client_data)->file.size(); + QFile &tmpFile = reinterpret_cast(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; } -- cgit v1.2.3