From 37a54d054f5aac43cb5721c68954b8b76d0db12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20R=C3=BCmelin?= Date: Mon, 17 May 2021 21:46:03 +0200 Subject: [PATCH] audio: move code to audio/audio.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the code to generate the pa_context_new() application name argument to a function in audio/audio.c. The new function audio_application_name() will also be used in the jackaudio backend. Signed-off-by: Volker RĂ¼melin Message-Id: <20210517194604.2545-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- audio/audio.c | 9 +++++++++ audio/audio_int.h | 2 ++ audio/paaudio.c | 5 +---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 534278edfe..052ca6cb78 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -32,6 +32,7 @@ #include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" #include "qemu/module.h" +#include "qemu-common.h" #include "sysemu/replay.h" #include "sysemu/runstate.h" #include "ui/qemu-spice.h" @@ -2172,6 +2173,14 @@ const char *audio_get_id(QEMUSoundCard *card) } } +const char *audio_application_name(void) +{ + const char *vm_name; + + vm_name = qemu_get_vm_name(); + return vm_name ? vm_name : "qemu"; +} + void audio_rate_start(RateCtl *rate) { memset(rate, 0, sizeof(RateCtl)); diff --git a/audio/audio_int.h b/audio/audio_int.h index 06f0913835..6d685e24a3 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -243,6 +243,8 @@ void *audio_calloc (const char *funcname, int nmemb, size_t size); void audio_run(AudioState *s, const char *msg); +const char *audio_application_name(void); + typedef struct RateCtl { int64_t start_ticks; int64_t bytes_sent; diff --git a/audio/paaudio.c b/audio/paaudio.c index 14b4269c55..75401d5391 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -2,7 +2,6 @@ #include "qemu/osdep.h" #include "qemu/module.h" -#include "qemu-common.h" #include "audio.h" #include "qapi/opts-visitor.h" @@ -753,7 +752,6 @@ static int qpa_validate_per_direction_opts(Audiodev *dev, /* common */ static void *qpa_conn_init(const char *server) { - const char *vm_name; PAConnection *c = g_malloc0(sizeof(PAConnection)); QTAILQ_INSERT_TAIL(&pa_conns, c, list); @@ -762,9 +760,8 @@ static void *qpa_conn_init(const char *server) goto fail; } - vm_name = qemu_get_vm_name(); c->context = pa_context_new(pa_threaded_mainloop_get_api(c->mainloop), - vm_name ? vm_name : "qemu"); + audio_application_name()); if (!c->context) { goto fail; }