aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/pulseaudio.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-10-04 23:24:40 -0700
committerChris Robinson <[email protected]>2012-10-04 23:36:59 -0700
commit468759e6abe90c0a6c8e2b445eb54275d7571265 (patch)
treed60d471b18151df6a410cbe72294c27c6d17d86b /Alc/backends/pulseaudio.c
parentf138774d78c5ae43dd43fdf8e63ae48bafa600fd (diff)
Scale and round NumUpdates when PulseAudio changes the sample rate
Diffstat (limited to 'Alc/backends/pulseaudio.c')
-rw-r--r--Alc/backends/pulseaudio.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 10e2fa6c..07b10c10 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -1100,12 +1100,10 @@ static ALCboolean pulse_reset_playback(ALCdevice *device)
/* Server updated our playback rate, so modify the buffer attribs
* accordingly. */
- device->UpdateSize = (ALuint64)device->UpdateSize * data->spec.rate /
- device->Frequency;
- if((CPUCapFlags&CPU_CAP_SSE))
- device->UpdateSize = (device->UpdateSize+3)&~3;
+ device->NumUpdates = (ALuint)((ALdouble)device->NumUpdates / device->Frequency *
+ data->spec.rate + 0.5);
data->attr.minreq = device->UpdateSize * pa_frame_size(&data->spec);
- data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2);
+ data->attr.tlength = data->attr.minreq * clampu(device->NumUpdates, 2, 16);
data->attr.maxlength = -1;
data->attr.prebuf = 0;
@@ -1124,8 +1122,10 @@ static ALCboolean pulse_reset_playback(ALCdevice *device)
stream_buffer_attr_callback(data->stream, device);
len = data->attr.minreq / pa_frame_size(&data->spec);
- device->NumUpdates = (device->UpdateSize*device->NumUpdates + len/2) / len;
- device->NumUpdates = maxu(device->NumUpdates, 2);
+ if((CPUCapFlags&CPU_CAP_SSE))
+ len = (len+3)&~3;
+ device->NumUpdates = (ALuint)((ALdouble)device->NumUpdates/len*device->UpdateSize + 0.5);
+ device->NumUpdates = clampu(device->NumUpdates, 2, 16);
device->UpdateSize = len;
pa_threaded_mainloop_unlock(data->loop);