* [PATCH] audio/jack: add JACK client audiodev
@ 2020-04-29 5:53 Geoffrey McRae
2020-04-29 6:59 ` no-reply
0 siblings, 1 reply; 2+ messages in thread
From: Geoffrey McRae @ 2020-04-29 5:53 UTC (permalink / raw)
To: qemu-devel
This commit adds a new audiodev backend to allow QEMU to use JACK as
both an audio sink and source.
Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
---
audio/Makefile.objs | 5 +
audio/audio.c | 1 +
audio/audio_template.h | 2 +
audio/jackaudio.c | 583 +++++++++++++++++++++++++++++++++++++++++
configure | 17 ++
qapi/audio.json | 50 +++-
6 files changed, 656 insertions(+), 2 deletions(-)
create mode 100644 audio/jackaudio.c
diff --git a/audio/Makefile.objs b/audio/Makefile.objs
index d7490a379f..b4a4c11f31 100644
--- a/audio/Makefile.objs
+++ b/audio/Makefile.objs
@@ -28,3 +28,8 @@ common-obj-$(CONFIG_AUDIO_SDL) += sdl.mo
sdl.mo-objs = sdlaudio.o
sdl.mo-cflags := $(SDL_CFLAGS)
sdl.mo-libs := $(SDL_LIBS)
+
+# jack module
+common-obj-$(CONFIG_AUDIO_JACK) += jack.mo
+jack.mo-objs = jackaudio.o
+jack.mo-libs := $(JACK_LIBS)
diff --git a/audio/audio.c b/audio/audio.c
index 7a9e680355..95d9fb16ca 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1969,6 +1969,7 @@ void audio_create_pdos(Audiodev *dev)
CASE(ALSA, alsa, Alsa);
CASE(COREAUDIO, coreaudio, Coreaudio);
CASE(DSOUND, dsound, );
+ CASE(JACK, jack, Jack);
CASE(OSS, oss, Oss);
CASE(PA, pa, Pa);
CASE(SDL, sdl, );
diff --git a/audio/audio_template.h b/audio/audio_template.h
index 7013d3041f..8dd48ce14e 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -330,6 +330,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
dev->u.coreaudio.TYPE);
case AUDIODEV_DRIVER_DSOUND:
return dev->u.dsound.TYPE;
+ case AUDIODEV_DRIVER_JACK:
+ return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.TYPE);
case AUDIODEV_DRIVER_OSS:
return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.TYPE);
case AUDIODEV_DRIVER_PA:
diff --git a/audio/jackaudio.c b/audio/jackaudio.c
new file mode 100644
index 0000000000..0413731044
--- /dev/null
+++ b/audio/jackaudio.c
@@ -0,0 +1,583 @@
+/*
+ * QEMU JACK Audio Connection Kit Client
+ *
+ * Copyright (c) 2020 Geoffrey McRae (gnif)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/module.h"
+#include "qemu/fifo8.h"
+#include "qemu-common.h"
+#include "audio.h"
+
+#define AUDIO_CAP "jack"
+#include "audio_int.h"
+
+#include <stdatomic.h>
+#include <jack/jack.h>
+#include <jack/thread.h>
+
+struct QJack;
+
+typedef enum QJackState
+{
+ QJACK_STATE_DISCONNECTED,
+ QJACK_STATE_CONNECTED,
+ QJACK_STATE_IDLE,
+ QJACK_STATE_RUNNING,
+ QJACK_STATE_STOPPING,
+ QJACK_STATE_STOPPED,
+}
+QJackState;
+
+typedef struct QJackBuffer
+{
+ int channels;
+ int frames;
+ _Atomic(int) used;
+ int rptr, wptr;
+ float ** data;
+}
+QJackBuffer;
+
+typedef struct QJackClient
+{
+ bool out;
+ QJackState state;
+ jack_client_t * client;
+ jack_nframes_t freq;
+
+ struct QJack * j;
+ int nchannels;
+ int buffersize;
+ jack_port_t ** port;
+ QJackBuffer fifo;
+}
+QJackClient;
+
+typedef struct QJackOut
+{
+ HWVoiceOut hw;
+ QJackClient c;
+}
+QJackOut;
+
+typedef struct QJackIn
+{
+ HWVoiceIn hw;
+ QJackClient c;
+}
+QJackIn;
+
+static void qjack_buffer_create(QJackBuffer * buffer, int channels, int frames)
+{
+ buffer->channels = channels;
+ buffer->frames = frames;
+ buffer->used = 0;
+ buffer->rptr = 0;
+ buffer->wptr = 0;
+ buffer->data = g_malloc(channels * sizeof(float *));
+ for(int i = 0; i < channels; ++i)
+ buffer->data[i] = g_malloc(frames * sizeof(float));
+}
+
+static void qjack_buffer_clear(QJackBuffer * buffer)
+{
+ atomic_store_explicit(&buffer->used, 0, memory_order_relaxed);
+ buffer->rptr = 0;
+ buffer->wptr = 0;
+}
+
+static void qjack_buffer_free(QJackBuffer * buffer)
+{
+ for(int i = 0; i < buffer->channels; ++i)
+ g_free(buffer->data[i]);
+
+ g_free(buffer->data);
+ buffer->data = NULL;
+}
+
+inline static int qjack_buffer_used(QJackBuffer * buffer)
+{
+ return atomic_load_explicit(&buffer->used, memory_order_relaxed);
+}
+
+/* write PCM interleaved */
+static int qjack_buffer_write(QJackBuffer * buffer, float * data, int size)
+{
+ const int samples = size / sizeof(float);
+ int frames = samples / buffer->channels;
+ const int avail = buffer->frames -
+ atomic_load_explicit(&buffer->used, memory_order_acquire);
+
+ if (frames > avail)
+ frames = avail;
+
+ int copy = frames;
+ int wptr = buffer->wptr;
+
+ while(copy) {
+
+ for(int c = 0; c < buffer->channels; ++c)
+ buffer->data[c][wptr] = *data++;
+
+ if (++wptr == buffer->frames)
+ wptr = 0;
+
+ --copy;
+ }
+
+ buffer->wptr = wptr;
+
+ atomic_fetch_add_explicit(&buffer->used, frames, memory_order_release);
+ return frames * buffer->channels * sizeof(float);
+};
+
+/* write PCM linear */
+static int qjack_buffer_write_l(QJackBuffer * buffer, float ** dest, int frames)
+{
+ const int avail = buffer->frames -
+ atomic_load_explicit(&buffer->used, memory_order_acquire);
+ int wptr = buffer->wptr;
+
+ if (frames > avail)
+ frames = avail;
+
+ int right = buffer->frames - wptr;
+ if (right > frames)
+ right = frames;
+
+ const int left = frames - right;
+ for(int c = 0; c < buffer->channels; ++c) {
+ memcpy(buffer->data[c] + wptr, dest[c] , right * sizeof(float));
+ memcpy(buffer->data[c] , dest[c] + right, left * sizeof(float));
+ }
+
+ wptr += frames;
+ if (wptr >= buffer->frames)
+ wptr -= buffer->frames;
+ buffer->wptr = wptr;
+
+ atomic_fetch_add_explicit(&buffer->used, frames, memory_order_release);
+ return frames;
+}
+
+/* read PCM interleaved */
+static int qjack_buffer_read(QJackBuffer * buffer, float * dest, int size)
+{
+ const int samples = size / sizeof(float);
+ int frames = samples / buffer->channels;
+ const int avail =
+ atomic_load_explicit(&buffer->used, memory_order_acquire);
+
+ if (frames > avail)
+ frames = avail;
+
+ int copy = frames;
+ int rptr = buffer->rptr;
+
+ while(copy) {
+
+ for(int c = 0; c < buffer->channels; ++c)
+ *dest++ = buffer->data[c][rptr];
+
+ if (++rptr == buffer->frames)
+ rptr = 0;
+
+ --copy;
+ }
+
+ buffer->rptr = rptr;
+
+ atomic_fetch_sub_explicit(&buffer->used, frames, memory_order_release);
+ return frames * buffer->channels * sizeof(float);
+}
+
+/* read PCM linear */
+static int qjack_buffer_read_l(QJackBuffer * buffer, float ** dest, int frames)
+{
+ int copy = frames;
+ const int used = atomic_load_explicit(&buffer->used, memory_order_acquire);
+ int rptr = buffer->rptr;
+
+ if (copy > used)
+ copy = used;
+
+ int right = buffer->frames - rptr;
+ if (right > copy)
+ right = copy;
+
+ const int left = copy - right;
+ for(int c = 0; c < buffer->channels; ++c) {
+ memcpy(dest[c] , buffer->data[c] + rptr, right * sizeof(float));
+ memcpy(dest[c] + right, buffer->data[c] , left * sizeof(float));
+ }
+
+ rptr += copy;
+ if (rptr >= buffer->frames)
+ rptr -= buffer->frames;
+ buffer->rptr = rptr;
+
+ atomic_fetch_sub_explicit(&buffer->used, copy, memory_order_release);
+ return copy;
+}
+
+static int qjack_process(jack_nframes_t nframes, void *arg)
+{
+ QJackClient *c = (QJackClient *)arg;
+ jack_transport_state_t ts = jack_transport_query(c->client, NULL);
+
+ if (ts == JackTransportRolling) {
+
+ if (c->state != QJACK_STATE_RUNNING)
+ return 0;
+
+ /* get the buffers for the ports */
+ float * buffers[c->nchannels];
+ for(int i = 0; i < c->nchannels; ++i)
+ buffers[i] = jack_port_get_buffer(c->port[i], nframes);
+
+ if (c->out)
+ qjack_buffer_read_l(&c->fifo, buffers, nframes);
+ else
+ qjack_buffer_write_l(&c->fifo, buffers, nframes);
+
+ } else if (ts == JackTransportStopped) {
+
+ if (c->state == QJACK_STATE_RUNNING)
+ c->state = QJACK_STATE_STOPPED;
+
+ }
+
+ return 0;
+}
+
+static int qjack_xrun(void * arg)
+{
+ QJackClient *c = (QJackClient *)arg;
+
+ if (c->state != QJACK_STATE_RUNNING)
+ return 0;
+
+ qjack_buffer_clear(&c->fifo);
+ return 0;
+}
+
+static void qjack_shutdown(void *arg)
+{
+ QJackClient *c = (QJackClient *)arg;
+
+ switch(c->state)
+ {
+ case QJACK_STATE_RUNNING:
+ jack_transport_stop(c->client);
+ /* fallthrough */
+
+ case QJACK_STATE_IDLE:
+ jack_deactivate(c->client);
+ /* fallthrough */
+
+ default:
+ jack_client_close(c->client);
+ c->state = QJACK_STATE_DISCONNECTED;
+ dolog("shutdown\n");
+ break;
+
+ case QJACK_STATE_DISCONNECTED:
+ break;
+ }
+}
+
+static size_t qjack_write(HWVoiceOut *hw, void *buf, size_t len)
+{
+ QJackOut *jo = (QJackOut *)hw;
+
+ if (jo->c.state != QJACK_STATE_RUNNING)
+ return len;
+
+ return qjack_buffer_write(&jo->c.fifo, buf, len);
+}
+
+static size_t qjack_read(HWVoiceIn *hw, void *buf, size_t len)
+{
+ QJackIn *ji = (QJackIn *)hw;
+
+ if (ji->c.state != QJACK_STATE_RUNNING)
+ return len;
+
+ return qjack_buffer_read(&ji->c.fifo, buf, len);
+}
+
+static int qjack_client_init(QJackClient *c,
+ AudiodevJackPerDirectionOptions *opt, bool out, struct audsettings *as)
+{
+ jack_status_t status;
+ char client_name[jack_client_name_size()];
+ jack_options_t options = JackNullOption;
+
+ c->out = out;
+
+ snprintf(client_name, sizeof(client_name), "%s-%s",
+ out ? "out" : "in",
+ opt->client_name ? opt->client_name : qemu_get_vm_name());
+
+ if (opt->exact_name)
+ options |= JackUseExactName;
+
+ if (!opt->start_server)
+ options |= JackNoStartServer;
+
+ if (opt->server_name)
+ options |= JackServerName;
+
+ c->client = jack_client_open(client_name, options, &status,
+ opt->server_name);
+
+ if (c->client == NULL) {
+ dolog("jack_client_open failed: status = 0x%2.0x\n", status);
+ if (status & JackServerFailed)
+ dolog("unable to connect to JACK server\n");
+ return -1;
+ }
+
+ c->freq = jack_get_sample_rate(c->client);
+
+ if (status & JackServerStarted) {
+ dolog("JACK server started\n");
+ }
+
+ if (status & JackNameNotUnique) {
+ dolog("JACK unique name assigned %s\n",
+ jack_get_client_name(c->client));
+ }
+
+ jack_set_process_callback(c->client, qjack_process , c);
+ jack_set_xrun_callback (c->client, qjack_xrun , c);
+ jack_on_shutdown (c->client, qjack_shutdown, c);
+
+ c->state = QJACK_STATE_CONNECTED;
+
+ /* activate the session */
+ jack_activate(c->client);
+
+ c->nchannels = as->nchannels;
+ c->buffersize = jack_get_buffer_size(c->client);
+
+ /* ensure the buffersize is no smaller then 512 samples, some (all?) qemu
+ * virtual devices do not work correctly otherwise */
+ if (c->buffersize < 512)
+ c->buffersize = 512;
+
+ /* create a 2 period buffer */
+ qjack_buffer_create(&c->fifo, c->nchannels, c->buffersize * 2);
+
+ /* allocate and register the ports */
+ c->port = g_malloc(sizeof(jack_port_t *) * c->nchannels);
+ for(int i = 0; i < c->nchannels; ++i) {
+
+ char port_name[16];
+ snprintf(
+ port_name,
+ sizeof(port_name),
+ out ? "output %d" : "input %d",
+ i);
+
+ c->port[i] = jack_port_register(
+ c->client,
+ port_name,
+ JACK_DEFAULT_AUDIO_TYPE,
+ out ? JackPortIsOutput : JackPortIsInput,
+ 0);
+ }
+
+ c->state = QJACK_STATE_IDLE;
+ return 0;
+}
+
+static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as,
+ void *drv_opaque)
+{
+ QJackOut *jo = (QJackOut *)hw;
+ Audiodev *dev = (Audiodev *)drv_opaque;
+
+ if (jo->c.state != QJACK_STATE_DISCONNECTED)
+ return 0;
+
+ int ret = qjack_client_init(&jo->c, dev->u.jack.out, true, as);
+ if (ret != 0)
+ return ret;
+
+ /* report the buffer size to qemu */
+ hw->samples = jo->c.buffersize;
+
+ /* report the audio format we support */
+ struct audsettings os = {
+ .freq = jo->c.freq,
+ .nchannels = jo->c.nchannels,
+ .fmt = AUDIO_FORMAT_F32,
+ .endianness = 0
+ };
+ audio_pcm_init_info(&hw->info, &os);
+
+ dolog("JACK output configured for %dHz (%d samples)\n",
+ jo->c.freq, jo->c.buffersize);
+
+ return 0;
+}
+
+static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
+ void *drv_opaque)
+{
+ QJackIn *ji = (QJackIn *)hw;
+ Audiodev *dev = (Audiodev *)drv_opaque;
+
+ if (ji->c.state != QJACK_STATE_DISCONNECTED)
+ return 0;
+
+ int ret = qjack_client_init(&ji->c, dev->u.jack.in, false, as);
+ if (ret != 0)
+ return ret;
+
+ /* report the buffer size to qemu */
+ hw->samples = ji->c.buffersize;
+
+ /* report the audio format we support */
+ struct audsettings is = {
+ .freq = ji->c.freq,
+ .nchannels = ji->c.nchannels,
+ .fmt = AUDIO_FORMAT_F32,
+ .endianness = 0
+ };
+ audio_pcm_init_info(&hw->info, &is);
+
+ dolog("JACK input configured for %dHz (%d samples)\n",
+ ji->c.freq, ji->c.buffersize);
+
+ return 0;
+}
+
+
+static void qjack_client_fini(QJackClient *c)
+{
+ qjack_shutdown(c);
+
+ qjack_buffer_free(&c->fifo);
+ for(int i = 0; i < c->nchannels; ++i)
+ jack_port_unregister(c->client, c->port[i]);
+ g_free(c->port);
+}
+
+static void qjack_fini_out(HWVoiceOut *hw)
+{
+ QJackOut *jo = (QJackOut *)hw;
+ qjack_client_fini(&jo->c);
+}
+
+static void qjack_fini_in(HWVoiceIn *hw)
+{
+ QJackIn *ji = (QJackIn *)hw;
+ qjack_client_fini(&ji->c);
+}
+
+static void qjack_enable(QJackClient *c, bool enable)
+{
+ if (c->state != QJACK_STATE_IDLE)
+ return;
+
+ if (enable) {
+ jack_transport_start(c->client);
+ c->state = QJACK_STATE_RUNNING;
+ } else {
+ jack_transport_stop(c->client);
+ c->state = QJACK_STATE_IDLE;
+ }
+}
+
+static void qjack_enable_out(HWVoiceOut *hw, bool enable)
+{
+ QJackOut *jo = (QJackOut *)hw;
+ qjack_enable(&jo->c, enable);
+}
+
+static void qjack_enable_in(HWVoiceIn *hw, bool enable)
+{
+ QJackIn *ji = (QJackIn *)hw;
+ qjack_enable(&ji->c, enable);
+}
+
+static int qjack_thread_creator(jack_native_thread_t * thread,
+ const pthread_attr_t * attr, void *(*function)(void *), void *arg)
+{
+ int ret = pthread_create(thread, attr, function, arg);
+ if (ret != 0)
+ return ret;
+
+ /* set the name of the thread */
+ pthread_setname_np(*thread, "jack-client");
+
+ return ret;
+}
+
+static void* qjack_init(Audiodev *dev)
+{
+ assert(dev->driver == AUDIODEV_DRIVER_JACK);
+
+ dev->u.jack.has_in = false;
+
+ return dev;
+}
+
+static void qjack_fini (void *opaque)
+{
+}
+
+static struct audio_pcm_ops jack_pcm_ops = {
+ .init_out = qjack_init_out,
+ .fini_out = qjack_fini_out,
+ .write = qjack_write,
+ .run_buffer_out = audio_generic_run_buffer_out,
+ .enable_out = qjack_enable_out,
+
+ .init_in = qjack_init_in,
+ .fini_in = qjack_fini_in,
+ .read = qjack_read,
+ .enable_in = qjack_enable_in
+};
+
+static struct audio_driver jack_driver = {
+ .name = "jack",
+ .descr = "JACK Audio Connection Kit Client",
+ .init = qjack_init,
+ .fini = qjack_fini,
+ .pcm_ops = &jack_pcm_ops,
+ .can_be_default = 1,
+ .max_voices_out = INT_MAX,
+ .max_voices_in = INT_MAX,
+ .voice_size_out = sizeof(QJackOut),
+ .voice_size_in = sizeof(QJackIn)
+};
+
+static void register_audio_jack(void)
+{
+ audio_driver_register(&jack_driver);
+ jack_set_thread_creator(qjack_thread_creator);
+}
+type_init(register_audio_jack);
diff --git a/configure b/configure
index 23b5e93752..004502c775 100755
--- a/configure
+++ b/configure
@@ -3629,6 +3629,22 @@ for drv in $audio_drv_list; do
oss_libs="$oss_lib"
;;
+ jack | try-jack)
+ if $pkg_config jack --exists; then
+ jack_libs=$($pkg_config jack --libs)
+ if test "$drv" = "try-jack"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
+ fi
+ else
+ if test "$drv" = "try-jack"; then
+ audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
+ else
+ error_exit "$drv check failed" \
+ "Make sure to have the $drv libs and headers installed."
+ fi
+ fi
+ ;;
+
*)
echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
error_exit "Unknown driver '$drv' selected" \
@@ -6904,6 +6920,7 @@ echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
echo "OSS_LIBS=$oss_libs" >> $config_host_mak
+echo "JACK_LIBS=$jack_libs" >> $config_host_mak
if test "$audio_win_int" = "yes" ; then
echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
fi
diff --git a/qapi/audio.json b/qapi/audio.json
index c31251f45b..c4bd1f65fc 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -152,6 +152,51 @@
'*out': 'AudiodevPerDirectionOptions',
'*latency': 'uint32' } }
+##
+# @AudiodevJackPerDirectionOptions:
+#
+# Options of the JACK backend that are used for both playback and
+# recording.
+#
+# @server_name: select from among several possible concurrent server instances.
+# If unspecified, use "default" unless $JACK_DEFAULT_SERVER is defined in the
+# process environment.
+#
+# @client_name: the client name to use. The server will modify this name to
+# create a unique variant, if needed unless @exact_name is true.
+#
+# @start_server: set to true to start a jack server instance if one is not
+# present.
+#
+# @exact_name: use the exact name requested otherwise JACK automatically
+# generates a unique one, if needed.
+#
+# Since: 4.0
+##
+{ 'struct': 'AudiodevJackPerDirectionOptions',
+ 'base': 'AudiodevPerDirectionOptions',
+ 'data': {
+ '*server_name': 'str',
+ '*client_name': 'str',
+ '*start_server': 'bool',
+ '*exact_name': 'bool' } }
+
+##
+# @AudiodevJackOptions:
+#
+# Options of the JACK audio backend.
+#
+# @in: options of the capture stream
+#
+# @out: options of the playback stream
+#
+# Since: 4.0
+##
+{ 'struct': 'AudiodevJackOptions',
+ 'data': {
+ '*in': 'AudiodevJackPerDirectionOptions',
+ '*out': 'AudiodevJackPerDirectionOptions' } }
+
##
# @AudiodevOssPerDirectionOptions:
#
@@ -300,8 +345,8 @@
# Since: 4.0
##
{ 'enum': 'AudiodevDriver',
- 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'oss', 'pa', 'sdl',
- 'spice', 'wav' ] }
+ 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa',
+ 'sdl', 'spice', 'wav' ] }
##
# @Audiodev:
@@ -327,6 +372,7 @@
'alsa': 'AudiodevAlsaOptions',
'coreaudio': 'AudiodevCoreaudioOptions',
'dsound': 'AudiodevDsoundOptions',
+ 'jack': 'AudiodevJackOptions',
'oss': 'AudiodevOssOptions',
'pa': 'AudiodevPaOptions',
'sdl': 'AudiodevGenericOptions',
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] audio/jack: add JACK client audiodev
2020-04-29 5:53 [PATCH] audio/jack: add JACK client audiodev Geoffrey McRae
@ 2020-04-29 6:59 ` no-reply
0 siblings, 0 replies; 2+ messages in thread
From: no-reply @ 2020-04-29 6:59 UTC (permalink / raw)
To: geoff; +Cc: qemu-devel
Patchew URL: https://patchew.org/QEMU/20200429061054.348B23C0D11@aeryn.lan.ktmba/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Subject: [PATCH] audio/jack: add JACK client audiodev
Message-id: 20200429061054.348B23C0D11@aeryn.lan.ktmba
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/20200428172634.29707-1-f4bug@amsat.org -> patchew/20200428172634.29707-1-f4bug@amsat.org
* [new tag] patchew/20200429061039.12687-1-vsementsov@virtuozzo.com -> patchew/20200429061039.12687-1-vsementsov@virtuozzo.com
Switched to a new branch 'test'
aaf9cf2 audio/jack: add JACK client audiodev
=== OUTPUT BEGIN ===
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#52:
new file mode 100644
ERROR: open brace '{' following enum go on the same line
#97: FILE: audio/jackaudio.c:41:
+typedef enum QJackState
+{
ERROR: open brace '{' following struct go on the same line
#108: FILE: audio/jackaudio.c:52:
+typedef struct QJackBuffer
+{
ERROR: "foo ** bar" should be "foo **bar"
#113: FILE: audio/jackaudio.c:57:
+ float ** data;
ERROR: open brace '{' following struct go on the same line
#118: FILE: audio/jackaudio.c:62:
+typedef struct QJackClient
+{
ERROR: "foo * bar" should be "foo *bar"
#121: FILE: audio/jackaudio.c:65:
+ jack_client_t * client;
ERROR: "foo * bar" should be "foo *bar"
#124: FILE: audio/jackaudio.c:68:
+ struct QJack * j;
ERROR: "foo ** bar" should be "foo **bar"
#127: FILE: audio/jackaudio.c:71:
+ jack_port_t ** port;
ERROR: open brace '{' following struct go on the same line
#133: FILE: audio/jackaudio.c:77:
+typedef struct QJackOut
+{
ERROR: open brace '{' following struct go on the same line
#140: FILE: audio/jackaudio.c:84:
+typedef struct QJackIn
+{
ERROR: "foo * bar" should be "foo *bar"
#146: FILE: audio/jackaudio.c:90:
+static void qjack_buffer_create(QJackBuffer * buffer, int channels, int frames)
ERROR: space required before the open parenthesis '('
#154: FILE: audio/jackaudio.c:98:
+ for(int i = 0; i < channels; ++i)
ERROR: braces {} are necessary for all arms of this statement
#154: FILE: audio/jackaudio.c:98:
+ for(int i = 0; i < channels; ++i)
[...]
ERROR: "foo * bar" should be "foo *bar"
#158: FILE: audio/jackaudio.c:102:
+static void qjack_buffer_clear(QJackBuffer * buffer)
ERROR: "foo * bar" should be "foo *bar"
#165: FILE: audio/jackaudio.c:109:
+static void qjack_buffer_free(QJackBuffer * buffer)
ERROR: space required before the open parenthesis '('
#167: FILE: audio/jackaudio.c:111:
+ for(int i = 0; i < buffer->channels; ++i)
ERROR: braces {} are necessary for all arms of this statement
#167: FILE: audio/jackaudio.c:111:
+ for(int i = 0; i < buffer->channels; ++i)
[...]
ERROR: "foo * bar" should be "foo *bar"
#174: FILE: audio/jackaudio.c:118:
+inline static int qjack_buffer_used(QJackBuffer * buffer)
ERROR: storage class should be at the beginning of the declaration
#174: FILE: audio/jackaudio.c:118:
+inline static int qjack_buffer_used(QJackBuffer * buffer)
ERROR: inline keyword should sit between storage class and type
#174: FILE: audio/jackaudio.c:118:
+inline static int qjack_buffer_used(QJackBuffer * buffer)
ERROR: "foo * bar" should be "foo *bar"
#180: FILE: audio/jackaudio.c:124:
+static int qjack_buffer_write(QJackBuffer * buffer, float * data, int size)
ERROR: braces {} are necessary for all arms of this statement
#187: FILE: audio/jackaudio.c:131:
+ if (frames > avail)
[...]
ERROR: space required before the open parenthesis '('
#193: FILE: audio/jackaudio.c:137:
+ while(copy) {
ERROR: space required before the open parenthesis '('
#195: FILE: audio/jackaudio.c:139:
+ for(int c = 0; c < buffer->channels; ++c)
ERROR: braces {} are necessary for all arms of this statement
#195: FILE: audio/jackaudio.c:139:
+ for(int c = 0; c < buffer->channels; ++c)
[...]
ERROR: braces {} are necessary for all arms of this statement
#198: FILE: audio/jackaudio.c:142:
+ if (++wptr == buffer->frames)
[...]
ERROR: "foo * bar" should be "foo *bar"
#211: FILE: audio/jackaudio.c:155:
+static int qjack_buffer_write_l(QJackBuffer * buffer, float ** dest, int frames)
ERROR: braces {} are necessary for all arms of this statement
#217: FILE: audio/jackaudio.c:161:
+ if (frames > avail)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#221: FILE: audio/jackaudio.c:165:
+ if (right > frames)
+ right = frames;
ERROR: braces {} are necessary for all arms of this statement
#221: FILE: audio/jackaudio.c:165:
+ if (right > frames)
[...]
ERROR: space required before the open parenthesis '('
#225: FILE: audio/jackaudio.c:169:
+ for(int c = 0; c < buffer->channels; ++c) {
ERROR: suspect code indent for conditional statements (4, 6)
#231: FILE: audio/jackaudio.c:175:
+ if (wptr >= buffer->frames)
+ wptr -= buffer->frames;
ERROR: braces {} are necessary for all arms of this statement
#231: FILE: audio/jackaudio.c:175:
+ if (wptr >= buffer->frames)
[...]
ERROR: "foo * bar" should be "foo *bar"
#240: FILE: audio/jackaudio.c:184:
+static int qjack_buffer_read(QJackBuffer * buffer, float * dest, int size)
ERROR: braces {} are necessary for all arms of this statement
#247: FILE: audio/jackaudio.c:191:
+ if (frames > avail)
[...]
ERROR: space required before the open parenthesis '('
#253: FILE: audio/jackaudio.c:197:
+ while(copy) {
ERROR: space required before the open parenthesis '('
#255: FILE: audio/jackaudio.c:199:
+ for(int c = 0; c < buffer->channels; ++c)
ERROR: braces {} are necessary for all arms of this statement
#255: FILE: audio/jackaudio.c:199:
+ for(int c = 0; c < buffer->channels; ++c)
[...]
ERROR: braces {} are necessary for all arms of this statement
#258: FILE: audio/jackaudio.c:202:
+ if (++rptr == buffer->frames)
[...]
ERROR: "foo * bar" should be "foo *bar"
#271: FILE: audio/jackaudio.c:215:
+static int qjack_buffer_read_l(QJackBuffer * buffer, float ** dest, int frames)
ERROR: braces {} are necessary for all arms of this statement
#277: FILE: audio/jackaudio.c:221:
+ if (copy > used)
[...]
ERROR: braces {} are necessary for all arms of this statement
#281: FILE: audio/jackaudio.c:225:
+ if (right > copy)
[...]
ERROR: space required before the open parenthesis '('
#285: FILE: audio/jackaudio.c:229:
+ for(int c = 0; c < buffer->channels; ++c) {
ERROR: braces {} are necessary for all arms of this statement
#291: FILE: audio/jackaudio.c:235:
+ if (rptr >= buffer->frames)
[...]
ERROR: braces {} are necessary for all arms of this statement
#306: FILE: audio/jackaudio.c:250:
+ if (c->state != QJACK_STATE_RUNNING)
[...]
ERROR: "foo * bar" should be "foo *bar"
#310: FILE: audio/jackaudio.c:254:
+ float * buffers[c->nchannels];
ERROR: space required before the open parenthesis '('
#311: FILE: audio/jackaudio.c:255:
+ for(int i = 0; i < c->nchannels; ++i)
ERROR: braces {} are necessary for all arms of this statement
#311: FILE: audio/jackaudio.c:255:
+ for(int i = 0; i < c->nchannels; ++i)
[...]
ERROR: braces {} are necessary for all arms of this statement
#314: FILE: audio/jackaudio.c:258:
+ if (c->out)
[...]
+ else
[...]
ERROR: braces {} are necessary for all arms of this statement
#321: FILE: audio/jackaudio.c:265:
+ if (c->state == QJACK_STATE_RUNNING)
[...]
ERROR: "foo * bar" should be "foo *bar"
#329: FILE: audio/jackaudio.c:273:
+static int qjack_xrun(void * arg)
ERROR: braces {} are necessary for all arms of this statement
#333: FILE: audio/jackaudio.c:277:
+ if (c->state != QJACK_STATE_RUNNING)
[...]
ERROR: that open brace { should be on the previous line
#344: FILE: audio/jackaudio.c:288:
+ switch(c->state)
+ {
ERROR: space required before the open parenthesis '('
#344: FILE: audio/jackaudio.c:288:
+ switch(c->state)
ERROR: suspect code indent for conditional statements (4, 6)
#369: FILE: audio/jackaudio.c:313:
+ if (jo->c.state != QJACK_STATE_RUNNING)
+ return len;
ERROR: braces {} are necessary for all arms of this statement
#369: FILE: audio/jackaudio.c:313:
+ if (jo->c.state != QJACK_STATE_RUNNING)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#379: FILE: audio/jackaudio.c:323:
+ if (ji->c.state != QJACK_STATE_RUNNING)
+ return len;
ERROR: braces {} are necessary for all arms of this statement
#379: FILE: audio/jackaudio.c:323:
+ if (ji->c.state != QJACK_STATE_RUNNING)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#398: FILE: audio/jackaudio.c:342:
+ if (opt->exact_name)
+ options |= JackUseExactName;
ERROR: braces {} are necessary for all arms of this statement
#398: FILE: audio/jackaudio.c:342:
+ if (opt->exact_name)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#401: FILE: audio/jackaudio.c:345:
+ if (!opt->start_server)
+ options |= JackNoStartServer;
ERROR: braces {} are necessary for all arms of this statement
#401: FILE: audio/jackaudio.c:345:
+ if (!opt->start_server)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#404: FILE: audio/jackaudio.c:348:
+ if (opt->server_name)
+ options |= JackServerName;
ERROR: braces {} are necessary for all arms of this statement
#404: FILE: audio/jackaudio.c:348:
+ if (opt->server_name)
[...]
ERROR: suspect code indent for conditional statements (8, 10)
#412: FILE: audio/jackaudio.c:356:
+ if (status & JackServerFailed)
+ dolog("unable to connect to JACK server\n");
ERROR: braces {} are necessary for all arms of this statement
#412: FILE: audio/jackaudio.c:356:
+ if (status & JackServerFailed)
[...]
ERROR: space prohibited between function name and open parenthesis '('
#429: FILE: audio/jackaudio.c:373:
+ jack_set_xrun_callback (c->client, qjack_xrun , c);
ERROR: space prohibited between function name and open parenthesis '('
#430: FILE: audio/jackaudio.c:374:
+ jack_on_shutdown (c->client, qjack_shutdown, c);
WARNING: Block comments use a leading /* on a separate line
#440: FILE: audio/jackaudio.c:384:
+ /* ensure the buffersize is no smaller then 512 samples, some (all?) qemu
WARNING: Block comments use a trailing */ on a separate line
#441: FILE: audio/jackaudio.c:385:
+ * virtual devices do not work correctly otherwise */
ERROR: braces {} are necessary for all arms of this statement
#442: FILE: audio/jackaudio.c:386:
+ if (c->buffersize < 512)
[...]
ERROR: space required before the open parenthesis '('
#450: FILE: audio/jackaudio.c:394:
+ for(int i = 0; i < c->nchannels; ++i) {
ERROR: braces {} are necessary for all arms of this statement
#477: FILE: audio/jackaudio.c:421:
+ if (jo->c.state != QJACK_STATE_DISCONNECTED)
[...]
ERROR: braces {} are necessary for all arms of this statement
#481: FILE: audio/jackaudio.c:425:
+ if (ret != 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#508: FILE: audio/jackaudio.c:452:
+ if (ji->c.state != QJACK_STATE_DISCONNECTED)
[...]
ERROR: braces {} are necessary for all arms of this statement
#512: FILE: audio/jackaudio.c:456:
+ if (ret != 0)
[...]
ERROR: space required before the open parenthesis '('
#539: FILE: audio/jackaudio.c:483:
+ for(int i = 0; i < c->nchannels; ++i)
ERROR: braces {} are necessary for all arms of this statement
#539: FILE: audio/jackaudio.c:483:
+ for(int i = 0; i < c->nchannels; ++i)
[...]
ERROR: braces {} are necessary for all arms of this statement
#558: FILE: audio/jackaudio.c:502:
+ if (c->state != QJACK_STATE_IDLE)
[...]
ERROR: "foo * bar" should be "foo *bar"
#582: FILE: audio/jackaudio.c:526:
+static int qjack_thread_creator(jack_native_thread_t * thread,
ERROR: braces {} are necessary for all arms of this statement
#586: FILE: audio/jackaudio.c:530:
+ if (ret != 0)
[...]
ERROR: "foo* bar" should be "foo *bar"
#595: FILE: audio/jackaudio.c:539:
+static void* qjack_init(Audiodev *dev)
ERROR: space prohibited between function name and open parenthesis '('
#604: FILE: audio/jackaudio.c:548:
+static void qjack_fini (void *opaque)
total: 80 errors, 3 warnings, 703 lines checked
Commit aaf9cf216407 (audio/jack: add JACK client audiodev) has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20200429061054.348B23C0D11@aeryn.lan.ktmba/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-29 7:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 5:53 [PATCH] audio/jack: add JACK client audiodev Geoffrey McRae
2020-04-29 6:59 ` no-reply
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.