diff options
author | Chris Robinson <[email protected]> | 2009-10-31 20:05:15 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-10-31 20:05:15 -0700 |
commit | 5aed92788715cc957d6adb2b621f49f8ed22e162 (patch) | |
tree | 5ab6bff12ec743d3a8653625c218c60f270cc4bf | |
parent | d964bb9f2f74dc2da124e48647b4af3a84cc8381 (diff) |
Watch for stream and context failures from pulse, and report disconnects
-rw-r--r-- | Alc/pulseaudio.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 106fbea5..fa7e593b 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -258,6 +258,33 @@ static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) //{{{ ProcessContext(NULL); }//}}} + +static void context_state_callback2(pa_context *context, void *pdata) //{{{ +{ + ALCdevice *Device = pdata; + + if(ppa_context_get_state(context) == PA_CONTEXT_FAILED) + { + AL_PRINT("Received context failure!\n"); + SuspendContext(NULL); + aluHandleDisconnect(Device); + ProcessContext(NULL); + } +}//}}} + +static void stream_state_callback2(pa_stream *stream, void *pdata) //{{{ +{ + ALCdevice *Device = pdata; + + if(ppa_stream_get_state(stream) == PA_STREAM_FAILED) + { + AL_PRINT("Received stream failure!\n"); + SuspendContext(NULL); + aluHandleDisconnect(Device); + ProcessContext(NULL); + } +}//}}} + //}}} // PulseAudio I/O Callbacks //{{{ @@ -368,7 +395,7 @@ static ALCboolean pulse_open(ALCdevice *device, const ALCchar *device_name) //{{ ppa_threaded_mainloop_wait(data->loop); ppa_threaded_mainloop_accept(data->loop); } - ppa_context_set_state_callback(data->context, NULL, NULL); + ppa_context_set_state_callback(data->context, context_state_callback2, device); device->szDeviceName = strdup(device_name); @@ -559,7 +586,7 @@ static ALCboolean pulse_reset_playback(ALCdevice *device) //{{{ ppa_threaded_mainloop_wait(data->loop); ppa_threaded_mainloop_accept(data->loop); } - ppa_stream_set_state_callback(data->stream, NULL, NULL); + ppa_stream_set_state_callback(data->stream, stream_state_callback2, device); stream_buffer_attr_callback(data->stream, device); ppa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device); @@ -705,7 +732,7 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na ppa_threaded_mainloop_wait(data->loop); ppa_threaded_mainloop_accept(data->loop); } - ppa_stream_set_state_callback(data->stream, NULL, NULL); + ppa_stream_set_state_callback(data->stream, stream_state_callback2, device); ppa_threaded_mainloop_unlock(data->loop); return ALC_TRUE; |