From 13c2dd71155f50f1d9690d32e6d63092cc82a781 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 18 Dec 2014 08:42:03 -0800 Subject: [PATCH] Offset to the buffer's channel start first --- Alc/mixer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Alc/mixer.c b/Alc/mixer.c index bce9b14f..b6cb19c7 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -293,6 +293,9 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam ALuint DataSize; ALuint pos; + /* Offset to current channel */ + Data += chan*SampleSize; + /* If current pos is beyond the loop range, do not loop */ if(Looping == AL_FALSE || DataPosInt >= (ALuint)ALBuffer->LoopEnd) { @@ -315,7 +318,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam * rest of the temp buffer */ DataSize = minu(SrcBufferSize - SrcDataSize, ALBuffer->SampleLen - pos); - LoadSamples(&SrcData[SrcDataSize], &Data[(pos*NumChannels + chan)*SampleSize], + LoadSamples(&SrcData[SrcDataSize], &Data[pos * NumChannels*SampleSize], NumChannels, ALBuffer->FmtType, DataSize); SrcDataSize += DataSize; @@ -353,7 +356,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam DataSize = LoopEnd - pos; DataSize = minu(SrcBufferSize - SrcDataSize, DataSize); - LoadSamples(&SrcData[SrcDataSize], &Data[(pos*NumChannels + chan)*SampleSize], + LoadSamples(&SrcData[SrcDataSize], &Data[pos * NumChannels*SampleSize], NumChannels, ALBuffer->FmtType, DataSize); SrcDataSize += DataSize; @@ -362,7 +365,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam { DataSize = minu(SrcBufferSize - SrcDataSize, DataSize); - LoadSamples(&SrcData[SrcDataSize], &Data[(LoopStart*NumChannels + chan)*SampleSize], + LoadSamples(&SrcData[SrcDataSize], &Data[LoopStart * NumChannels*SampleSize], NumChannels, ALBuffer->FmtType, DataSize); SrcDataSize += DataSize; } -- 2.11.4.GIT