qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/7] Audio 20190124 patches
@ 2019-01-24 13:20 Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 1/7] audio: fix pc speaker init Gerd Hoffmann
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Gerd Hoffmann

The following changes since commit f6b06fcceef465de0cf2514c9f76fe0192896781:

  Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190121-pull-request' into staging (2019-01-23 17:57:47 +0000)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/audio-20190124-pull-request

for you to fetch changes up to 6a48541873f14b597630283f8f5397674ad82ea9:

  audio: probe audio drivers by default (2019-01-24 13:11:08 +0100)

----------------------------------------------------------------
audio: pc speaker init fix, rework driver probing

----------------------------------------------------------------

Gerd Hoffmann (7):
  audio: fix pc speaker init
  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    | 12 +++++----
 audio/paaudio.c  | 15 +++++++++++
 hw/audio/pcspk.c | 35 +++++++++++-------------
 4 files changed, 82 insertions(+), 61 deletions(-)

-- 
2.9.3

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

* [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-02-12 11:47   ` David Hildenbrand
  2019-01-24 13:20 ` [Qemu-devel] [PULL 2/7] audio: use pkg-config Gerd Hoffmann
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Gerd Hoffmann

Get rid of the pcspk_state global, allow pc speaker
be added using "-device isa-pcspk".

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124110810.1040-1-kraxel@redhat.com
---
 hw/audio/pcspk.c | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
index 908696d483..b80a62ce90 100644
--- a/hw/audio/pcspk.c
+++ b/hw/audio/pcspk.c
@@ -57,7 +57,6 @@ typedef struct {
 } PCSpkState;
 
 static const char *s_spk = "pcspk";
-static PCSpkState *pcspk_state;
 
 static inline void generate_samples(PCSpkState *s)
 {
@@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
     }
 }
 
-static int pcspk_audio_init(ISABus *bus)
-{
-    PCSpkState *s = pcspk_state;
-    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
-
-    AUD_register_card(s_spk, &s->card);
-
-    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
-    if (!s->voice) {
-        AUD_log(s_spk, "Could not open voice\n");
-        return -1;
-    }
-
-    return 0;
-}
-
 static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
                               unsigned size)
 {
@@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
 
 static void pcspk_realizefn(DeviceState *dev, Error **errp)
 {
+    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
     ISADevice *isadev = ISA_DEVICE(dev);
     PCSpkState *s = PC_SPEAKER(dev);
 
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
-    pcspk_state = s;
+    AUD_register_card(s_spk, &s->card);
+
+    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
+    if (!s->voice) {
+        error_setg(errp, "Initializing audio voice failed");
+        AUD_remove_card(&s->card);
+        return;
+    }
 }
 
 static bool migrate_needed(void *opaque)
@@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
     dc->vmsd = &vmstate_spk;
     dc->props = pcspk_properties;
-    /* Reason: realize sets global pcspk_state */
-    dc->user_creatable = false;
 }
 
 static const TypeInfo pcspk_info = {
@@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
     .class_init     = pcspk_class_initfn,
 };
 
+static int pcspk_audio_init(ISABus *bus)
+{
+    isa_create_simple(bus, TYPE_PC_SPEAKER);
+    return 0;
+}
+
 static void pcspk_register(void)
 {
     type_register_static(&pcspk_info);
-- 
2.9.3

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

* [Qemu-devel] [PULL 2/7] audio: use pkg-config
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 1/7] audio: fix pc speaker init Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 3/7] audio: allow optional audio drivers Gerd Hoffmann
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Gerd Hoffmann

Use pkg-config to probe for alsa and pulseaudio.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124112055.547-2-kraxel@redhat.com
---
 configure | 39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/configure b/configure
index 8f312ac3e2..5fcd0f4795 100755
--- a/configure
+++ b/configure
@@ -3342,39 +3342,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] 14+ messages in thread

* [Qemu-devel] [PULL 3/7] audio: allow optional audio drivers.
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 1/7] audio: fix pc speaker init Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 2/7] audio: use pkg-config Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 4/7] audio: use try-sdl for openbsd Gerd Hoffmann
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, 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>
Message-id: 20190124112055.547-3-kraxel@redhat.com
---
 configure | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 5fcd0f4795..6a2aa3b533 100755
--- a/configure
+++ b/configure
@@ -3345,22 +3345,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
     ;;
 
