From: David Hildenbrand <david@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
qemu-devel@nongnu.org
Cc: Brad Smith <brad@comstyle.com>
Subject: Re: [Qemu-devel] [PULL 1/7] audio: fix pc speaker init
Date: Tue, 12 Feb 2019 13:20:22 +0100 [thread overview]
Message-ID: <d068cf4a-f191-820c-032d-5e70caa999ce@redhat.com> (raw)
In-Reply-To: <78b29e41-f1fa-9e88-e124-e91f2a3d9dc4@redhat.com>
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
next prev parent reply other threads:[~2019-02-12 12:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d068cf4a-f191-820c-032d-5e70caa999ce@redhat.com \
--to=david@redhat.com \
--cc=brad@comstyle.com \
--cc=kraxel@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).