aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-07-22 08:11:44 -0700
committerChris Robinson <[email protected]>2010-07-22 08:11:44 -0700
commit7eb124d99c2cde0ba27c90d01176b34249958974 (patch)
treedea8e97dc5eb3e0985785fd66943d9267a19d61e /Alc
parent88f236ccd3f2e75d0823414e8c9a4492ddbd2539 (diff)
Keep count of the number of samples played
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c9
-rw-r--r--Alc/ALu.c1
2 files changed, 10 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 02e04e58..0cdb9da8 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1453,6 +1453,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
{
ALCcontext *ALContext;
ALboolean running;
+ ALuint oldRate;
ALuint attrIdx;
void *temp;
ALuint i;
@@ -1467,6 +1468,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
}
running = ((device->NumContexts > 0) ? AL_TRUE : AL_FALSE);
+ oldRate = device->Frequency;
// Reset Context Last Error code
device->LastError = ALC_NO_ERROR;
@@ -1540,6 +1542,11 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
}
aluInitPanning(device);
+ // Scale the number of samples played according to the new sample rate
+ device->SamplesPlayed *= device->Frequency;
+ device->SamplesPlayed += oldRate-1;
+ device->SamplesPlayed /= oldRate;
+
for(i = 0;i < device->NumContexts;i++)
{
ALCcontext *context = device->Contexts[i];
@@ -1986,6 +1993,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->Contexts = NULL;
device->NumContexts = 0;
+ device->SamplesPlayed = 0;
+
InitUIntMap(&device->BufferMap);
InitUIntMap(&device->EffectMap);
InitUIntMap(&device->FilterMap);
diff --git a/Alc/ALu.c b/Alc/ALu.c
index d92f8311..b276982a 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1474,6 +1474,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
}
ProcessContext(ALContext);
}
+ device->SamplesPlayed += SamplesToDo;
ProcessContext(NULL);
//Post processing loop