aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-10-19 16:07:56 -0700
committerChris Robinson <[email protected]>2011-10-19 16:07:56 -0700
commit75679c959ab8619d1c12b2de6fdf991e7f70cc0d (patch)
tree18a578e9dbd7232e673e042e22277cec61c29876
parent628356a2942322656dc82c01f91cddec4ceb2a27 (diff)
Don't update the device update parameters when PulseAudio does an async buffer update
It risks a deadlock, and though the UpdateSize won't change, we'll still fill as much of the buffer as we can up to a multiple of it
-rw-r--r--Alc/backends/pulseaudio.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index f727b639..ee7a633f 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -437,21 +437,11 @@ static void stream_signal_callback(pa_stream *stream, void *pdata) //{{{
static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) //{{{
{
- ALCdevice *Device = pdata;
- pulse_data *data = Device->ExtraData;
-
- LockDevice(Device);
-
- data->attr = *(pa_stream_get_buffer_attr(stream));
- Device->UpdateSize = data->attr.minreq / data->frame_size;
- Device->NumUpdates = (data->attr.tlength/data->frame_size) / Device->UpdateSize;
- if(Device->NumUpdates <= 1)
- {
- Device->NumUpdates = 1;
- ERR("PulseAudio returned minreq > tlength/2; expect lag or break up\n");
- }
+ const pa_buffer_attr *attr;
+ (void)pdata;
- UnlockDevice(Device);
+ attr = pa_stream_get_buffer_attr(stream);
+ WARN("PulseAudio modified buffer length: minreq=%d, tlength=%d\n", attr->minreq, attr->tlength);
}//}}}
static void stream_device_callback(pa_stream *stream, void *pdata) //{{{
@@ -1018,11 +1008,23 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
device->Frequency = data->spec.rate;
}
- stream_buffer_attr_callback(data->stream, device);
- if(device->NumUpdates < 2)
+#if PA_CHECK_VERSION(0,9,15)
+ if(pa_stream_set_buffer_attr_callback)
+ pa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device);
+#endif
+ pa_stream_set_moved_callback(data->stream, stream_device_callback, device);
+ pa_stream_set_write_callback(data->stream, stream_write_callback, device);
+ pa_stream_set_underflow_callback(data->stream, stream_signal_callback, device);
+
+ data->attr = *(pa_stream_get_buffer_attr(data->stream));
+ device->UpdateSize = data->attr.minreq / data->frame_size;
+ device->NumUpdates = (data->attr.tlength/data->frame_size) / device->UpdateSize;
+ if(device->NumUpdates <= 1)
{
pa_operation *o;
+ ERR("PulseAudio returned minreq=%d, tlength=%d; expect lag or break up\n", data->attr.minreq, data->attr.tlength);
+
/* Server gave a comparatively large minreq, so modify the tlength. */
device->NumUpdates = 2;
data->attr.tlength = data->attr.minreq * device->NumUpdates;
@@ -1034,14 +1036,6 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
pa_operation_unref(o);
}
-#if PA_CHECK_VERSION(0,9,15)
- if(pa_stream_set_buffer_attr_callback)
- pa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device);
-#endif
- pa_stream_set_moved_callback(data->stream, stream_device_callback, device);
- pa_stream_set_write_callback(data->stream, stream_write_callback, device);
- pa_stream_set_underflow_callback(data->stream, stream_signal_callback, device);
-
data->thread = StartThread(PulseProc, device);
if(!data->thread)
{