Keep count of the number of samples played

This commit is contained in:
Chris Robinson
2010-07-22 08:11:44 -07:00
parent 88f236ccd3
commit 7eb124d99c
3 changed files with 13 additions and 0 deletions
+9
View File
@@ -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);
+1
View File
@@ -1474,6 +1474,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
}
ProcessContext(ALContext);
}
device->SamplesPlayed += SamplesToDo;
ProcessContext(NULL);
//Post processing loop
+3
View File
@@ -405,6 +405,9 @@ struct ALCdevice_struct
ALCcontext **Contexts;
ALuint NumContexts;
// Number of samples rendered by this device
ALuint64 SamplesPlayed;
BackendFuncs *Funcs;
void *ExtraData; // For the backend's use