-
-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple_playback blocks (no sound) on Ubuntu 18.04 / pulseaudio. #57
Comments
Sample Same cause inside: #0 0x00007ffff7337cf6 in __GI_ppoll (fds=0x55555578f330, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
#1 0x00007ffff6ff6ec1 in pa_mainloop_poll () from /usr/lib/x86_64-linux-gnu/libpulse.so
#2 0x00007ffff6ff74d0 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so
#3 0x000055555555c77e in ma_context_enumerate_devices__pulse (pContext=0x7ffffffe6130, callback=0x5555555646da <ma_context_get_devices__enum_callback>, pUserData=0x0) at ../miniaudio.h:13887
#4 0x0000555555564a04 in ma_context_get_devices (pContext=0x7ffffffe6130, ppPlaybackDeviceInfos=0x7ffffffe5ee0, pPlaybackDeviceCount=0x7ffffffe5ecc, ppCaptureDeviceInfos=0x7ffffffe5ee8, pCaptureDeviceCount=0x7ffffffe5ed0) at ../miniaudio.h:22942
#5 0x0000555555577f48 in main (argc=1, argv=0x7fffffffda48) at advanced_config.c:114
up
#1 0x00007ffff6ff6ec1 in pa_mainloop_poll () from /usr/lib/x86_64-linux-gnu/libpulse.so
(gdb)
#2 0x00007ffff6ff74d0 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so
(gdb)
#3 0x000055555555c77e in ma_context_enumerate_devices__pulse (pContext=0x7ffffffe6130, callback=0x5555555646da <ma_context_get_devices__enum_callback>, pUserData=0x0) at ../miniaudio.h:13887
13887 error = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)(pMainLoop, 1, NULL);
Breakpoint 3 at 0x55555555c760: file ../miniaudio.h, line 13887. |
Hmm, that's annoying... I will take a look at this as soon as I can. Can you try the ALSA backend by disabling PulseAudio (Put Thanks for reporting this! |
Thank you for your feedback. Adding |
For convenience, I added a Makefile in branch https://github.com/fidergo-stephane-gourichon/miniaudio/tree/my_experiments see commit fidergo-stephane-gourichon@6c573fa It might also be convenient for exact reproduction. |
I've pushed a potential fix to the dev branch. Relevant commit: 72b0e7b To test, could you add The advance_config example will fail due to the server name not existing, but the deadlock should be gone now. |
Summary: betterI tested your current dev branch (60d6156 which contains 72b0e7b).
Works! 👍
Indeed.
Other tests.Also:
And that one:
records relevant sound for only a very small time (about one fourth of a second). It worked well with ALSA backend. That's probably another issue. |
Detailed output$ git branch -v
* dev 60d6156 Another potential deadlock fix for PulseAudio.
$ gcc -W -Wall -Wextra -g -DMA_DEBUG_OUTPUT=1 simple_playback.c -lpthread -lm -ldl -o simple_playback
(usual "fall through" warnings, -W or -Wextra are enough to cause them)
$ ./simple_playback /usr/share/orage/sounds/Wall_c.wav
[miniaudio] Endian: LE
[miniaudio] SSE2: YES
[miniaudio] AVX2: NO
[miniaudio] AVX512F: NO
[miniaudio] NEON: NO
[PulseAudio] Playback attr: maxlength=5280, tlength=1760, prebuf=-1, minreq=1760, fragsize=1760; internalBufferSizeInFrames=1320
[PulseAudio] Playback actual attr: maxlength=5280, tlength=5280, prebuf=3524, minreq=1760, fragsize=1760; internalBufferSizeInFrames=1320
[PulseAudio]
Audio interne Stéréo analogique (Playback)
Format: 16-bit Signed Integer -> 16-bit Signed Integer
Channels: 1 -> 2
Sample Rate: 11025 -> 44100
Buffer Size: 1320/1 (1320)
Conversion:
Pre Format Conversion: YES
Post Format Conversion: YES
Channel Routing: YES
SRC: YES
Channel Routing at Start: NO
Passthrough: NO
Press Enter to quit...TRACE: Data available: 5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2564
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2496
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2752
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2528
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2752
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2528
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 1888
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Playback: pa_mainloop_iterate(). writableSizeInBytes=0, periodSizeInBytes=5280
TRACE: Data available: 2784 |
Anyway, now it works.
|
Potential fix for the capture issue is in the dev branch. |
Hmm, that's annoying. I've pushed another update with some debug output. Could you post the output of that? One thing I've noticed (which I don't know how to fix just yet) is that it will deadlock when you try capturing without an actual microphone active. So for example, on my machine PulseAudio will have a generic input device even when no microphone is plugged in. In this case it deadlocks. When I plug in my actual microphone and use that as the capture device it will work like normal. I will take a further look at this later to work around those deadlocks (I'm also getting a deadlock with ALSA in my no-microphone-plugged-in scenario above by the way). |
Summary: fixed in dea8309, correct behavior observed.Just tested current dev, now it records sound correctly as long as needed. Recorded sound files play correctly with git branch -v
* dev dea8309 PulseAudio: Experimental fix for a deadlock with PulseAudio.
./simple_capture test_cap2.wav
[miniaudio] Endian: LE
[miniaudio] SSE2: YES
[miniaudio] AVX2: NO
[miniaudio] AVX512F: NO
[miniaudio] NEON: NO
[PulseAudio] Capture attr: maxlength=5280, tlength=1760, prebuf=-1, minreq=1760, fragsize=1760; internalBufferSizeInFrames=1320
[PulseAudio] Capture actual attr: maxlength=5280, tlength=1760, prebuf=-1, minreq=1760, fragsize=1760; internalBufferSizeInFrames=1320
[PulseAudio]
Audio interne Stéréo analogique (Capture)
Format: 32-bit IEEE Floating Point -> 16-bit Signed Integer
Channels: 2 -> 2
Sample Rate: 44100 -> 44100
Buffer Size: 1320/3 (440)
Conversion:
Pre Format Conversion: NO
Post Format Conversion: YES
Channel Routing: NO
SRC: NO
Channel Routing at Start: NO
Passthrough: NO
Press Enter to stop recording...
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=3616.
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=1856.
TRACE: Data available: bytesMapped=96, readableSizeInBytes=96.
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=3456.
TRACE: Data available: bytesMapped=1696, readableSizeInBytes=1696.
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=3488.
TRACE: Data available: bytesMapped=1728, readableSizeInBytes=1728.
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=3616.
TRACE: Data available: bytesMapped=1760, readableSizeInBytes=1856.
TRACE: Data available: bytesMapped=96, readableSizeInBytes=96.
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0
TRACE: Capture: pa_mainloop_iterate(). readableSizeInBytes=0 |
Thanks for testing that. I will organize a release with these fixes soon. |
I've gone ahead and pushed these fixes to the master branch and bumped the version. Just as a side note, this particular part of the PulseAudio backend (among others) will be refactored soon so fingers crossed I don't accidentally reintroduce these bugs... Thanks for reporting these issues! |
Hi.
Context
Ubuntu 18.04 (actually Xubuntu, practically the same) with regular pulseaudio server (version 1:11.1-1ubuntu7.2), no specific tweak. gcc 7.3.0 .
Compile with
I started with current https://github.com/dr-soft/miniaudio/tree/master a.k.a. e184644
Expected
Sound is heard.
Observed
No sound.
No output besides
Press Enter to quit...
. Then I added more output.Additional information.
I have not noticed any other sound problem on the machine : applications work, audio, video, full duplex, everything. There's only an occasional sound corruption on pulseaudio output, solved with a
pulseaudio -k
and autospawn, but that seems unrelated.Debug information
For comfort I fixed unrelated warnings and re-enabled the
printf
in the pulseaudio code. The exact code I now use is pushed to https://github.com/fidergo-stephane-gourichon/miniaudio/tree/test_on_ubuntu1804_pulseaudioHere's a full output:
I also tried with a 44100Hz 2 channel WAV file, with flac file, same result.
I traced with gdb.
Execution blocks inside call to
pa_mainloop_iterate
:Here's a backtrace:
When stuck, I sometimes have a more complete backtrace:
Also, here's the end of an
strace
output:File descriptor 4 may the a communication pipe between threads as shown below.
Can I do something more to help you figuring out what's wrong?
Thanks.
The text was updated successfully, but these errors were encountered: