All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing.
@ 2019-01-23 15:21 Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 1/6] audio: use pkg-config Gerd Hoffmann
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann



Gerd Hoffmann (6):
  audio: use pkg-config
  audio: allow optional audio drivers.
  audio: use try-sdl for openbsd
  audio: check for pulseaudio daemon pidfile
  audio: error message tweak
  audio: probe audio drivers by default

 configure       | 81 ++++++++++++++++++++++++++++++++-------------------------
 audio/audio.c   | 11 ++++----
 audio/paaudio.c | 13 +++++++++
 3 files changed, 64 insertions(+), 41 deletions(-)

-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 1/6] audio: use pkg-config
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 2/6] audio: allow optional audio drivers Gerd Hoffmann
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

Use pkg-config to probe for alsa and pulseaudio.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/configure b/configure
index de768e2343..0af38f0cec 100755
--- a/configure
+++ b/configure
@@ -3303,39 +3303,26 @@ fi
 ##########################################
 # Sound support libraries probe
 
-audio_drv_probe()
-{
-    drv=$1
-    hdr=$2
-    lib=$3
-    exp=$4
-    cfl=$5
-        cat > $TMPC << EOF
-#include <$hdr>
-int main(void) { $exp }
-EOF
-    if compile_prog "$cfl" "$lib" ; then
-        :
-    else
-        error_exit "$drv check failed" \
-            "Make sure to have the $drv libs and headers installed."
-    fi
-}
-
 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
 for drv in $audio_drv_list; do
     case $drv in
     alsa)
-    audio_drv_probe $drv alsa/asoundlib.h -lasound \
-        "return snd_pcm_close((snd_pcm_t *)0);"
-    alsa_libs="-lasound"
+    if $pkg_config alsa --exists; then
+        alsa_libs=$($pkg_config alsa --libs)
+    else
+        error_exit "$drv check failed" \
+            "Make sure to have the $drv libs and headers installed."
+    fi
     ;;
 
     pa)
-    audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
-        "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
-    pulse_libs="-lpulse"
-    audio_pt_int="yes"
+    if $pkg_config libpulse --exists; then
+        pulse_libs=$($pkg_config libpulse --libs)
+        audio_pt_int="yes"
+    else
+        error_exit "$drv check failed" \
+            "Make sure to have the $drv libs and headers installed."
+    fi
     ;;
 
     sdl)
-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 2/6] audio: allow optional audio drivers.
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 1/6] audio: use pkg-config Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 3/6] audio: use try-sdl for openbsd Gerd Hoffmann
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

For those audio drivers which can be probed (sdl, alsa, pulse) add a
try-$name variants.  Unlike the variants without try- prefix they will
not error out on probe failure, the driver will be dropped from the list
instead.  Mainly useful for the audio_drv_list default values.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 0af38f0cec..d32e4f6dbb 100755
--- a/configure
+++ b/configure
@@ -3306,22 +3306,36 @@ fi
 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
 for drv in $audio_drv_list; do
     case $drv in
-    alsa)
+    alsa | try-alsa)
     if $pkg_config alsa --exists; then
         alsa_libs=$($pkg_config alsa --libs)
+        if test "$drv" = "try-alsa"; then
+            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
+        fi
     else
-        error_exit "$drv check failed" \
-            "Make sure to have the $drv libs and headers installed."
+        if test "$drv" = "try-alsa"; then
+            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
+        else
+            error_exit "$drv check failed" \
+                "Make sure to have the $drv libs and headers installed."
+        fi
     fi
     ;;
 
-    pa)
+    pa | try-pa)
     if $pkg_config libpulse --exists; then
         pulse_libs=$($pkg_config libpulse --libs)
         audio_pt_int="yes"
+        if test "$drv" = "try-pa"; then
+            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
+        fi
     else
-        error_exit "$drv check failed" \
-            "Make sure to have the $drv libs and headers installed."
+        if test "$drv" = "try-pa"; then
+            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
+        else
+            error_exit "$drv check failed" \
+                "Make sure to have the $drv libs and headers installed."
+        fi
     fi
     ;;
 
@@ -3331,6 +3345,14 @@ for drv in $audio_drv_list; do
     fi
     ;;
 
+    try-sdl)
+    if test "$sdl" = "no"; then
+        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
+    else
+        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
+    fi
+    ;;
+
     coreaudio)
       coreaudio_libs="-framework CoreAudio"
     ;;
-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 3/6] audio: use try-sdl for openbsd
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 1/6] audio: use pkg-config Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 2/6] audio: allow optional audio drivers Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 4/6] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

Fixes the openbsd build failure with SDL disabled.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index d32e4f6dbb..99f3c10759 100755
--- a/configure
+++ b/configure
@@ -828,7 +828,7 @@ NetBSD)
 OpenBSD)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="sdl"
+  audio_drv_list="try-sdl"
   audio_possible_drivers="sdl"
   HOST_VARIANT_DIR="openbsd"
   supported_os="yes"
-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 4/6] audio: check for pulseaudio daemon pidfile
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 3/6] audio: use try-sdl for openbsd Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 5/6] audio: error message tweak Gerd Hoffmann
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

Check whenever the pulseaudio daemon pidfile is present before trying to
initialize the pulseaudio backend.  Just return NULL if that is not the
case, so qemu will check the next backend in line.

In case the user explicitly configured a non-default pulseaudio server
skip the check.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/paaudio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 4c100bc318..3c5cae8851 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -814,6 +814,19 @@ static PAConf glob_conf = {
 
 static void *qpa_audio_init (void)
 {
+    if (glob_conf.server == NULL) {
+        char pidfile[64];
+        char *runtime;
+        struct stat st;
+
+        runtime = getenv("XDG_RUNTIME_DIR");
+        if (!runtime)
+            return NULL;
+        snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime);
+        if (stat(pidfile, &st) != 0)
+            return NULL;
+    }
+
     paaudio *g = g_malloc(sizeof(paaudio));
     g->conf = glob_conf;
     g->mainloop = NULL;
-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 5/6] audio: error message tweak
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 4/6] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 6/6] audio: probe audio drivers by default Gerd Hoffmann
  2019-01-31 17:49 ` [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing no-reply
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

Only print a message about the failed driver initialization in case it
was the driver explicitly requested by the user via QEMU_AUDIO_DRV=$drv.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/audio.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index 1ace47f510..3e40ea9e5e 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1762,7 +1762,7 @@ void AUD_help (void)
         );
 }
 
-static int audio_driver_init (AudioState *s, struct audio_driver *drv)
+static int audio_driver_init (AudioState *s, struct audio_driver *drv, bool msg)
 {
     if (drv->options) {
         audio_process_options (drv->name, drv->options);
@@ -1776,7 +1776,8 @@ static int audio_driver_init (AudioState *s, struct audio_driver *drv)
         return 0;
     }
     else {
-        dolog ("Could not init `%s' audio driver\n", drv->name);
+        if (msg)
+            dolog ("Could not init `%s' audio driver\n", drv->name);
         return -1;
     }
 }
@@ -1901,7 +1902,7 @@ static void audio_init (void)
     if (drvname) {
         driver = audio_driver_lookup(drvname);
         if (driver) {
-            done = !audio_driver_init(s, driver);
+            done = !audio_driver_init(s, driver, true);
         } else {
             dolog ("Unknown audio driver `%s'\n", drvname);
             dolog ("Run with -audio-help to list available drivers\n");
@@ -1912,14 +1913,14 @@ static void audio_init (void)
         for (i = 0; !done && i < ARRAY_SIZE(audio_prio_list); i++) {
             driver = audio_driver_lookup(audio_prio_list[i]);
             if (driver && driver->can_be_default) {
-                done = !audio_driver_init(s, driver);
+                done = !audio_driver_init(s, driver, false);
             }
         }
     }
 
     if (!done) {
         driver = audio_driver_lookup("none");
-        done = !audio_driver_init(s, driver);
+        done = !audio_driver_init(s, driver, false);
         assert(done);
         dolog("warning: Using timer based audio emulation\n");
     }
-- 
2.9.3

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

* [Qemu-devel] [PATCH v2 6/6] audio: probe audio drivers by default
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 5/6] audio: error message tweak Gerd Hoffmann
@ 2019-01-23 15:21 ` Gerd Hoffmann
  2019-01-31 17:49 ` [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing no-reply
  6 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-23 15:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Philippe Mathieu-Daudé, Gerd Hoffmann

Add the drivers listed in audio_possible_drivers to audio_drv_list,
using the try-* variants.  That way the probable drivers are compiled by
default if possible.

Reordered linux drivers, order is now: pa alsa sdl oss

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 configure | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 99f3c10759..cb6ae555fc 100755
--- a/configure
+++ b/configure
@@ -793,13 +793,13 @@ MINGW32*)
 ;;
 GNU/kFreeBSD)
   bsd="yes"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl try-pa"
   audio_possible_drivers="oss sdl pa"
 ;;
 FreeBSD)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl try-pa"
   audio_possible_drivers="oss sdl pa"
   # needed for kinfo_getvmmap(3) in libutil.h
   LIBS="-lutil $LIBS"
@@ -812,14 +812,14 @@ FreeBSD)
 DragonFly)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl try-pa"
   audio_possible_drivers="oss sdl pa"
   HOST_VARIANT_DIR="dragonfly"
 ;;
 NetBSD)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl"
   audio_possible_drivers="oss sdl"
   oss_lib="-lossaudio"
   HOST_VARIANT_DIR="netbsd"
@@ -844,7 +844,7 @@ Darwin)
     LDFLAGS="-arch x86_64 $LDFLAGS"
   fi
   cocoa="yes"
-  audio_drv_list="coreaudio"
+  audio_drv_list="coreaudio try-sdl"
   audio_possible_drivers="coreaudio sdl"
   LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
   libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
@@ -860,7 +860,7 @@ SunOS)
   install="${INSTALL-ginstall}"
   smbd="${SMBD-/usr/sfw/sbin/smbd}"
   if test -f /usr/include/sys/soundcard.h ; then
-    audio_drv_list="oss"
+    audio_drv_list="oss try-sdl"
   fi
   audio_possible_drivers="oss sdl"
 # needed for CMSG_ macros in sys/socket.h
@@ -878,7 +878,7 @@ Haiku)
   LIBS="-lposix_error_mapper -lnetwork $LIBS"
 ;;
 Linux)
-  audio_drv_list="oss"
+  audio_drv_list="try-pa try-alsa try-sdl oss"
   audio_possible_drivers="oss alsa sdl pa"
   linux="yes"
   linux_user="yes"
-- 
2.9.3

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

* Re: [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing.
  2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 6/6] audio: probe audio drivers by default Gerd Hoffmann
@ 2019-01-31 17:49 ` no-reply
  6 siblings, 0 replies; 8+ messages in thread
From: no-reply @ 2019-01-31 17:49 UTC (permalink / raw)
  To: kraxel; +Cc: fam, qemu-devel, philmd, brad

Patchew URL: https://patchew.org/QEMU/20190123152112.15757-1-kraxel@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing.
Type: series
Message-id: 20190123152112.15757-1-kraxel@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
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
Switched to a new branch 'test'
fea799eca6 audio: probe audio drivers by default
722a65b21c audio: error message tweak
1db7b38a1f audio: check for pulseaudio daemon pidfile
fdf2993915 audio: use try-sdl for openbsd
7ab8105158 audio: allow optional audio drivers.
c971b5eb6b audio: use pkg-config

=== OUTPUT BEGIN ===
1/6 Checking commit c971b5eb6b54 (audio: use pkg-config)
2/6 Checking commit 7ab810515823 (audio: allow optional audio drivers.)
3/6 Checking commit fdf2993915d6 (audio: use try-sdl for openbsd)
4/6 Checking commit 1db7b38a1f9d (audio: check for pulseaudio daemon pidfile)
ERROR: braces {} are necessary for all arms of this statement
#31: FILE: audio/paaudio.c:823:
+        if (!runtime)
[...]

ERROR: braces {} are necessary for all arms of this statement
#34: FILE: audio/paaudio.c:826:
+        if (stat(pidfile, &st) != 0)
[...]

total: 2 errors, 0 warnings, 19 lines checked

Patch 4/6 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

5/6 Checking commit 722a65b21c13 (audio: error message tweak)
ERROR: space prohibited between function name and open parenthesis '('
#22: FILE: audio/audio.c:1765:
+static int audio_driver_init (AudioState *s, struct audio_driver *drv, bool msg)

ERROR: braces {} are necessary for all arms of this statement
#31: FILE: audio/audio.c:1779:
+        if (msg)
[...]

ERROR: space prohibited between function name and open parenthesis '('
#32: FILE: audio/audio.c:1780:
+            dolog ("Could not init `%s' audio driver\n", drv->name);

total: 3 errors, 0 warnings, 41 lines checked

Patch 5/6 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

6/6 Checking commit fea799eca604 (audio: probe audio drivers by default)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190123152112.15757-1-kraxel@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

end of thread, other threads:[~2019-01-31 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 15:21 [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 1/6] audio: use pkg-config Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 2/6] audio: allow optional audio drivers Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 3/6] audio: use try-sdl for openbsd Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 4/6] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 5/6] audio: error message tweak Gerd Hoffmann
2019-01-23 15:21 ` [Qemu-devel] [PATCH v2 6/6] audio: probe audio drivers by default Gerd Hoffmann
2019-01-31 17:49 ` [Qemu-devel] [PATCH v2 0/6] audio: rework driver probing 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.