diff options
author | Laszlo Papp <lpapp@kde.org> | 2011-12-07 19:43:44 +0200 |
---|---|---|
committer | Laszlo Papp <ext-laszlo.papp@nokia.com> | 2011-12-07 19:43:44 +0200 |
commit | 5f51d33b66d39da263e64c15024ded46ebeba93a (patch) | |
tree | 09e06f56a8384f3a218f5259bd77197e5b4df895 | |
parent | fee74bff2095b18bfdf445418ddec287612a899b (diff) |
Clean up and implement the pos() method of the qalflacaudiodecoder class
-rw-r--r-- | src/decoders/qalflacaudiodecoder.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/decoders/qalflacaudiodecoder.cpp b/src/decoders/qalflacaudiodecoder.cpp index 205959a..3c1ee4b 100644 --- a/src/decoders/qalflacaudiodecoder.cpp +++ b/src/decoders/qalflacaudiodecoder.cpp @@ -168,7 +168,7 @@ QALFlacAudioDecoder::open(const QString &fileName) { d->file.setFileName(fileName); - d->flacStreamDecoder = *FLAC__stream_decoder_new(); + d->flacStreamDecoder = FLAC__stream_decoder_new(); if (d->flacStreamDecoder == 0) { qWarning() << Q_FUNC_INFO << "Could not allocate enough memory for the flac stream decoder handle"; return false; @@ -184,25 +184,18 @@ QALFlacAudioDecoder::open(const QString &fileName) return; } - FLAC__stream_decoder_finish(flacFile); + FLAC__stream_decoder_finish(d->flacStreamDecoder); } - if ((d->sndFile = sf_open_virtual(&sfVirtualIO, SFM_READ, &sfInfo, d)) == 0) { - qWarning() << Q_FUNC_INFO << "Failed to open the file" << fileName.toUtf8().constData() << "for decoding:" << sf_strerror(d->sndFile); - return false; - } - - d->sfInfo = sfInfo; - return true; } qint64 QALFlacAudioDecoder::pos() { - int position; - if ((position = sf_seek(d->sndFile, 0, SEEK_CUR)) == -1) { - qWarning() << Q_FUNC_INFO << "Failed to tell the current position:" << sf_strerror(d->sndFile); + FLAC__uint64 position; + if (FLAC__stream_decoder_get_decode_position(d->flacStreamDecoder, &position) == false) { + qWarning() << Q_FUNC_INFO << "Failed to tell the current position"; } return position; |