aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-10-31 17:57:35 -0700
committerChris Robinson <[email protected]>2009-10-31 17:57:35 -0700
commit8e599103b61e056ac5aa1233f9081daec0a725d3 (patch)
tree4a690c43f8d2bbd646a0cbed9043a303848dbc51 /Alc
parentaf0140e260500532eabfafa432c03f656d0e9b44 (diff)
Watch for buffer attribute changes from PulseAudio
Diffstat (limited to 'Alc')
-rw-r--r--Alc/pulseaudio.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index 9bce3486..3962a27c 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -78,6 +78,7 @@ MAKE_FUNC(pa_stream_set_write_callback);
MAKE_FUNC(pa_threaded_mainloop_new);
MAKE_FUNC(pa_context_connect);
MAKE_FUNC(pa_stream_get_buffer_attr);
+MAKE_FUNC(pa_stream_set_buffer_attr_callback);
MAKE_FUNC(pa_stream_set_read_callback);
MAKE_FUNC(pa_stream_set_state_callback);
MAKE_FUNC(pa_stream_new);
@@ -190,6 +191,7 @@ LOAD_FUNC(pa_stream_set_write_callback);
LOAD_FUNC(pa_threaded_mainloop_new);
LOAD_FUNC(pa_context_connect);
LOAD_FUNC(pa_stream_get_buffer_attr);
+LOAD_FUNC(pa_stream_set_buffer_attr_callback);
LOAD_FUNC(pa_stream_set_read_callback);
LOAD_FUNC(pa_stream_set_state_callback);
LOAD_FUNC(pa_stream_new);
@@ -235,6 +237,23 @@ static void stream_state_callback(pa_stream *stream, void *pdata) //{{{
if(ppa_threaded_mainloop_in_thread(data->loop))
ppa_threaded_mainloop_signal(data->loop, 1);
}//}}}
+
+static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) //{{{
+{
+ ALCdevice *Device = pdata;
+ pulse_data *data = Device->ExtraData;
+
+ SuspendContext(NULL);
+
+ data->attr = *(ppa_stream_get_buffer_attr(stream));
+ if((data->attr.tlength%data->attr.minreq) != 0)
+ AL_PRINT("new tlength (%d) is not a multiple of minreq (%d)!\n",
+ data->attr.tlength, data->attr.minreq);
+ Device->UpdateSize = data->attr.minreq;
+ Device->NumUpdates = data->attr.tlength/data->attr.minreq;
+
+ ProcessContext(NULL);
+}//}}}
//}}}
// PulseAudio I/O Callbacks //{{{
@@ -500,12 +519,8 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{
}
ppa_stream_set_state_callback(data->stream, NULL, NULL);
- data->attr = *(ppa_stream_get_buffer_attr(data->stream));
- if((data->attr.tlength%data->attr.minreq) != 0)
- AL_PRINT("tlength (%d) is not a multiple of minreq (%d)!\n",
- data->attr.tlength, data->attr.minreq);
- device->UpdateSize = data->attr.minreq;
- device->NumUpdates = data->attr.tlength/data->attr.minreq;
+ stream_buffer_attr_callback(data->stream, device);
+ ppa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device);
ppa_threaded_mainloop_unlock(data->loop);
return ALC_TRUE;