qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Volker Rümelin" <vr_qemu@t-online.de>
Cc: Rene Engel <ReneEngel80@emailn.de>,
	kraxel@redhat.com,  marcandre.lureau@redhat.com,
	qemu-devel@nongnu.org
Subject: Re: Audio playback speed issue on sam460ex and pegasos2
Date: Sun, 19 Mar 2023 21:18:22 +0100 (CET)	[thread overview]
Message-ID: <db850619-ea3d-10e1-d32c-57f35cd17bec@eik.bme.hu> (raw)
In-Reply-To: <f1ec050c-7315-aae5-b377-1f99b057045c@t-online.de>

[-- Attachment #1: Type: text/plain, Size: 6074 bytes --]

On Sun, 19 Mar 2023, Volker Rümelin wrote:
> Am 19.03.23 um 18:49 schrieb BALATON Zoltan:
>> On Sun, 12 Mar 2023, Volker Rümelin wrote:
>>> Am 12.03.23 um 15:09 schrieb Rene Engel:
>>>> Tested with -audiodev coreaudio,id=audio0,out.buffer-count=1 to 12
>>>> 
>>>> 1 is too slow the rest up to 12 has no effect
>>>> 
>>>> The sampling frequency of the via-ac97 driver is 48000 Hz under 
>>>> AmigaOs4.1
>>>> 
>>>> Any other ideas?
>>>> 
>>>> 
>>> 
>>> In audio/audio_template.h in the AUD_open_ functions there is one
>>> 
>>>     ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
>>>             name, as->freq, as->nchannels, as->fmt);
>>> 
>>> line. Please replace this line with
>>> 
>>>     fprintf(stderr, "open %s, freq %d, nchannels %d, fmt %d\n",
>>>             name, as->freq, as->nchannels, as->fmt);
>>> 
>>> compile and start AmigaOS. Use the default out.buffer-count. I would like 
>>> to know the via-ac97 drivers idea of the sampling frequency.
>> 
>> Not sure this helps but I get these with DEBUG enabled in qemu/audio on 
>> Linux host with alsa set to 44100 Hz dmix rate with default settings 
>> without any -audiodev options with AmigaOS guest.
>> With pegasos2:
>> 
>> audio: open via-ac97.out, freq 44100, nchannels 1, fmt 1##############] 100 
>> %
>> audio: open via-ac97.out, freq 44100, nchannels 2, fmt 3
>> alsa: enabling voice
>> alsa: disabling voice
>> alsa: alsa_fini
>> 
>> or pegasos2 with ES1370:
>> 
>> audio: open via-ac97.out, freq 44100, nchannels 2, fmt 3
>> alsa: enabling voice
>> alsa: disabling voice
>> alsa: alsa_fini
>> 
>> this does not play as slow as with sam460ex below but maybe a bit slow 
>> which seems to improve with try-poll=off so this may be because of the alsa 
>> backend issue. It's a bit faster with sdl backend, not sure if that's the 
>> right speed or too fast but at least the backend seems to influence 
>> playback speed.
>> 
>
> Hi,
>
> I still don't understand how the playback speed can slow down without 
> changing the pitch.

The pitch also changes when it's playing slow but sometimes the speed 
difference is not too big so pitch shift maybe not obvious.

> Is it possible that the guest can't provide the audio 
> frames fast enough and there are buffer underruns in the ALSA backend? But I 
> think you would hear buffer underruns.

I think we'll need your logging patch to verify this. Or are there some 
traces that I can enable to check this?

>> With sam460ex and ES1370:
>> 
>> audio: open es1370.dac2, freq 44100, nchannels 1, fmt 0
>> audio: open es1370.adc, freq 44100, nchannels 1, fmt 0
>> audio: open es1370.dac2, freq 48662, nchannels 1, fmt 0
>> audio: open es1370.adc, freq 48662, nchannels 1, fmt 0
>> audio: open es1370.dac2, freq 48662, nchannels 2, fmt 3
>> alsa: enabling voice
>> alsa: disabling voice
>> alsa: alsa_fini
>> 
>> this plays definitely slow and the freq also seems to be off. I may have 
>> different AmigaOS versions on pegasos2 and sam460ex but I they seem to use 
>> the same driver as there were no updates to that part. I'm not sure what 
>> the driver in AmigaOS looks like but it may be similar to the AROS AHI 
>> SB128 one. I don't know if higher level parts in AHI may try to measure 
>> something like you mentioned but at least the card driver does not seem to 
>> do that.
>
> I had a look at the AROS SB128 driver and the AHI Preferences code. There is 
> no code to measure the audio clock frequency. The frequency selection of 
> 48662Hz seems to be a AROS/AmigaOS bug. This log is from a AROS x86 guest. I 
> hear some faint static noise but the playback speed is correct.
>
> open pcspk, freq 32000, nchannels 1, fmt 0
> open es1370.dac2, freq 44100, nchannels 1, fmt 0
> open es1370.adc, freq 44100, nchannels 1, fmt 0
> open es1370.dac2, freq 48662, nchannels 1, fmt 0
> open es1370.adc, freq 48662, nchannels 1, fmt 0
> open es1370.dac2, freq 48662, nchannels 2, fmt 3
> open es1370.dac2, freq 44100, nchannels 2, fmt 3
> open es1370.adc, freq 44100, nchannels 1, fmt 0

