From 5a8d2e80577e1c80186dcf6a05879a9101c34639 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Dec 2014 23:22:45 +0100 Subject: output/jack: cache AudioFormat::channels --- src/output/plugins/JackOutputPlugin.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/output/plugins') diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index e4239a70b..99de03fb3 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -145,16 +145,18 @@ JackOutput::Process(jack_nframes_t nframes) jack_nframes_t available = GetAvailable(); + const unsigned n_channels = audio_format.channels; + if (pause) { /* empty the ring buffers */ - for (unsigned i = 0; i < audio_format.channels; ++i) + for (unsigned i = 0; i < n_channels; ++i) jack_ringbuffer_read_advance(ringbuffer[i], available * jack_sample_size); /* generate silence while MPD is paused */ - for (unsigned i = 0; i < audio_format.channels; ++i) { + for (unsigned i = 0; i < n_channels; ++i) { jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(ports[i], nframes); @@ -168,7 +170,7 @@ JackOutput::Process(jack_nframes_t nframes) if (available > nframes) available = nframes; - for (unsigned i = 0; i < audio_format.channels; ++i) { + for (unsigned i = 0; i < n_channels; ++i) { jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(ports[i], nframes); @@ -188,7 +190,7 @@ JackOutput::Process(jack_nframes_t nframes) /* generate silence for the unused source ports */ - for (unsigned i = audio_format.channels; i < num_source_ports; ++i) { + for (unsigned i = n_channels; i < num_source_ports; ++i) { jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(ports[i], nframes); -- cgit v1.2.3