[client] audio/pw: don't actually stop when SPICE signals a stop

This commit is contained in:
Geoffrey McRae 2021-12-25 02:38:11 +11:00
parent e810577317
commit 75e46128d4

View File

@ -133,6 +133,18 @@ static void pipewire_free(void)
pw_deinit();
}
static void pipewire_stop(void)
{
if (!pw.stream)
return;
pw_thread_loop_lock(pw.thread);
pw_stream_flush(pw.stream, true);
pw_stream_destroy(pw.stream);
pw.stream = NULL;
pw_thread_loop_unlock(pw.thread);
}
static void pipewire_start(int channels, int sampleRate)
{
const struct spa_pod * params[1];
@ -144,6 +156,8 @@ static void pipewire_start(int channels, int sampleRate)
.process = pipewire_on_process
};
pipewire_stop();
pw.channels = channels;
pw.stride = sizeof(uint16_t) * channels;
pw.buffer = ringbuffer_new(sampleRate, channels * sizeof(uint16_t));
@ -197,16 +211,9 @@ static void pipewire_play(uint8_t * data, int size)
ringbuffer_push(pw.buffer, data + i);
}
static void pipewire_stop(void)
static void pipewire_stop_nop(void)
{
if (!pw.stream)
return;
pw_thread_loop_lock(pw.thread);
pw_stream_flush(pw.stream, true);
pw_stream_destroy(pw.stream);
pw.stream = NULL;
pw_thread_loop_unlock(pw.thread);
// we ignore the stop message to avoid messing up any audio graph
}
struct LG_AudioDevOps LGAD_PipeWire =
@ -216,5 +223,5 @@ struct LG_AudioDevOps LGAD_PipeWire =
.free = pipewire_free,
.start = pipewire_start,
.play = pipewire_play,
.stop = pipewire_stop
.stop = pipewire_stop_nop
};