[client] audio/pw: gracefully shutdown when asked to

This commit is contained in:
Geoffrey McRae 2021-12-25 15:03:50 +11:00
parent cca6492069
commit e408ea51e2

View File

@ -104,30 +104,11 @@ err_context:
pw_context_destroy(context);
err:
pw_loop_destroy(pw.loop);
pw_deinit();
return false;
}
static void pipewire_free(void)
{
if (pw.thread)
{
pw_thread_loop_lock(pw.thread);
if (pw.stream)
{
pw_stream_destroy(pw.stream);
pw.stream = NULL;
}
pw_thread_loop_signal(pw.thread, true);
pw_thread_loop_destroy(pw.thread);
pw.loop = NULL;
}
ringbuffer_free(&pw.buffer);
pw_deinit();
}
static void pipewire_stop_stream(void)
{
if (!pw.stream)
@ -140,6 +121,20 @@ static void pipewire_stop_stream(void)
pw_thread_loop_unlock(pw.thread);
}
static void pipewire_free(void)
{
pipewire_stop_stream();
pw_thread_loop_stop(pw.thread);
pw_thread_loop_destroy(pw.thread);
pw_loop_destroy(pw.loop);
pw.loop = NULL;
pw.thread = NULL;
ringbuffer_free(&pw.buffer);
pw_deinit();
}
static void pipewire_start(int channels, int sampleRate)
{
const struct spa_pod * params[1];