summaryrefslogtreecommitdiffstats
path: root/src/audio
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-05-17 16:45:56 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-24 20:32:43 +0200
commit4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435 (patch)
treec541a4f1e6f903319b0418b39af6be2e80157990 /src/audio
parentMake gang members react to sexy females (diff)
downloadre3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar.gz
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar.bz2
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar.lz
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar.xz
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.tar.zst
re3-4a9d890ae9e54a3f4c6b7420ee140fbfecb8a435.zip
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/oal/channel.cpp19
-rw-r--r--src/audio/oal/channel.h1
2 files changed, 19 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]);
diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h
index b081be25..872646c8 100644
--- a/src/audio/oal/channel.h
+++ b/src/audio/oal/channel.h
@@ -20,6 +20,7 @@ class CChannel
int32 LoopCount;
ALint LoopPoints[2];
ALint LastProcessedOffset;
+ bool bIs2D;
public:
static int32 channelsThatNeedService;