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

List:       kde-commits
Subject:    [qtopenal] src: Implement the alBufferData and format calculation
From:       Laszlo Papp <ext-laszlo.papp () nokia ! com>
Date:       2011-11-30 23:53:01
Message-ID: 20111130235301.7C3FFA60BE () git ! kde ! org
[Download RAW message or body]

Git commit 583ef6078872fdc2ee621383d2909e34cbc0cdfd by Laszlo Papp.
Committed on 01/12/2011 at 02:49.
Pushed by lpapp into branch 'master'.

Implement the alBufferData and format calculation operations in the context

M  +19   -2    src/qalcontext.cpp

http://commits.kde.org/qtopenal/583ef6078872fdc2ee621383d2909e34cbc0cdfd

diff --git a/src/qalcontext.cpp b/src/qalcontext.cpp
index 20c50a4..4b092a4 100644
--- a/src/qalcontext.cpp
+++ b/src/qalcontext.cpp
@@ -189,9 +189,10 @@ QALContext::cacheBuffer(const QString& filename)
 
         QByteArray decodedData;
         QByteArray tmpData;
-        int maxlen = qalSndAudioDecoder.channels() * qalSndAudioDecoder.sampleRate() \
* qalSndAudioDecode.sampleSize(); +        int maxlen = qalSndAudioDecoder.channels() \
* qalSndAudioDecoder.sampleRate() * qalSndAudioDecoder.sampleSize();  
-        while ((tmpData = qalSndAudioDecoder.decode(maxlen))) {
+        forever {
+            tmpData = qalSndAudioDecoder.decode(maxlen);
             decodedData.append(tmpData);
             if (tmpData.size() != maxlen)
                 break;
@@ -209,7 +210,23 @@ QALContext::cacheBuffer(const QString& filename)
             return 0;
         };
 
+        int channels = qalSndAudioDecoder.channels();
+        int sampleSize = qalSndAudioDecoder.sampleSize();
+        ALenum format;
+
+        if (channels == 1) {
+            if (sampleSize == 8)
+                format = AL_FORMAT_MONO8;
+            else if (sampleSize == 16)
+                format = AL_FORMAT_MONO16;
+        } else if (channels == 2) {
+            if (sampleSize == 8)
+                format = AL_FORMAT_STEREO8;
+            else if (sampleSize == 16)
+                format = AL_FORMAT_STEREO16;
+        }
 
+        alBufferData(buffer, format, reinterpret_cast<const \
ALvoid*>(decodedData.constData()), decodedData.size(), \
qalSndAudioDecoder.sampleRate());  
         d->loadedBuffers.insert(filename, buffer);
     }


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

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