aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-09-25 11:32:49 -0700
committerChris Robinson <[email protected]>2012-09-25 11:32:49 -0700
commit012e61b1054403655d70bc52b57f2ce1b5776f1d (patch)
treee85fb12d41b498585694a7632317969636a1514a
parentd19d7321d927208be1b861a880950ff568723e0c (diff)
Round when calculating NumUpdates from PulseAudio's minreq
-rw-r--r--Alc/backends/pulseaudio.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 9512c8af..a490d0e1 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -1004,6 +1004,7 @@ static ALCboolean pulse_reset_playback(ALCdevice *device)
pulse_data *data = device->ExtraData;
pa_stream_flags_t flags = 0;
pa_channel_map chanmap;
+ ALuint len;
pa_threaded_mainloop_lock(data->loop);
@@ -1099,11 +1100,11 @@ static ALCboolean pulse_reset_playback(ALCdevice *device)
/* Server updated our playback rate, so modify the buffer attribs
* accordingly. */
- data->attr.minreq = (ALuint64)device->UpdateSize * data->spec.rate /
- device->Frequency;
+ device->UpdateSize = (ALuint64)device->UpdateSize * data->spec.rate /
+ device->Frequency;
if((CPUCapFlags&CPU_CAP_SSE))
- data->attr.minreq = (data->attr.minreq+3)&~3;
- data->attr.minreq *= pa_frame_size(&data->spec);
+ device->UpdateSize = (device->UpdateSize+3)&~3;
+ data->attr.minreq = device->UpdateSize * pa_frame_size(&data->spec);
data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2);
data->attr.prebuf = 0;
@@ -1121,10 +1122,10 @@ static ALCboolean pulse_reset_playback(ALCdevice *device)
#endif
stream_buffer_attr_callback(data->stream, device);
- device->NumUpdates = device->UpdateSize*device->NumUpdates /
- (data->attr.minreq/pa_frame_size(&data->spec));
+ len = data->attr.minreq / pa_frame_size(&data->spec);
+ device->NumUpdates = (device->UpdateSize*device->NumUpdates + len/2) / len;
device->NumUpdates = maxu(device->NumUpdates, 2);
- device->UpdateSize = data->attr.minreq / pa_frame_size(&data->spec);
+ device->UpdateSize = len;
pa_threaded_mainloop_unlock(data->loop);
return ALC_TRUE;