mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-23 04:35:35 +00:00
PulseAudio: detect server going offline
This commit is contained in:
parent
8d3a32e668
commit
b8a2adb4ec
|
@ -272,10 +272,10 @@ Then look at `html/index.html` in a browser.
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
0. Detect PulseAudio server going offline and emit `on_backend_disconnect`.
|
|
||||||
0. Ability to "activate" a buffer-flexible outstream by jumping the gun and
|
0. Ability to "activate" a buffer-flexible outstream by jumping the gun and
|
||||||
causing `write_callback` to be called early.
|
causing `write_callback` to be called early.
|
||||||
- Use the same mechanism when destroying the outstream
|
- Use the same mechanism when destroying the outstream
|
||||||
|
0. Create a test for recovering from backend disconnecting that reconnects
|
||||||
0. Create a test for input stream overflow handling.
|
0. Create a test for input stream overflow handling.
|
||||||
0. Create a test for the latency / synchronization API.
|
0. Create a test for the latency / synchronization API.
|
||||||
- Input is an audio file and some events indexed at particular frame - when
|
- Input is an audio file and some events indexed at particular frame - when
|
||||||
|
|
|
@ -36,6 +36,7 @@ static int subscribe_to_events(SoundIoPrivate *si) {
|
||||||
static void context_state_callback(pa_context *context, void *userdata) {
|
static void context_state_callback(pa_context *context, void *userdata) {
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)userdata;
|
SoundIoPrivate *si = (SoundIoPrivate *)userdata;
|
||||||
SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
|
SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
|
||||||
|
SoundIo *soundio = &si->pub;
|
||||||
|
|
||||||
switch (pa_context_get_state(context)) {
|
switch (pa_context_get_state(context)) {
|
||||||
case PA_CONTEXT_UNCONNECTED: // The context hasn't been connected yet.
|
case PA_CONTEXT_UNCONNECTED: // The context hasn't been connected yet.
|
||||||
|
@ -55,7 +56,9 @@ static void context_state_callback(pa_context *context, void *userdata) {
|
||||||
return;
|
return;
|
||||||
case PA_CONTEXT_FAILED: // The connection failed or was disconnected.
|
case PA_CONTEXT_FAILED: // The connection failed or was disconnected.
|
||||||
sipa->connection_err = SoundIoErrorInitAudioBackend;
|
sipa->connection_err = SoundIoErrorInitAudioBackend;
|
||||||
sipa->ready_flag = true;
|
if (sipa->ready_flag.exchange(true)) {
|
||||||
|
soundio->on_backend_disconnect(soundio, SoundIoErrorBackendDisconnected);
|
||||||
|
}
|
||||||
pa_threaded_mainloop_signal(sipa->main_loop, 0);
|
pa_threaded_mainloop_signal(sipa->main_loop, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue