mirror of
https://github.com/edubart/otclient.git
synced 2025-10-24 00:05:02 +02:00
get stereo audo working on linux
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
#include "soundbuffer.h"
|
||||
#include "soundfile.h"
|
||||
|
||||
#include <framework/util/databuffer.h>
|
||||
|
||||
SoundBuffer::SoundBuffer()
|
||||
{
|
||||
m_bufferId = 0;
|
||||
@@ -38,7 +36,7 @@ SoundBuffer::~SoundBuffer()
|
||||
assert(alGetError() == AL_NO_ERROR);
|
||||
}
|
||||
|
||||
bool SoundBuffer::loadSoundFile(const SoundFilePtr& soundFile)
|
||||
bool SoundBuffer::fillBuffer(const SoundFilePtr& soundFile)
|
||||
{
|
||||
ALenum format = soundFile->getSampleFormat();
|
||||
if(format == AL_UNDETERMINED) {
|
||||
@@ -53,12 +51,16 @@ bool SoundBuffer::loadSoundFile(const SoundFilePtr& soundFile)
|
||||
return false;
|
||||
}
|
||||
|
||||
alBufferData(m_bufferId, format, &samples[0], soundFile->getSize(), soundFile->getRate());
|
||||
return fillBuffer(format, samples, samples.size(), soundFile->getRate());
|
||||
}
|
||||
|
||||
bool SoundBuffer::fillBuffer(ALenum sampleFormat, const DataBuffer<char>& data, int size, int rate)
|
||||
{
|
||||
alBufferData(m_bufferId, sampleFormat, &data[0], size, rate);
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR) {
|
||||
logError("unable to fill audio buffer data for '", soundFile->getName(), "': ", alGetString(err));
|
||||
logError("unable to fill audio buffer data: ", alGetString(err));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user