All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Misc. audio patches
@ 2021-05-17 19:45 Volker Rümelin
  2021-05-17 19:46 ` [PATCH 1/4] alsaaudio: remove #ifdef DEBUG to avoid bit rot Volker Rümelin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Volker Rümelin @ 2021-05-17 19:45 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

A small collection of patches for the audio subsystem.

It took me one evening to get a working audio system with JACK.
I never associated the in-(NULL) and out-(NULL) devices in the
patch bay with qemu.

With best regards,
Volker

Volker Rümelin (4):
   alsaaudio: remove #ifdef DEBUG to avoid bit rot
   paaudio: remove unused stream flags
   audio: move code to audio/audio.c
   jackaudio: avoid that the client name contains the word (NULL)

  audio/alsaaudio.c | 10 ++++------
  audio/audio.c     |  9 +++++++++
  audio/audio_int.h |  2 ++
  audio/jackaudio.c |  3 +--
  audio/paaudio.c   | 10 ++--------
  5 files changed, 18 insertions(+), 16 deletions(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] alsaaudio: remove #ifdef DEBUG to avoid bit rot
  2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
@ 2021-05-17 19:46 ` Volker Rümelin
  2021-05-17 19:46 ` [PATCH 2/4] paaudio: remove unused stream flags Volker Rümelin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Volker Rümelin @ 2021-05-17 19:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Merge the #ifdef DEBUG code with the if statement a few lines
above to avoid bit rot.

Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 audio/alsaaudio.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index fcc2f62864..2b9789e647 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -34,6 +34,8 @@
 #define AUDIO_CAP "alsa"
 #include "audio_int.h"
 
+#define DEBUG_ALSA 0
+
 struct pollhlp {
     snd_pcm_t *handle;
     struct pollfd *pfds;
@@ -587,16 +589,12 @@ static int alsa_open(bool in, struct alsa_params_req *req,
 
     *handlep = handle;
 
-    if (obtfmt != req->fmt ||
-         obt->nchannels != req->nchannels ||
-         obt->freq != req->freq) {
+    if (DEBUG_ALSA || obtfmt != req->fmt ||
+        obt->nchannels != req->nchannels || obt->freq != req->freq) {
         dolog ("Audio parameters for %s\n", typ);
         alsa_dump_info(req, obt, obtfmt, apdo);
     }
 
-#ifdef DEBUG
-    alsa_dump_info(req, obt, obtfmt, apdo);
-#endif
     return 0;
 
  err:
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] paaudio: remove unused stream flags
  2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
  2021-05-17 19:46 ` [PATCH 1/4] alsaaudio: remove #ifdef DEBUG to avoid bit rot Volker Rümelin
@ 2021-05-17 19:46 ` Volker Rümelin
  2021-05-17 19:46 ` [PATCH 3/4] audio: move code to audio/audio.c Volker Rümelin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Volker Rümelin @ 2021-05-17 19:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

In current code there are no calls to pa_stream_get_latency()
or pa_stream_get_time() to receive latency or time information.

