aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-07-25 12:54:50 -0700
committerChris Robinson <[email protected]>2010-07-25 12:54:50 -0700
commit46d46c49a87b33ed727a7099aca3dc89e06e57cd (patch)
treefb5e8d5611de607f6ddb707e1406d71e0bbe251d
parent40dd1fb85364e3a9e278ffa7a034638e7718770b (diff)
Store the time precision with the device
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/alsa.c5
-rw-r--r--Alc/dsound.c2
-rw-r--r--Alc/null.c3
-rw-r--r--Alc/oss.c2
-rw-r--r--Alc/portaudio.c2
-rw-r--r--Alc/pulseaudio.c3
-rw-r--r--Alc/solaris.c2
-rw-r--r--Alc/wave.c2
-rw-r--r--OpenAL32/Include/alMain.h3
10 files changed, 24 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 93ee4b7d..30fe037c 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1995,6 +1995,8 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
device->SamplesPlayed = 0;
+ device->TimeRes = 1;
+
InitUIntMap(&device->BufferMap);
InitUIntMap(&device->EffectMap);
InitUIntMap(&device->FilterMap);
diff --git a/Alc/alsa.c b/Alc/alsa.c
index 80825b02..4d1d58b3 100644
--- a/Alc/alsa.c
+++ b/Alc/alsa.c
@@ -695,6 +695,9 @@ static ALCboolean alsa_reset_playback(ALCdevice *device)
psnd_pcm_sw_params_free(sp);
+ device->TimeRes = (ALuint64)periodSizeInFrames * 1000000000 / rate;
+ device->Frequency = rate;
+
SetDefaultChannelOrder(device);
data->size = psnd_pcm_frames_to_bytes(data->pcmHandle, periodSizeInFrames);
@@ -711,7 +714,6 @@ static ALCboolean alsa_reset_playback(ALCdevice *device)
}
device->UpdateSize = periodSizeInFrames;
device->NumUpdates = periods;
- device->Frequency = rate;
data->thread = StartThread(ALSANoMMapProc, device);
}
else
@@ -724,7 +726,6 @@ static ALCboolean alsa_reset_playback(ALCdevice *device)
}
device->UpdateSize = periodSizeInFrames;
device->NumUpdates = periods;
- device->Frequency = rate;
data->thread = StartThread(ALSAProc, device);
}
if(data->thread == NULL)
diff --git a/Alc/dsound.c b/Alc/dsound.c
index f636287f..f513f2ef 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -461,6 +461,8 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device)
if(SUCCEEDED(hr))
{
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
device->Format = format;
SetDefaultWFXChannelOrder(device);
pData->thread = StartThread(DSoundProc, device);
diff --git a/Alc/null.c b/Alc/null.c
index be760e7d..43a10624 100644
--- a/Alc/null.c
+++ b/Alc/null.c
@@ -108,6 +108,9 @@ static ALCboolean null_reset_playback(ALCdevice *device)
}
SetDefaultWFXChannelOrder(device);
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
+
data->thread = StartThread(NullProc, device);
if(data->thread == NULL)
{
diff --git a/Alc/oss.c b/Alc/oss.c
index 9f3e5ae2..8fda248c 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -268,6 +268,8 @@ static ALCboolean oss_reset_playback(ALCdevice *device)
device->Frequency = ossSpeed;
device->UpdateSize = info.fragsize / frameSize;
device->NumUpdates = info.fragments + 1;
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
data->data_size = device->UpdateSize * frameSize;
data->mix_data = calloc(1, data->data_size);
diff --git a/Alc/portaudio.c b/Alc/portaudio.c
index 94eca19e..062c403a 100644
--- a/Alc/portaudio.c
+++ b/Alc/portaudio.c
@@ -250,6 +250,8 @@ static ALCboolean pa_reset_playback(ALCdevice *device)
streamInfo = pPa_GetStreamInfo(data->stream);
device->Frequency = streamInfo->sampleRate;
device->UpdateSize = data->update_size;
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
err = pPa_StartStream(data->stream);
if(err != paNoError)
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index 2769fcd9..9355cc36 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -938,6 +938,9 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
ppa_stream_set_moved_callback(data->stream, stream_device_callback, device);
ppa_stream_set_write_callback(data->stream, stream_write_callback, device);
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
+
data->thread = StartThread(PulseProc, device);
if(!data->thread)
{
diff --git a/Alc/solaris.c b/Alc/solaris.c
index cff744ae..4fbb1942 100644
--- a/Alc/solaris.c
+++ b/Alc/solaris.c
@@ -193,6 +193,8 @@ static ALCboolean solaris_reset_playback(ALCdevice *device)
device->Frequency = info.play.sample_rate;
device->UpdateSize = (info.play.buffer_size/device->NumUpdates) + 1;
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
data->data_size = device->UpdateSize * frameSize;
data->mix_data = calloc(1, data->data_size);
diff --git a/Alc/wave.c b/Alc/wave.c
index 61a93570..1b6a41d1 100644
--- a/Alc/wave.c
+++ b/Alc/wave.c
@@ -273,6 +273,8 @@ static ALCboolean wave_reset_playback(ALCdevice *device)
return ALC_FALSE;
}
+ device->TimeRes = (ALuint64)device->UpdateSize * 1000000000 /
+ device->Frequency;
SetDefaultWFXChannelOrder(device);
data->thread = StartThread(WaveProc, device);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 5791b336..4957b942 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -410,6 +410,9 @@ struct ALCdevice_struct
// Number of samples rendered by this device
ALuint64 SamplesPlayed;
+ // Precision of this device's timing
+ ALuint64 TimeRes;
+
BackendFuncs *Funcs;
void *ExtraData; // For the backend's use