[client] audio/pw: don't re-create an idle stream with matching format

This commit is contained in:
Geoffrey McRae 2021-12-25 13:44:40 +11:00
parent 2ea24516d2
commit ebdc847ef1

View File

@ -32,6 +32,7 @@ struct PipeWire
struct pw_thread_loop * thread;
struct pw_stream * stream;
int channels;
int sampleRate;
int stride;
RingBuffer buffer;
@ -150,9 +151,13 @@ static void pipewire_start(int channels, int sampleRate)
.process = pipewire_on_process
};
if (pw.stream && pw.channels == channels && pw.sampleRate == sampleRate)
return;
pipewire_stop_stream();
pw.channels = channels;
pw.sampleRate = sampleRate;
pw.stride = sizeof(uint16_t) * channels;
pw.buffer = ringbuffer_new(sampleRate / 10, channels * sizeof(uint16_t));