Remove the flags PA_STREAM_INTERPOLATE_TIMING and
PA_STREAM_AUTO_TIMING_UPDATE which instruct PulseAudio to
calculate this information in regular intervals.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 audio/paaudio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index c97b22e970..14b4269c55 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -463,10 +463,7 @@ static pa_stream *qpa_simple_new (
 
     pa_stream_set_state_callback(stream, stream_state_cb, c);
 
-    flags =
-        PA_STREAM_INTERPOLATE_TIMING
-        | PA_STREAM_AUTO_TIMING_UPDATE
-        | PA_STREAM_EARLY_REQUESTS;
+    flags = PA_STREAM_EARLY_REQUESTS;
 
     if (dev) {
         /* don't move the stream if the user specified a sink/source */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] audio: move code to audio/audio.c
  2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
  2021-05-17 19:46 ` [PATCH 1/4] alsaaudio: remove #ifdef DEBUG to avoid bit rot Volker Rümelin
  2021-05-17 19:46 ` [PATCH 2/4] paaudio: remove unused stream flags Volker Rümelin
@ 2021-05-17 19:46 ` Volker Rümelin
  2021-05-17 19:46 ` [PATCH 4/4] jackaudio: avoid that the client name contains the word (NULL) Volker Rümelin
  2021-05-18 10:21 ` [PATCH 0/4] Misc. audio patches Gerd Hoffmann
  4 siblings, 0 replies; 6+ messages in thread
From: Volker Rümelin @ 2021-05-17 19:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

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 <vr_qemu@t-online.de>
---
 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;
     }
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] jackaudio: avoid that the client name contains the word (NULL)
  2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
                   ` (2 preceding siblings ...)
  2021-05-17 19:46 ` [PATCH 3/4] audio: move code to audio/audio.c Volker Rümelin
@ 2021-05-17 19:46 ` Volker Rümelin
  2021-05-18 10:21 ` [PATCH 0/4] Misc. audio patches Gerd Hoffmann
  4 siblings, 0 replies; 6+ messages in thread
From: Volker Rümelin @ 2021-05-17 19:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel

Currently with jackaudio client name and qemu guest name unset,
the JACK client names are out-(NULL) and in-(NULL). These names
are user visible in the patch bay. Replace the function call to
qemu_get_vm_name() with a call to audio_application_name() which
replaces NULL with "qemu" to have more descriptive names.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
---
 audio/jackaudio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/audio/jackaudio.c b/audio/jackaudio.c
index 3031c4e29b..e7de6d5433 100644
--- a/audio/jackaudio.c
+++ b/audio/jackaudio.c
@@ -26,7 +26,6 @@
 #include "qemu/module.h"
 #include "qemu/atomic.h"
 #include "qemu/main-loop.h"
-#include "qemu-common.h"
 #include "audio.h"
 
 #define AUDIO_CAP "jack"
@@ -412,7 +411,7 @@ static int qjack_client_init(QJackClient *c)
 
     snprintf(client_name, sizeof(client_name), "%s-%s",
         c->out ? "out" : "in",
-        c->opt->client_name ? c->opt->client_name : qemu_get_vm_name());
+        c->opt->client_name ? c->opt->client_name : audio_application_name());
 
     if (c->opt->exact_name) {
         options |= JackUseExactName;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] Misc. audio patches
  2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
                   ` (3 preceding siblings ...)
  2021-05-17 19:46 ` [PATCH 4/4] jackaudio: avoid that the client name contains the word (NULL) Volker Rümelin
@ 2021-05-18 10:21 ` Gerd Hoffmann
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2021-05-18 10:21 UTC (permalink / raw)
  To: Volker Rümelin; +Cc: qemu-devel

On Mon, May 17, 2021 at 09:45:04PM +0200, Volker Rümelin wrote:
> A small collection of patches for the audio subsystem.
> 
> It took me one evening to get a working audio system with JACK.
> I never associated the in-(NULL) and out-(NULL) devices in the
> patch bay with qemu.

Added all to audio queue.

thanks,
  Gerd



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-18 10:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 19:45 [PATCH 0/4] Misc. audio patches Volker Rümelin
2021-05-17 19:46 ` [PATCH 1/4] alsaaudio: remove #ifdef DEBUG to avoid bit rot Volker Rümelin
2021-05-17 19:46 ` [PATCH 2/4] paaudio: remove unused stream flags Volker Rümelin
2021-05-17 19:46 ` [PATCH 3/4] audio: move code to audio/audio.c Volker Rümelin
2021-05-17 19:46 ` [PATCH 4/4] jackaudio: avoid that the client name contains the word (NULL) Volker Rümelin
2021-05-18 10:21 ` [PATCH 0/4] Misc. audio patches Gerd Hoffmann

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.