[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [qtopenal] src: Better support for things, like sample rate,
From:       Laszlo Papp <ext-laszlo.papp () nokia ! com>
Date:       2011-12-05 21:54:07
Message-ID: 20111205215407.AB556A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit bdae4e5eca0945a96b7012007dbf56ba848d98ca by Laszlo Papp.
Committed on 06/12/2011 at 00:53.
Pushed by lpapp into branch 'master'.

Better support for things, like sample rate, channels getters, error management

M  +2    -0    src/CMakeLists.txt
M  +18   -12   src/qalvorbisfileaudiodecoder.cpp

http://commits.kde.org/qtopenal/bdae4e5eca0945a96b7012007dbf56ba848d98ca

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 138c104..480c278 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,6 +51,7 @@ set(QtOpenAL_SRCS
     qalcontext.cpp
     qalsndaudiodecoder.cpp
     qalsource.cpp
+    qalvorbisfileaudiodecoder.cpp
 )
 
 set(QtOpenAL_HEADERS
@@ -61,6 +62,7 @@ set(QtOpenAL_HEADERS
     qalcontext.h
     qalsndaudiodecoder.h
     qalsource.h
+    qalvorbisfileaudiodecoder.h
 	${CMAKE_CURRENT_BINARY_DIR}/qtopenal_global.h
 )
 
diff --git a/src/qalvorbisfileaudiodecoder.cpp b/src/qalvorbisfileaudiodecoder.cpp
index 8930eab..5c9c104 100644
--- a/src/qalvorbisfileaudiodecoder.cpp
+++ b/src/qalvorbisfileaudiodecoder.cpp
@@ -46,13 +46,15 @@ class QALVorbisFileAudioDecoder::Private
         QFile file;
 
         QByteArray encodedData;
-        OggVorbis_File* oggVorbisFile;
+        OggVorbis_File *oggVorbisFile;
+        vorbis_info vorbisInfo;
 };
 
 int
 QALVorbisFileAudioDecoder::Private::closeCallback(void *datasource)
 {
     reinterpret_cast<QALVorbisFileAudioDecoder::Private*>(datasource)->file.close();
+
     return 0;
 }
 
@@ -129,17 +131,19 @@ QALVorbisFileAudioDecoder::open(const QString &fileName)
     d->file.setFileName(fileName);
 
     ov_callbacks oggVorbisCallbacks;
-    oggVorbisCallbacks.close_func = &d->fileLengthCallback;
-    oggVorbisCallbacks.seek_func = &d->seekCallback;
+    oggVorbisCallbacks.close_func = &d->closeCallback;
     oggVorbisCallbacks.read_func = &d->readCallback;
+    oggVorbisCallbacks.seek_func = &d->seekCallback;
     oggVorbisCallbacks.tell_func = &d->tellCallback;
 
-    int error = 0;
-    if ((error = ov_open_callbacks(d, d->oggVorbisFile, 0, 0, &oggVofbisCallback) < \
0)) { +    int error;
+    if ((error = ov_open_callbacks(d, d->oggVorbisFile, 0, 0, oggVorbisCallbacks) < \
                0)) {
         qWarning() << Q_FUNC_INFO << "Failed to open the file" << \
fileName.toUtf8().constData() << "for decoding:" << error;  return false;
     }
 
+    d->vorbisInfo = *ov_info(d->oggVorbisFile, -1);
+
     return true;
 }
 
@@ -157,8 +161,9 @@ QALVorbisFileAudioDecoder::pos()
 bool
 QALVorbisFileAudioDecoder::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); +    int error;
+    if ((error = sf_seek(d->sndFile, pos, SEEK_SET) == -1)) {
+        qWarning() << Q_FUNC_INFO << "Failed to seek in the file:" << error;
         return false;
     }
 
@@ -168,8 +173,9 @@ QALVorbisFileAudioDecoder::seek(qint64 pos)
 bool
 QALVorbisFileAudioDecoder::close()
 {
-    if (ov_clear(d->oggVorbisFile)) {
-        qWarning() << Q_FUNC_INFO << "Failed to close the file:" <<  \
sf_strerror(d->sndFile); +    int error;
+    if ((error = ov_clear(d->oggVorbisFile))) {
+        qWarning() << Q_FUNC_INFO << "Failed to close the file:" << error;
         return false;
     }
 
@@ -185,19 +191,19 @@ QALVorbisFileAudioDecoder::setEncodedData(const QByteArray \
&encodedData)  int
 QALVorbisFileAudioDecoder::channels() const
 {
-    return d->sfInfo.channels;
+    return d->vorbisInfo.channels;
 }
 
 int
 QALVorbisFileAudioDecoder::sampleRate() const
 {
-    return d->sfInfo.samplerate;
+    return d->vorbisInfo.rate;
 }
 
 int
 QALVorbisFileAudioDecoder::sampleSize() const
 {
-    return 16;
+    return d->vorbisInfo.bitrate_nominal;
 }
 
 QByteArray


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic