audio: rework driver probing.
v2 cover audio: rework driver probing.
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(-)
Signature · 1 line
2.9.3
PATCH v2 1/6 audio: use pkg-config
Use pkg-config to probe for alsa and pulseaudio.
--- configure | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
configure +13 -26
@@ -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)
Signature · 1 line
2.9.3
PATCH v2 2/6 audio: allow optional audio drivers.
In reply to Gerd HoffmannFor 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.
--- configure | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
configure +28 -6
@@ -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" ;;
Signature · 1 line
2.9.3
PATCH v2 3/6 audio: use try-sdl for openbsd
In reply to Gerd HoffmannFixes the openbsd build failure with SDL disabled.
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -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"
Signature · 1 line
2.9.3
PATCH v2 4/6 audio: check for pulseaudio daemon pidfile
In reply to Gerd HoffmannCheck 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.
--- audio/paaudio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
audio/paaudio.c +13 -0
@@ -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 ;
Signature · 1 line
2.9.3
PATCH v2 5/6 audio: error message tweak
In reply to Gerd HoffmannOnly print a message about the failed driver initialization in case it was the driver explicitly requested by the user via QEMU_AUDIO_DRV=$drv.
--- audio/audio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
audio/audio.c +6 -5
@@ -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" ); }
Signature · 1 line
2.9.3
PATCH v2 6/6 audio: probe audio drivers by default
In reply to Gerd HoffmannAdd 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
--- configure | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
configure +7 -7
@@ -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"
Signature · 1 line
2.9.3
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
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: [email protected]
=== 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/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]