godot: Microphone recording doesn't work on Linux with official builds
Godot version: Git https://github.com/godotengine/godot/commit/924db5fa58ab28912857029ec8dd34fbde771550
OS/device including version: Fedora 30, PulseAudio
Issue description: Microphone recording doesn’t seem to work on Linux, even though Godot appears as a capture device when running the Mic Record Demo:
Saving the file after recording a few seconds will write a WAV file that contains only a few seconds of silence. I made sure the microphone is not muted by recording a sample in Audacity beforehand (where it works correctly).
Steps to reproduce: Use the “Mic Record Demo” from godot-demo-projects. Click the Record button, say something, then press Stop. Save the audio to a WAV file then inspect it using a media player.
See also https://github.com/godotengine/godot-demo-projects/issues/359. This issue has been confirmed by @CombustibleLemonade in https://github.com/godotengine/godot-demo-projects/issues/359#issuecomment-547962679, so I’ll add the confirmed
label right away.
Edit: This issue is not exclusive to Linux and has been occurring on Windows and macOS too (both x86 and ARM).
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 20
- Comments: 40 (19 by maintainers)
Commits related to this issue
- monkeyfix: make the microphone record on linux This fix is not a real fix. I wish I could properly fix the bug, but it eludes me. See https://github.com/godotengine/godot/issues/33184 — committed to Adrenesis/godot by Goutte 4 years ago
- monkeyfix: make the microphone record on linux This fix is not a real fix. I wish I could properly fix the bug, but it eludes me. See https://github.com/godotengine/godot/issues/33184 — committed to Adrenesis/godot by Goutte 4 years ago
- Initializing the library the worst way possible At least, it's kind of recording something... However, I'm still stuck due to this bug : https://github.com/godotengine/godot/issues/33184 So, I'll h... — committed to Miouyouyou/godot_speech_port by Miouyouyou 4 years ago
- fix mic on linux adding --verbose arg https://github.com/godotengine/godot/issues/33184 — committed to thegatesbrowser/thegates-old by Nordup 4 months ago
- fix mic on linux adding --verbose arg https://github.com/godotengine/godot/issues/33184 — committed to thegatesbrowser/thegates-old by Nordup 4 months ago
- fix mic on linux adding --verbose arg https://github.com/godotengine/godot/issues/33184 — committed to thegatesbrowser/thegates by Nordup 4 months ago
@FeralBytes the change might be in the fa26a551. After reverting that in Master the recording started working for me. The changes look pretty innocent and I cannot tell just by looking what is the problem. Any thoughts @marcelofg55.
Edit: Adding this line seems to be enough fix it for me. Race condition / synchronization problem perhaps?
I was looking closely at the code and I’m no expert at C++ or threaded stuff. When
set_recording_active
is set to false, it never waits for the thread to finish. The code inside the thread_io_thread_process
does know when to stop processing, but it seems like that function is still being called since the thread never finishes.Also
_io_thread_process
really just calls_update_buffer
. Though what’s strange is that another function called_update
also calls_update_buffer
as well. I’m not sure where_update
gets called from but it never checks if the recording has stopped.Maybe I can try to clone the repo and test to see if there is any issues there.
Over 3 years later and this is still happening on Godot 4.01 stable. Recorded audio is silent every time. The length of the recording is accurate but the data is all 0s. You can clearly hear yourself with the Record bus unmuted, so imo the issue lies somewhere within the set_recording_active() and/or get_recording() functions. I tried to figure it out but I am not equipped enough to figure it out. Please help anyone 😢
@Calinou 3.2 beta 4 is broken, also 3.1.1 is broken Also 3.1 Stable does not work. A what stage of 3.1 was it added at Alpha? Ah 3.1 Alpha1 works. I then tested Beta 1 and it was broken. I then worked backwards and found that even 3.1. Alpha2 was broken.
So a change between 3.1 Alpha1 and 3.1Alpha2 broke mic recording for many versions of Linux.
EDIT: Tested in both Linux Mint 19.2 and 19.3, same result.
More testing, i was reading through the source code and wanted to get more details. I run the test project in verbose mode, and all of the sudden, it starts to work.
For some unknown reason, verbose mode, fixes the issue? And running without verbose mode, brings the issue back.
All I can assume here and what I’m guessing, is that the verbose printing is delaying something long enough for it to work?
EDIT: Oh wait, that’s what everyone above has said as well, didn’t check that part, whoops.
I could finally reproduce this too, it seems like official builds don’t work but local builds do. Likely an issue with the different PulseAudio versions used on the official buildsystem and on user systems.