Audio 20190124 patches
[Qemu-devel] [PULL 6/7] 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.
Message-id: [email protected]
--- audio/audio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
audio/audio.c +7 -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,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" ); }
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 4/7] audio: use try-sdl for openbsd
In reply to Gerd HoffmannFixes the openbsd build failure with SDL disabled.
Message-id: [email protected]
--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -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"
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 7/7] 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.
Additioal tweaks:
linux: reorder to: pa alsa sdl oss.
*bsd: drop pa.
Message-id: [email protected]
--- configure | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
configure +7 -7
@@ -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"
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 2/7] audio: use pkg-config
In reply to Gerd HoffmannUse pkg-config to probe for alsa and pulseaudio.
Message-id: [email protected]
--- configure | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
configure +13 -26
@@ -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)
Signature · 1 line
2.9.3
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(-)
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 3/7] audio: allow optional audio drivers.
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.
Message-id: [email protected]
--- configure | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
configure +28 -6
@@ -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" ;;
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 1/7] audio: fix pc speaker init
In reply to Gerd HoffmannGet rid of the pcspk_state global, allow pc speaker be added using "-device isa-pcspk".
Message-id: [email protected]
--- hw/audio/pcspk.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
hw/audio/pcspk.c +15 -20
@@ -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);
Signature · 1 line
2.9.3
[Qemu-devel] [PULL 5/7] 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.
Message-id: [email protected]
--- audio/paaudio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
audio/paaudio.c +15 -0
@@ -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 ;
Signature · 1 line
2.9.3
Peter Maydell
AppliedQuoted 9 lines · 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/qemutags/audio-20190124-pull-request
Quoted 8 lines
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
Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
In reply to Gerd HoffmannQuoted 80 lines · Gerd Hoffmann
Get rid of the
pcspk_stateglobal, allow pc speaker be added using "-device isa-pcspk".Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-id: [email protected]
--- hw/audio/pcspk.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)hw/audio/pcspk.c +9
-20@@ -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, };
hw/audio/pcspk.c static const TypeInfo pcspk_info = { · line 233
Quoted 10 lines
hw/audio/pcspk.c +6
-0+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=readlineCould 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)
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
Hi David,
Quoted 103 lines · David Hildenbrand
Quoted 80 lines · Gerd Hoffmann
Get rid of the
pcspk_stateglobal, allow pc speaker be added using "-device isa-pcspk".Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-id: [email protected]
--- hw/audio/pcspk.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)hw/audio/pcspk.c +9
-20@@ -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, };hw/audio/pcspk.c static const TypeInfo pcspk_info = { · line 233
Quoted 10 lines
hw/audio/pcspk.c +6
-0+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 refusedalsa: 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
Quoted 3 lines
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: Connection refused
This ALSA problem seems on your side.
Quoted 3 lines
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.
Quoted 22 lines
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
Quoted 3 lines
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.
Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
In reply to David HildenbrandQuoted 172 lines · David Hildenbrand
Quoted 110 lines · Philippe Mathieu-Daudé
Hi David,
Quoted 103 lines · David Hildenbrand
Quoted 80 lines · Gerd Hoffmann
Get rid of the
pcspk_stateglobal, allow pc speaker be added using "-device isa-pcspk".Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-id: [email protected]
--- hw/audio/pcspk.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)hw/audio/pcspk.c +9
-20@@ -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, };hw/audio/pcspk.c static const TypeInfo pcspk_info = { · line 233
Quoted 10 lines
hw/audio/pcspk.c +6
-0+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 refusedalsa: 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 refusedQuoted 3 lines
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: Connection refusedQuoted 7 lines
This ALSA problem seems on your side.
Quoted 3 lines
audio: Failed to create voice `pcspk'
qemu-system-x86_64: Initialization of device isa-pcspk failed:
Initializing audio voice failedPreviously 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.
Quoted 23 lines
Quoted 23 lines
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=readlineQuoted 5 lines
Quoted 3 lines
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.
Quoted 12 lines
I think the behavior change you are experiencing comes from the patch 7 of this series "audio: probe audio drivers by default":
(quoted diff) +1
-1@@ -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.
Quoted 1 line
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
Quoted 13 lines
Gives me
Audio drivers alsa sdl oss
Thanks!
Quoted 5 lines
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
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
In reply to Philippe Mathieu-DaudéQuoted 110 lines · Philippe Mathieu-Daudé
Hi David,
Quoted 103 lines · David Hildenbrand
Quoted 80 lines · Gerd Hoffmann
Get rid of the
pcspk_stateglobal, allow pc speaker be added using "-device isa-pcspk".Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Message-id: [email protected]
--- hw/audio/pcspk.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-)hw/audio/pcspk.c +9
-20@@ -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, };hw/audio/pcspk.c static const TypeInfo pcspk_info = { · line 233
Quoted 10 lines
hw/audio/pcspk.c +6
-0+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 refusedalsa: 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 refusedQuoted 3 lines
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: Connection refused
Quoted 7 lines
This ALSA problem seems on your side.
Quoted 3 lines
audio: Failed to create voice `pcspk'
qemu-system-x86_64: Initialization of device isa-pcspk failed:
Initializing audio voice failedPreviously 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.
Quoted 23 lines
Quoted 23 lines
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
Quoted 5 lines
Quoted 3 lines
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.
Quoted 12 lines
I think the behavior change you are experiencing comes from the patch 7 of this series "audio: probe audio drivers by default":
(quoted diff) +1
-1@@ -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.
Quoted 1 line
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!
Quoted 5 lines
Thanks,
Phil.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PULL 7/7] audio: probe audio drivers by default
In reply to Gerd HoffmannQuoted 6 lines · Gerd Hoffmann
Add the drivers listed in
audio_possible_driverstoaudio_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
Signature · 3 lines
|: 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 :|