summaryrefslogtreecommitdiffstats
path: root/src/audio/oal/channel.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-05-17 16:45:56 +0200
committerSergeanur <s.anureev@yandex.ua>2021-05-17 16:46:33 +0200
commit0c41734c20527b348f8b20a35f25fdfc0957c848 (patch)
tree1cb29ec4ad0ad9abf374cf5768a64ed829e4f277 /src/audio/oal/channel.cpp
parentFix oneshot audio crash (diff)
downloadre3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar.gz
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar.bz2
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar.lz
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar.xz
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.tar.zst
re3-0c41734c20527b348f8b20a35f25fdfc0957c848.zip
Diffstat (limited to 'src/audio/oal/channel.cpp')
-rw-r--r--src/audio/oal/channel.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp
index d1fd0aea..1bb4c4a8 100644
--- a/src/audio/oal/channel.cpp
+++ b/src/audio/oal/channel.cpp
@@ -17,6 +17,8 @@ bool bChannelsCreated = false;
int32 CChannel::channelsThatNeedService = 0;
+uint8 tempStereoBuffer[PED_BLOCKSIZE * 2];
+
void
CChannel::InitChannels()
{
@@ -50,6 +52,7 @@ CChannel::CChannel()
{
Data = nil;
DataSize = 0;
+ bIs2D = false;
SetDefault();
}
@@ -90,6 +93,7 @@ void CChannel::Init(uint32 _id, bool Is2D)
if ( Is2D )
{
+ bIs2D = true;
alSource3f(alSources[id], AL_POSITION, 0.0f, 0.0f, 0.0f);
alSourcef(alSources[id], AL_GAIN, 1.0f);
}
@@ -113,7 +117,20 @@ void CChannel::Start()
if ( !HasSource() ) return;
if ( !Data ) return;
- alBufferData(alBuffers[id], AL_FORMAT_MONO16, Data, DataSize, Frequency);
+ if ( bIs2D )
+ {
+ // convert mono data to stereo
+ int16 *monoData = (int16*)Data;
+ int16 *stereoData = (int16*)tempStereoBuffer;
+ for (size_t i = 0; i < DataSize / 2; i++)
+ {
+ *(stereoData++) = *monoData;
+ *(stereoData++) = *(monoData++);
+ }
+ alBufferData(alBuffers[id], AL_FORMAT_STEREO16, tempStereoBuffer, DataSize * 2, Frequency);
+ }
+ else
+ alBufferData(alBuffers[id], AL_FORMAT_MONO16, Data, DataSize, Frequency);
if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 )
alBufferiv(alBuffers[id], AL_LOOP_POINTS_SOFT, LoopPoints);
alSourcei(alSources[id], AL_BUFFER, alBuffers[id]);