Bug 2238132

Summary: python3-pyaudio-0.2.11 does not work, needs update to >= 0.2.12
Product: [Fedora] Fedora Reporter: Mike FABIAN <mfabian>
Component: pyaudioAssignee: Christian Krause <chkr>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 39CC: chkr, mfabian
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: pyaudio-0.2.13-1.fc39 pyaudio-0.2.13-1.fc37 pyaudio-0.2.13-1.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-15 18:58:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test file to reproduce the problem
none
pyaudio-test-trigger-hang.py none

Description Mike FABIAN 2023-09-09 09:58:51 UTC
Trying to play .wav files using python3-pyaudio does not work.
An upgrade to version >= 0.2.12 makes it work.

Reproducible: Always

Steps to Reproduce:
Script to reproduce attached.


Actual Results:  
$ python3 pyaudio-test.py 
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.front.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround40.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround71.0:CARD=0'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
Traceback (most recent call last):
  File "/local/mfabian/src/ibus-typing-booster/engine/pyaudio-test.py", line 27, in <module>
    stream.write(data)
  File "/usr/lib64/python3.11/site-packages/pyaudio.py", line 585, in write
    pa.write_stream(self._stream, frames, num_frames,
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats


Expected Results:  
Should play a sound. 

The test .wav file used in the script is in the package ibus-typing-booster:

$ rpm -qf /usr/share/ibus-typing-booster/data/coin9.wav
ibus-typing-booster-2.23.4-1.fc38.noarch

Comment 1 Mike FABIAN 2023-09-09 10:01:11 UTC
Created attachment 1987820 [details]
Test file to reproduce the problem

Test like this:

- make sure ibus-typing-booster is installed to have the test .wav file used in the script available
- Run the script like this: `python3 pyaudio-test.py`

Comment 2 Christian Krause 2023-09-10 20:49:11 UTC
Thank you very much for the bug report and the PRs. I'll use the opportunity to include some additional changes (update spec to latest Python packaging guidelines, migrate to SPDX license).

Comment 3 Mike FABIAN 2023-09-11 19:23:22 UTC
(In reply to Christian Krause from comment #2)
> Thank you very much for the bug report and the PRs. I'll use the opportunity
> to include some additional changes (update spec to latest Python packaging
> guidelines, migrate to SPDX license).

Great, thank you very much!

Comment 4 Fedora Update System 2023-09-11 19:59:15 UTC
FEDORA-2023-4025f362c0 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-4025f362c0

Comment 5 Fedora Update System 2023-09-11 20:00:11 UTC
FEDORA-2023-f675d09ee6 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-f675d09ee6

Comment 6 Fedora Update System 2023-09-11 20:00:35 UTC
FEDORA-2023-bb295d0bd4 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-bb295d0bd4

Comment 7 Mike FABIAN 2023-09-11 21:15:18 UTC
Created attachment 1988209 [details]
pyaudio-test-trigger-hang.py

With the updated python3-pyaudio, it works but not reliably. It sometimes hangs, pretty often actually.

The attached script makes it rather easy to reproduce the hang. It should do 99 beeps, but does the full amount of beeps not always, quite often it hangs like this:

    $ python3 ~/tmp/audio-test/pyaudio-test-trigger-hang.py 
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.front.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround40.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround40
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround41
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround50
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround51
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround71.0:CARD=0'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM surround71
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM iec958
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:5181:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:5704:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave


and here at this `ALSA lib pcm_dmix.c:999:(snd_pcm_dmix_open) unable to open slave` message it hangs, there is no more sound and the script never finishes.

I can stop it here with Control-C only because I added:

    # Make Control-C work when it hangs:
    signal.signal(signal.SIGINT, signal.SIG_DFL)

to the script.

When it hangs, stopping the script with Control-C and starting it again, usually reproduces the hang immediately.

Using

    aplay /usr/share/ibus-typing-booster/data/coin9.wav

in a different terminal while this test script is hanging does not work, aplay then hangs as well.

But after stopping the test script with Control-C, running

    aplay /usr/share/ibus-typing-booster/data/coin9.wav

once seems to "fix" the problem, aplay produces the correct sound and the next run of the test script usually works as well.

Comment 8 Mike FABIAN 2023-09-11 21:31:29 UTC
I should probably make a new bug report for this hang.

I can quite easily reproduce the hang using your latest build on Fedora 38: https://koji.fedoraproject.org/koji/buildinfo?buildID=2287903

Comment 9 Fedora Update System 2023-09-12 01:23:52 UTC
FEDORA-2023-4025f362c0 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-4025f362c0`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-4025f362c0

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2023-09-12 01:24:32 UTC
FEDORA-2023-f675d09ee6 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-f675d09ee6`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f675d09ee6

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2023-09-12 01:29:35 UTC
FEDORA-2023-bb295d0bd4 has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-bb295d0bd4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-bb295d0bd4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Christian Krause 2023-09-12 22:40:21 UTC
(In reply to Mike FABIAN from comment #8)
> I should probably make a new bug report for this hang.

I can reproduce similar issues (see below). Anyway, I suggest a new bug report as well. Let's keep using this one for the update and fixing the issue that the package didn't work at all.

Just to double-check: Do you see the same issues with your own local builds of pyaudio?

> I can quite easily reproduce the hang using your latest build on Fedora 38:
> https://koji.fedoraproject.org/koji/buildinfo?buildID=2287903

A few notes from my tests:
- works worse if there are other active audio players (e.g. a browser): lots of stutter, sometimes hanging pyaudio
- I tried using mpg123 with portaudio plugin (to test the underlying portaudio library): issues couldn't be reproduced

Comment 13 Mike FABIAN 2023-09-13 13:08:41 UTC
New bug for this hang: https://bugzilla.redhat.com/show_bug.cgi?id=2238746

Comment 14 Fedora Update System 2023-09-15 18:58:31 UTC
FEDORA-2023-4025f362c0 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 15 Fedora Update System 2023-09-20 01:06:33 UTC
FEDORA-2023-bb295d0bd4 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 16 Fedora Update System 2023-09-20 01:31:19 UTC
FEDORA-2023-f675d09ee6 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.