Here you end up with the correct freq but for me it stays at 48662 on 
sam460ex so could that explain a speed difference? Also selecting 
different sound options in AHI Prefs the test sound sounds quite different 
which probably should not if only the resolution or freq is changed but 
I'm not sure what the options really set.

>> There seems to be two independent problems, one is the bug in alsa backend 
>> that you mentioned and something else only affecting sam460ex which causes 
>> the wrong freq to be selected but I have no idea why or what to check 
>> further to find out. 
>
> I'm not so sure if your analysis is correct. The ALSA error I mentioned can 
> significantly increase the processor load, sometimes to the point of stopping 
> the guest. But it can't directly change the playback speed.

What I meant is we likely have multiple issues (and the slow speed on 
sam460ex may even be a guest bug if that's because using 48662 instead of 
44100 Hz) but just changing the audiodev and it's options I hear different 
results on pegasos2 which does not play that slow as sam460ex so this may 
be some alsa backend issue.

I've looked at the alsa and sndio backends to see if I can find what the 
issue with poll may be but since I don't know how it works I can't fix it. 
What I've noticed is that the sndio backend seems to remove the poll 
calbacks while handling the previous poll results and reenable them 
afterwards. Would the alsa backend need some flag that is set after 
handling poll results so while this is set the poll callback would return 
instead of calling the handler again or it really needs to be removed and 
reinstalled every time? (Or maybe it's not even the issue you were hinting 
at.)

> I will write a patch with a few tracepoints for the audio system. With your 
> help it should be possible to find the cause of the problem. It might take me 
> a few days to write and test the patch.

Thanks for looking at it, let me know if I can test anything that could 
help.

Regards,
BALATON Zoltan

  reply	other threads:[~2023-03-19 20:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-11 21:48 Audio playback speed issue on sam460ex and pegasos2 BALATON Zoltan
2023-03-11 21:50 ` BALATON Zoltan
2023-03-11 22:54   ` BALATON Zoltan
2023-03-12  9:46     ` Volker Rümelin
2023-03-12 13:23       ` BALATON Zoltan
     [not found]         ` <073253fedbbcc9467ca42ced0ef7f5e7@mail.emailn.de>
2023-03-12 14:58           ` Volker Rümelin
2023-03-19 17:49             ` BALATON Zoltan
2023-03-19 20:03               ` Volker Rümelin
2023-03-19 20:18                 ` BALATON Zoltan [this message]
2023-03-20  7:03                   ` Volker Rümelin
2023-03-26 17:46                 ` Volker Rümelin
     [not found]                   ` <a53db76d-aa94-4a95-0fe1-c8a469cc9086@eik.bme.hu>
     [not found]                     ` <56ae723446530739cc496afbb63991c7@mail.emailn.de>
     [not found]                       ` <ed7b48a6-42e2-0381-074e-9d774ecfa26f@t-online.de>
     [not found]                         ` <146a76841a0fc58eec972fe3c1cc34b0@mail.emailn.de>
     [not found]                           ` <9f77ce1a-a02e-365e-0d5b-a35a023e53d8@t-online.de>
     [not found]                             ` <0c71ee37c6d16abb23a03693381113d3@mail.emailn.de>
2023-03-28 18:26                               ` Volker Rümelin
2023-03-29 19:20                                 ` BALATON Zoltan
2023-03-29 21:19                                   ` Volker Rümelin
2023-03-29 22:38                                     ` BALATON Zoltan
     [not found]                                 ` <cc449b26874e615e52bca93c1cab078e@mail.emailn.de>
2023-03-29 19:42                                   ` Volker Rümelin
2023-03-12 15:17         ` Volker Rümelin
2023-03-12 15:34           ` BALATON Zoltan
2023-03-12 15:53             ` Volker Rümelin
2023-03-12 20:28               ` BALATON Zoltan
2023-03-19 12:49                 ` Volker Rümelin
2023-03-19 15:48                   ` BALATON Zoltan

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=db850619-ea3d-10e1-d32c-57f35cd17bec@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=ReneEngel80@emailn.de \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vr_qemu@t-online.de \
    /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).