summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2011-12-07 17:50:03 +0200
committerLaszlo Papp <ext-laszlo.papp@nokia.com>2011-12-07 17:50:03 +0200
commit02e209b463a88ae00ec26c1865ebbcb07274e804 (patch)
tree833bfe54fd30d6d14bb0b344a103b7704a95bae9
parentf97bc18255fbf8331d2cd002ed8c7870a166aa2a (diff)
Implement the seeking in the flac decoder and add a state check before decoding
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/decoders/qalflacaudiodecoder.cpp12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 45068e1..a7a597f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,7 +51,7 @@ set(QtOpenAL_SRCS
qalcontext.cpp
qalsource.cpp
- decoders/qalmpg123audiodecoder.cpp
+ decoders/qalflacaudiodecoder.cpp
decoders/qalsndfileaudiodecoder.cpp
decoders/qalvorbisfileaudiodecoder.cpp
)
@@ -65,7 +65,7 @@ set(QtOpenAL_HEADERS
qalsource.h
${CMAKE_CURRENT_BINARY_DIR}/qtopenal_global.h
- decoders/qalmpg123audiodecoder.h
+ decoders/qalflacaudiodecoder.h
decoders/qalsndfileaudiodecoder.h
decoders/qalvorbisfileaudiodecoder.h
)
diff --git a/src/decoders/qalflacaudiodecoder.cpp b/src/decoders/qalflacaudiodecoder.cpp
index eb510cf..d6873ea 100644
--- a/src/decoders/qalflacaudiodecoder.cpp
+++ b/src/decoders/qalflacaudiodecoder.cpp
@@ -172,8 +172,8 @@ QALFlacAudioDecoder::pos()
bool
QALFlacAudioDecoder::seek(qint64 pos)
{
- if (sf_seek(d->sndFile, pos, SEEK_SET) == -1) {
- qWarning() << Q_FUNC_INFO << "Failed to seek in the file:" << sf_strerror(d->sndFile);
+ if (FLAC__stream_decoder_seek_absolute(d->flacStreamDecoder, pos) == false) {
+ qWarning() << Q_FUNC_INFO << "Failed to seek in the file";
return false;
}
@@ -230,5 +230,13 @@ QALFlacAudioDecoder::decode(qint64 maxlen)
qint64
QALFlacAudioDecoder::decode(char *decodedData, qint64 maxlen)
{
+ if (FLAC__stream_decoder_get_state(d->flacStreamDecoder) == FLAC__STREAM_DECODER_SEEK_ERROR
+ && FLAC__stream_decoder_reset(d->flacStreamDecoder) == false)
+ {
+ qWarning() << Q_FUNC_INFO << "Failed to allocate memory while resetting before decoding";;
+ return false;
+ }
+ }
+
return sf_readf_short(d->sndFile, reinterpret_cast<short*>(decodedData), maxlen);
}