@@ -3370,6 +3384,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] 14+ messages in thread

* [Qemu-devel] [PULL 4/7] audio: use try-sdl for openbsd
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2019-01-24 13:20 ` [Qemu-devel] [PULL 3/7] audio: allow optional audio drivers Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 5/7] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, Gerd Hoffmann

Fixes the openbsd build failure with SDL disabled.

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

diff --git a/configure b/configure
index 6a2aa3b533..1eff5946f6 100755
--- a/configure
+++ b/configure
@@ -829,7 +829,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] 14+ messages in thread

* [Qemu-devel] [PULL 5/7] audio: check for pulseaudio daemon pidfile
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2019-01-24 13:20 ` [Qemu-devel] [PULL 4/7] audio: use try-sdl for openbsd Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 6/7] audio: error message tweak Gerd Hoffmann
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, 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>
Message-id: 20190124112055.547-5-kraxel@redhat.com
---
 audio/paaudio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/audio/paaudio.c b/audio/paaudio.c
index 4c100bc318..6153b908da 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -814,6 +814,21 @@ 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] 14+ messages in thread

* [Qemu-devel] [PULL 6/7] audio: error message tweak
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2019-01-24 13:20 ` [Qemu-devel] [PULL 5/7] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-01-24 13:20 ` [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default Gerd Hoffmann
  2019-01-25 11:51 ` [Qemu-devel] [PULL 0/7] Audio 20190124 patches Peter Maydell
  7 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, 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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190124112055.547-6-kraxel@redhat.com
---
 audio/audio.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index 1ace47f510..d163ffbc88 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,9 @@ 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 +1903,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 +1914,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] 14+ messages in thread

* [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2019-01-24 13:20 ` [Qemu-devel] [PULL 6/7] audio: error message tweak Gerd Hoffmann
@ 2019-01-24 13:20 ` Gerd Hoffmann
  2019-02-15 14:46   ` Daniel P. Berrangé
  2019-01-25 11:51 ` [Qemu-devel] [PULL 0/7] Audio 20190124 patches Peter Maydell
  7 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2019-01-24 13:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brad Smith, 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.

Additioal tweaks:
  linux: reorder to: pa alsa sdl oss.
  *bsd: drop pa.

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

diff --git a/configure b/configure
index 1eff5946f6..b18281c61f 100755
--- a/configure
+++ b/configure
@@ -794,13 +794,13 @@ MINGW32*)
 ;;
 GNU/kFreeBSD)
   bsd="yes"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl"
   audio_possible_drivers="oss sdl pa"
 ;;
 FreeBSD)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl"
   audio_possible_drivers="oss sdl pa"
   # needed for kinfo_getvmmap(3) in libutil.h
   LIBS="-lutil $LIBS"
@@ -813,14 +813,14 @@ FreeBSD)
 DragonFly)
   bsd="yes"
   make="${MAKE-gmake}"
-  audio_drv_list="oss"
+  audio_drv_list="oss try-sdl"
   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"
@@ -845,7 +845,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"
@@ -861,7 +861,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
@@ -879,7 +879,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] 14+ messages in thread

* Re: [Qemu-devel] [PULL 0/7] Audio 20190124 patches
  2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2019-01-24 13:20 ` [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default Gerd Hoffmann
@ 2019-01-25 11:51 ` Peter Maydell
  7 siblings, 0 replies; 14+ messages in thread
From: Peter Maydell @ 2019-01-25 11:51 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers, Brad Smith

On Thu, 24 Jan 2019 at 13:27, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> The following changes since commit f6b06fcceef465de0cf2514c9f76fe0192896781:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190121-pull-request' into staging (2019-01-23 17:57:47 +0000)
>
> are available in the git repository at:
>
>   git://git.kraxel.org/qemu tags/audio-20190124-pull-request
>
> for you to fetch changes up to 6a48541873f14b597630283f8f5397674ad82ea9:
>
>   audio: probe audio drivers by default (2019-01-24 13:11:08 +0100)
>
> ----------------------------------------------------------------
> audio: pc speaker init fix, rework driver probing
>
> ----------------------------------------------------------------

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/4.0
for any user-visible changes.

-- PMM

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

* Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
  2019-01-24 13:20 ` [Qemu-devel] [PULL 1/7] audio: fix pc speaker init Gerd Hoffmann
@ 2019-02-12 11:47   ` David Hildenbrand
  2019-02-12 12:08     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 14+ messages in thread
From: David Hildenbrand @ 2019-02-12 11:47 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel; +Cc: Brad Smith

On 24.01.19 14:20, Gerd Hoffmann wrote:
> Get rid of the pcspk_state global, allow pc speaker
> be added using "-device isa-pcspk".
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Message-id: 20190124110810.1040-1-kraxel@redhat.com
> ---
>  hw/audio/pcspk.c | 35 +++++++++++++++--------------------
>  1 file changed, 15 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
> index 908696d483..b80a62ce90 100644
> --- a/hw/audio/pcspk.c
> +++ b/hw/audio/pcspk.c
> @@ -57,7 +57,6 @@ typedef struct {
>  } PCSpkState;
>  
>  static const char *s_spk = "pcspk";
> -static PCSpkState *pcspk_state;
>  
>  static inline void generate_samples(PCSpkState *s)
>  {
> @@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
>      }
>  }
>  
> -static int pcspk_audio_init(ISABus *bus)
> -{
> -    PCSpkState *s = pcspk_state;
> -    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
> -
> -    AUD_register_card(s_spk, &s->card);
> -
> -    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
> -    if (!s->voice) {
> -        AUD_log(s_spk, "Could not open voice\n");
> -        return -1;
> -    }
> -
> -    return 0;
> -}
> -
>  static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>                                unsigned size)
>  {
> @@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
>  
>  static void pcspk_realizefn(DeviceState *dev, Error **errp)
>  {
> +    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>      ISADevice *isadev = ISA_DEVICE(dev);
>      PCSpkState *s = PC_SPEAKER(dev);
>  
>      isa_register_ioport(isadev, &s->ioport, s->iobase);
>  
> -    pcspk_state = s;
> +    AUD_register_card(s_spk, &s->card);
> +
> +    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
> +    if (!s->voice) {
> +        error_setg(errp, "Initializing audio voice failed");
> +        AUD_remove_card(&s->card);
> +        return;
> +    }
>  }
>  
>  static bool migrate_needed(void *opaque)
> @@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
>      set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
>      dc->vmsd = &vmstate_spk;
>      dc->props = pcspk_properties;
> -    /* Reason: realize sets global pcspk_state */
> -    dc->user_creatable = false;
>  }
>  
>  static const TypeInfo pcspk_info = {
> @@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
>      .class_init     = pcspk_class_initfn,
>  };
>  
> +static int pcspk_audio_init(ISABus *bus)
> +{
> +    isa_create_simple(bus, TYPE_PC_SPEAKER);
> +    return 0;
> +}
> +
>  static void pcspk_register(void)
>  {
>      type_register_static(&pcspk_info);
> 

I suddenly get (under fedora 28)

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
Connection refused

alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: Connection refused
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
Connection refused

alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: Connection refused
audio: Failed to create voice `pcspk'
qemu-system-x86_64: Initialization of device isa-pcspk failed:
Initializing audio voice failed


With

sudo x86_64-softmmu/qemu-system-x86_64 \
    --enable-kvm \
    -m 4G,maxmem=40G,slots=2 \
    -smp sockets=2,cores=2 \
    -numa node,nodeid=0,cpus=0-1 -numa node,nodeid=1,cpus=2-3 \
    -kernel /boot/vmlinuz-4.19.6-200.fc28.x86_64 \
    -append "console=ttyS0 rd.shell rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0" \
    -initrd /boot/initramfs-4.19.6-200.fc28.x86_64.img \
    -machine pc,nvdimm \
    -nographic \
    -nodefaults \
    -chardev stdio,id=serial \
    --trace events=to_trace \
    -device isa-serial,chardev=serial \
    -chardev socket,id=monitor,path=/var/tmp/monitor,server,nowait \
    -mon chardev=monitor,mode=readline


Could this be related to this patch? (or is maybe something about my
system messed up? will try rebooting, but other audio - e.g. via firefox
- works fine)

-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
  2019-02-12 11:47   ` David Hildenbrand
@ 2019-02-12 12:08     ` Philippe Mathieu-Daudé
  2019-02-12 12:20       ` David Hildenbrand
  0 siblings, 1 reply; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-02-12 12:08 UTC (permalink / raw)
  To: David Hildenbrand, Gerd Hoffmann, qemu-devel; +Cc: Brad Smith

Hi David,

On 2/12/19 12:47 PM, David Hildenbrand wrote:
> On 24.01.19 14:20, Gerd Hoffmann wrote:
>> Get rid of the pcspk_state global, allow pc speaker
>> be added using "-device isa-pcspk".
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Message-id: 20190124110810.1040-1-kraxel@redhat.com
>> ---
>>  hw/audio/pcspk.c | 35 +++++++++++++++--------------------
>>  1 file changed, 15 insertions(+), 20 deletions(-)
>>
>> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
>> index 908696d483..b80a62ce90 100644
>> --- a/hw/audio/pcspk.c
>> +++ b/hw/audio/pcspk.c
>> @@ -57,7 +57,6 @@ typedef struct {
>>  } PCSpkState;
>>  
>>  static const char *s_spk = "pcspk";
>> -static PCSpkState *pcspk_state;
>>  
>>  static inline void generate_samples(PCSpkState *s)
>>  {
>> @@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
>>      }
>>  }
>>  
>> -static int pcspk_audio_init(ISABus *bus)
>> -{
>> -    PCSpkState *s = pcspk_state;
>> -    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>> -
>> -    AUD_register_card(s_spk, &s->card);
>> -
>> -    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>> -    if (!s->voice) {
>> -        AUD_log(s_spk, "Could not open voice\n");
>> -        return -1;
>> -    }
>> -
>> -    return 0;
>> -}
>> -
>>  static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>>                                unsigned size)
>>  {
>> @@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
>>  
>>  static void pcspk_realizefn(DeviceState *dev, Error **errp)
>>  {
>> +    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>>      ISADevice *isadev = ISA_DEVICE(dev);
>>      PCSpkState *s = PC_SPEAKER(dev);
>>  
>>      isa_register_ioport(isadev, &s->ioport, s->iobase);
>>  
>> -    pcspk_state = s;
>> +    AUD_register_card(s_spk, &s->card);
>> +
>> +    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>> +    if (!s->voice) {
>> +        error_setg(errp, "Initializing audio voice failed");
>> +        AUD_remove_card(&s->card);
>> +        return;
>> +    }
>>  }
>>  
>>  static bool migrate_needed(void *opaque)
>> @@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
>>      set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
>>      dc->vmsd = &vmstate_spk;
>>      dc->props = pcspk_properties;
>> -    /* Reason: realize sets global pcspk_state */
>> -    dc->user_creatable = false;
>>  }
>>  
>>  static const TypeInfo pcspk_info = {
>> @@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
>>      .class_init     = pcspk_class_initfn,
>>  };
>>  
>> +static int pcspk_audio_init(ISABus *bus)
>> +{
>> +    isa_create_simple(bus, TYPE_PC_SPEAKER);
>> +    return 0;
>> +}
>> +
>>  static void pcspk_register(void)
>>  {
>>      type_register_static(&pcspk_info);
>>
> 
> I suddenly get (under fedora 28)
> 
> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
> Connection refused
> 
> alsa: Could not initialize DAC
> alsa: Failed to open `default':
> alsa: Reason: Connection refused
> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
> Connection refused
> 
> alsa: Could not initialize DAC
> alsa: Failed to open `default':
> alsa: Reason: Connection refused

This ALSA problem seems on your side.

> audio: Failed to create voice `pcspk'
> qemu-system-x86_64: Initialization of device isa-pcspk failed:
> Initializing audio voice failed

Previously the errors would be ignored and QEMU would start.

> 
> 
> With
> 
> sudo x86_64-softmmu/qemu-system-x86_64 \
>     --enable-kvm \
>     -m 4G,maxmem=40G,slots=2 \
>     -smp sockets=2,cores=2 \
>     -numa node,nodeid=0,cpus=0-1 -numa node,nodeid=1,cpus=2-3 \
>     -kernel /boot/vmlinuz-4.19.6-200.fc28.x86_64 \
>     -append "console=ttyS0 rd.shell rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0" \
>     -initrd /boot/initramfs-4.19.6-200.fc28.x86_64.img \
>     -machine pc,nvdimm \
>     -nographic \
>     -nodefaults \
>     -chardev stdio,id=serial \
>     --trace events=to_trace \
>     -device isa-serial,chardev=serial \
>     -chardev socket,id=monitor,path=/var/tmp/monitor,server,nowait \
>     -mon chardev=monitor,mode=readline
> 
> 
> Could this be related to this patch? (or is maybe something about my
> system messed up? will try rebooting, but other audio - e.g. via firefox
> - works fine)

Does your Firefox uses ALSA? The default install uses PulseAudio.

I think the behavior change you are experiencing comes from the patch 7
of this series "audio: probe audio drivers by default":

@@ -879,7 +879,7 @@
 Linux)
-  audio_drv_list="oss"
+  audio_drv_list="try-pa try-alsa try-sdl oss"

Previously you were using OSS, and how the ./configure found via
pkg-config that you have the ALSA libs installed, and use ALSA first.

Can you share the relevant part of the ./configure output?

Thanks,

Phil.

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

* Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
  2019-02-12 12:08     ` Philippe Mathieu-Daudé
@ 2019-02-12 12:20       ` David Hildenbrand
  2019-02-12 12:25         ` David Hildenbrand
  0 siblings, 1 reply; 14+ messages in thread
From: David Hildenbrand @ 2019-02-12 12:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Gerd Hoffmann, qemu-devel; +Cc: Brad Smith

On 12.02.19 13:08, Philippe Mathieu-Daudé wrote:
> Hi David,
> 
> On 2/12/19 12:47 PM, David Hildenbrand wrote:
>> On 24.01.19 14:20, Gerd Hoffmann wrote:
>>> Get rid of the pcspk_state global, allow pc speaker
>>> be added using "-device isa-pcspk".
>>>
>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> Message-id: 20190124110810.1040-1-kraxel@redhat.com
>>> ---
>>>  hw/audio/pcspk.c | 35 +++++++++++++++--------------------
>>>  1 file changed, 15 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
>>> index 908696d483..b80a62ce90 100644
>>> --- a/hw/audio/pcspk.c
>>> +++ b/hw/audio/pcspk.c
>>> @@ -57,7 +57,6 @@ typedef struct {
>>>  } PCSpkState;
>>>  
>>>  static const char *s_spk = "pcspk";
>>> -static PCSpkState *pcspk_state;
>>>  
>>>  static inline void generate_samples(PCSpkState *s)
>>>  {
>>> @@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
>>>      }
>>>  }
>>>  
>>> -static int pcspk_audio_init(ISABus *bus)
>>> -{
>>> -    PCSpkState *s = pcspk_state;
>>> -    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>>> -
>>> -    AUD_register_card(s_spk, &s->card);
>>> -
>>> -    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>>> -    if (!s->voice) {
>>> -        AUD_log(s_spk, "Could not open voice\n");
>>> -        return -1;
>>> -    }
>>> -
>>> -    return 0;
>>> -}
>>> -
>>>  static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>>>                                unsigned size)
>>>  {
>>> @@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
>>>  
>>>  static void pcspk_realizefn(DeviceState *dev, Error **errp)
>>>  {
>>> +    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>>>      ISADevice *isadev = ISA_DEVICE(dev);
>>>      PCSpkState *s = PC_SPEAKER(dev);
>>>  
>>>      isa_register_ioport(isadev, &s->ioport, s->iobase);
>>>  
>>> -    pcspk_state = s;
>>> +    AUD_register_card(s_spk, &s->card);
>>> +
>>> +    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>>> +    if (!s->voice) {
>>> +        error_setg(errp, "Initializing audio voice failed");
>>> +        AUD_remove_card(&s->card);
>>> +        return;
>>> +    }
>>>  }
>>>  
>>>  static bool migrate_needed(void *opaque)
>>> @@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
>>>      set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
>>>      dc->vmsd = &vmstate_spk;
>>>      dc->props = pcspk_properties;
>>> -    /* Reason: realize sets global pcspk_state */
>>> -    dc->user_creatable = false;
>>>  }
>>>  
>>>  static const TypeInfo pcspk_info = {
>>> @@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
>>>      .class_init     = pcspk_class_initfn,
>>>  };
>>>  
>>> +static int pcspk_audio_init(ISABus *bus)
>>> +{
>>> +    isa_create_simple(bus, TYPE_PC_SPEAKER);
>>> +    return 0;
>>> +}
>>> +
>>>  static void pcspk_register(void)
>>>  {
>>>      type_register_static(&pcspk_info);
>>>
>>
>> I suddenly get (under fedora 28)
>>
>> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
>> Connection refused
>>
>> alsa: Could not initialize DAC
>> alsa: Failed to open `default':
>> alsa: Reason: Connection refused
>> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
>> Connection refused
>>
>> alsa: Could not initialize DAC
>> alsa: Failed to open `default':
>> alsa: Reason: Connection refused
> 
> This ALSA problem seems on your side.
> 
>> audio: Failed to create voice `pcspk'
>> qemu-system-x86_64: Initialization of device isa-pcspk failed:
>> Initializing audio voice failed
> 
> Previously the errors would be ignored and QEMU would start.

I just did a fedora 28 uupdate + reboot. Problem still exists. Would be
strange if only I would be hitting this problem with stock alsa libraries.

> 
>>
>>
>> With
>>
>> sudo x86_64-softmmu/qemu-system-x86_64 \
>>     --enable-kvm \
>>     -m 4G,maxmem=40G,slots=2 \
>>     -smp sockets=2,cores=2 \
>>     -numa node,nodeid=0,cpus=0-1 -numa node,nodeid=1,cpus=2-3 \
>>     -kernel /boot/vmlinuz-4.19.6-200.fc28.x86_64 \
>>     -append "console=ttyS0 rd.shell rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0" \
>>     -initrd /boot/initramfs-4.19.6-200.fc28.x86_64.img \
>>     -machine pc,nvdimm \
>>     -nographic \
>>     -nodefaults \
>>     -chardev stdio,id=serial \
>>     --trace events=to_trace \
>>     -device isa-serial,chardev=serial \
>>     -chardev socket,id=monitor,path=/var/tmp/monitor,server,nowait \
>>     -mon chardev=monitor,mode=readline
>>
>>
>> Could this be related to this patch? (or is maybe something about my
>> system messed up? will try rebooting, but other audio - e.g. via firefox
>> - works fine)
> 
> Does your Firefox uses ALSA? The default install uses PulseAudio.

Yes, I think so. I will try to find another tool to test ALSA.

> 
> I think the behavior change you are experiencing comes from the patch 7
> of this series "audio: probe audio drivers by default":
> 
> @@ -879,7 +879,7 @@
>  Linux)
> -  audio_drv_list="oss"
> +  audio_drv_list="try-pa try-alsa try-sdl oss"
> 
> Previously you were using OSS, and how the ./configure found via
> pkg-config that you have the ALSA libs installed, and use ALSA first.
> 
> Can you share the relevant part of the ./configure output?

