From 2892a6f5e27ff9143bec0d66a1c4a8e8983053fc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 5 Aug 2019 09:28:41 +0200 Subject: [PATCH] output/jack: merge set_audioformat() into Open() --- src/output/plugins/JackOutputPlugin.cxx | 28 ++++++++++--------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index 021ef0842..6c3271e69 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -368,22 +368,6 @@ mpd_jack_shutdown(jack_status_t, const char *reason, void *arg) reason))); } -static void -set_audioformat(JackOutput *jd, AudioFormat &audio_format) -{ - audio_format.sample_rate = jack_get_sample_rate(jd->client); - - if (jd->num_source_ports == 1) - audio_format.channels = 1; - else if (audio_format.channels > jd->num_source_ports) - audio_format.channels = 2; - - /* JACK uses 32 bit float in the range [-1 .. 1] - just like - MPD's SampleFormat::FLOAT*/ - static_assert(jack_sample_size == sizeof(float), "Expected float32"); - audio_format.format = SampleFormat::FLOAT; -} - static void mpd_jack_error(const char *msg) { @@ -614,7 +598,17 @@ JackOutput::Open(AudioFormat &new_audio_format) if (client == nullptr) Connect(); - set_audioformat(this, new_audio_format); + new_audio_format.sample_rate = jack_get_sample_rate(client); + + if (num_source_ports == 1) + new_audio_format.channels = 1; + else if (new_audio_format.channels > num_source_ports) + new_audio_format.channels = 2; + + /* JACK uses 32 bit float in the range [-1 .. 1] - just like + MPD's SampleFormat::FLOAT*/ + static_assert(jack_sample_size == sizeof(float), "Expected float32"); + new_audio_format.format = SampleFormat::FLOAT; audio_format = new_audio_format; Start();