./configure
--target-list=s390x-linux-user,s390x-softmmu,s390x-linux-user,x86_64-softmmu,ppc-softmmu,ppc64-softmmu
 --enable-sdl --enable-spice --enable-kvm  --enable-trace-backends=log
--enable-debug-tcg

Gives me

Audio drivers      alsa sdl oss

Thanks!

> 
> Thanks,
> 
> Phil.
> 


-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
  2019-02-12 12:20       ` David Hildenbrand
@ 2019-02-12 12:25         ` David Hildenbrand
  0 siblings, 0 replies; 14+ messages in thread
From: David Hildenbrand @ 2019-02-12 12:25 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Gerd Hoffmann, qemu-devel; +Cc: Brad Smith

On 12.02.19 13:20, David Hildenbrand wrote:
> On 12.02.19 13:08, Philippe Mathieu-Daudé wrote:
>> Hi David,
>>
>> On 2/12/19 12:47 PM, David Hildenbrand wrote:
>>> On 24.01.19 14:20, Gerd Hoffmann wrote:
>>>> Get rid of the pcspk_state global, allow pc speaker
>>>> be added using "-device isa-pcspk".
>>>>
>>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>>> Message-id: 20190124110810.1040-1-kraxel@redhat.com
>>>> ---
>>>>  hw/audio/pcspk.c | 35 +++++++++++++++--------------------
>>>>  1 file changed, 15 insertions(+), 20 deletions(-)
>>>>
>>>> diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c
>>>> index 908696d483..b80a62ce90 100644
>>>> --- a/hw/audio/pcspk.c
>>>> +++ b/hw/audio/pcspk.c
>>>> @@ -57,7 +57,6 @@ typedef struct {
>>>>  } PCSpkState;
>>>>  
>>>>  static const char *s_spk = "pcspk";
>>>> -static PCSpkState *pcspk_state;
>>>>  
>>>>  static inline void generate_samples(PCSpkState *s)
>>>>  {
>>>> @@ -111,22 +110,6 @@ static void pcspk_callback(void *opaque, int free)
>>>>      }
>>>>  }
>>>>  
>>>> -static int pcspk_audio_init(ISABus *bus)
>>>> -{
>>>> -    PCSpkState *s = pcspk_state;
>>>> -    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>>>> -
>>>> -    AUD_register_card(s_spk, &s->card);
>>>> -
>>>> -    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>>>> -    if (!s->voice) {
>>>> -        AUD_log(s_spk, "Could not open voice\n");
>>>> -        return -1;
>>>> -    }
>>>> -
>>>> -    return 0;
>>>> -}
>>>> -
>>>>  static uint64_t pcspk_io_read(void *opaque, hwaddr addr,
>>>>                                unsigned size)
>>>>  {
>>>> @@ -179,12 +162,20 @@ static void pcspk_initfn(Object *obj)
>>>>  
>>>>  static void pcspk_realizefn(DeviceState *dev, Error **errp)
>>>>  {
>>>> +    struct audsettings as = {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0};
>>>>      ISADevice *isadev = ISA_DEVICE(dev);
>>>>      PCSpkState *s = PC_SPEAKER(dev);
>>>>  
>>>>      isa_register_ioport(isadev, &s->ioport, s->iobase);
>>>>  
>>>> -    pcspk_state = s;
>>>> +    AUD_register_card(s_spk, &s->card);
>>>> +
>>>> +    s->voice = AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback, &as);
>>>> +    if (!s->voice) {
>>>> +        error_setg(errp, "Initializing audio voice failed");
>>>> +        AUD_remove_card(&s->card);
>>>> +        return;
>>>> +    }
>>>>  }
>>>>  
>>>>  static bool migrate_needed(void *opaque)
>>>> @@ -221,8 +212,6 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
>>>>      set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
>>>>      dc->vmsd = &vmstate_spk;
>>>>      dc->props = pcspk_properties;
>>>> -    /* Reason: realize sets global pcspk_state */
>>>> -    dc->user_creatable = false;
>>>>  }
>>>>  
>>>>  static const TypeInfo pcspk_info = {
>>>> @@ -233,6 +222,12 @@ static const TypeInfo pcspk_info = {
>>>>      .class_init     = pcspk_class_initfn,
>>>>  };
>>>>  
>>>> +static int pcspk_audio_init(ISABus *bus)
>>>> +{
>>>> +    isa_create_simple(bus, TYPE_PC_SPEAKER);
>>>> +    return 0;
>>>> +}
>>>> +
>>>>  static void pcspk_register(void)
>>>>  {
>>>>      type_register_static(&pcspk_info);
>>>>
>>>
>>> I suddenly get (under fedora 28)
>>>
>>> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
>>> Connection refused
>>>
>>> alsa: Could not initialize DAC
>>> alsa: Failed to open `default':
>>> alsa: Reason: Connection refused
>>> ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
>>> Connection refused
>>>
>>> alsa: Could not initialize DAC
>>> alsa: Failed to open `default':
>>> alsa: Reason: Connection refused
>>
>> This ALSA problem seems on your side.
>>
>>> audio: Failed to create voice `pcspk'
>>> qemu-system-x86_64: Initialization of device isa-pcspk failed:
>>> Initializing audio voice failed
>>
>> Previously the errors would be ignored and QEMU would start.
> 
> I just did a fedora 28 uupdate + reboot. Problem still exists. Would be
> strange if only I would be hitting this problem with stock alsa libraries.
> 
>>
>>>
>>>
>>> With
>>>
>>> sudo x86_64-softmmu/qemu-system-x86_64 \
>>>     --enable-kvm \
>>>     -m 4G,maxmem=40G,slots=2 \
>>>     -smp sockets=2,cores=2 \
>>>     -numa node,nodeid=0,cpus=0-1 -numa node,nodeid=1,cpus=2-3 \
>>>     -kernel /boot/vmlinuz-4.19.6-200.fc28.x86_64 \
>>>     -append "console=ttyS0 rd.shell rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0" \
>>>     -initrd /boot/initramfs-4.19.6-200.fc28.x86_64.img \
>>>     -machine pc,nvdimm \
>>>     -nographic \
>>>     -nodefaults \
>>>     -chardev stdio,id=serial \
>>>     --trace events=to_trace \
>>>     -device isa-serial,chardev=serial \
>>>     -chardev socket,id=monitor,path=/var/tmp/monitor,server,nowait \
>>>     -mon chardev=monitor,mode=readline
>>>
>>>
>>> Could this be related to this patch? (or is maybe something about my
>>> system messed up? will try rebooting, but other audio - e.g. via firefox
>>> - works fine)
>>
>> Does your Firefox uses ALSA? The default install uses PulseAudio.
> 
> Yes, I think so. I will try to find another tool to test ALSA.
> 
>>
>> I think the behavior change you are experiencing comes from the patch 7
>> of this series "audio: probe audio drivers by default":
>>
>> @@ -879,7 +879,7 @@
>>  Linux)
>> -  audio_drv_list="oss"
>> +  audio_drv_list="try-pa try-alsa try-sdl oss"
>>
>> Previously you were using OSS, and how the ./configure found via
>> pkg-config that you have the ALSA libs installed, and use ALSA first.
>>
>> Can you share the relevant part of the ./configure output?
> 
> ./configure
> --target-list=s390x-linux-user,s390x-softmmu,s390x-linux-user,x86_64-softmmu,ppc-softmmu,ppc64-softmmu
>  --enable-sdl --enable-spice --enable-kvm  --enable-trace-backends=log
> --enable-debug-tcg
> 
> Gives me
> 
> Audio drivers      alsa sdl oss
> 
> Thanks!
> 
>>
>> Thanks,
>>
>> Phil.
>>
> 
> 

Using speaker-test

t460s: ~  $  aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=PCH
    HDA Intel PCH, ALC293 Analog
    Default Audio Device


t460s: ~  $ LANG=C speaker-test -c 2 -d default

speaker-test 1.1.6

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 96 to 1048576
Period size range from 32 to 349526
Using max buffer size 1048576
Periods = 4
was set period_size = 262144
was set buffer_size = 1048576
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 1048576
  period_size  : 262144
  period_time  : 5461333
  tstamp_mode  : NONE
  tstamp_type  : GETTIMEOFDAY
  period_step  : 1
  avail_min    : 262144
  period_event : 0
  start_threshold  : 1048576
  stop_threshold   : 1048576
  silence_threshold: 0
  silence_size : 0
  boundary     : 4611686018427387904



However, root seems to be the issue

t460s: ~  $ LANG=C sudo speaker-test -c 2 -d default

speaker-test 1.1.6

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect:
Connection refused

Playback open error: -111,Connection refused


-- 

Thanks,

David / dhildenb

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

* Re: [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default
  2019-01-24 13:20 ` [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default Gerd Hoffmann
@ 2019-02-15 14:46   ` Daniel P. Berrangé
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel P. Berrangé @ 2019-02-15 14:46 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Brad Smith

On Thu, Jan 24, 2019 at 02:20:20PM +0100, Gerd Hoffmann wrote:
> 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.
> 
> Additioal tweaks:
>   linux: reorder to: pa alsa sdl oss.

Unfortunately this breaks QEMU on hosts which lack a physical  sound
card. The alsa driver activates itself, despite the fact it is incapable
of working, and thus causes QEMU startup to fail when AUD_open_out is
tried

https://bugs.launchpad.net/qemu/+bug/1816052


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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

end of thread, other threads:[~2019-02-15 14:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-24 13:20 [Qemu-devel] [PULL 0/7] Audio 20190124 patches Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 1/7] audio: fix pc speaker init Gerd Hoffmann
2019-02-12 11:47   ` David Hildenbrand
2019-02-12 12:08     ` Philippe Mathieu-Daudé
2019-02-12 12:20       ` David Hildenbrand
2019-02-12 12:25         ` David Hildenbrand
2019-01-24 13:20 ` [Qemu-devel] [PULL 2/7] audio: use pkg-config Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 3/7] audio: allow optional audio drivers Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 4/7] audio: use try-sdl for openbsd Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 5/7] audio: check for pulseaudio daemon pidfile Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 6/7] audio: error message tweak Gerd Hoffmann
2019-01-24 13:20 ` [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default Gerd Hoffmann
2019-02-15 14:46   ` Daniel P. Berrangé
2019-01-25 11:51 ` [Qemu-devel] [PULL 0/7] Audio 20190124 patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).