godot: Cannot record audio on Linux when compiled with -fPIC
Godot version
3.4.stable
System information
Linux 5.15.4-arch1-1
Issue description
The following code captures audio from a mic and plays it back:
extends Node
var capture := AudioEffectCapture.new()
var playback: AudioStreamGeneratorPlayback
func _ready():
var idx := AudioServer.get_bus_count()
AudioServer.add_bus(idx)
AudioServer.set_bus_mute(idx, true)
AudioServer.add_bus_effect(idx, capture)
var mic := AudioStreamPlayer.new()
mic.stream = AudioStreamMicrophone.new()
mic.bus = AudioServer.get_bus_name(idx)
add_child(mic)
mic.play()
var player := AudioStreamPlayer.new()
player.stream = AudioStreamGenerator.new()
playback = player.get_stream_playback()
add_child(player)
player.play()
func _physics_process(_delta: float):
var n := capture.get_frames_available()
var recorded := capture.get_buffer(n)
var maxval := 0.0
for i in range(n):
playback.push_frame(recorded[i])
capture.clear_buffer()
In godot 3.3.4, it works as expected. In godot 3.4, I hear nothing.
Steps to reproduce
- Run the example project with godot 3.3.4
- Talk into your mic
- Verify you hear your voice played back
- Run the example project with Godot 3.4
- Talk into your mic
- Hear nothing played back
Minimal reproduction project
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 15 (11 by maintainers)
I’m getting extrememly confused. This problem seems specific to the godot 3.4 PKGBUILD for ArchLinux. If I download that
PKGBUILD
and runmakepkg -s
, the resulting godot binary cannot capture audio. If I unpack the source .tgz and compile with the same flags, it seems to work fine:I’ll keep investigating, but it seems like this is probably an Arch-specific packaging issue and not a Godot bug.
@extremety1989 if you’re asking about this issue in particular,
n
is nonzero but the data fromcapture.get_frames_available()
is all0
(if compiled with-fPIC
).If you’re asking for general help, this issue isn’t the place. Check out some of the community resources, the docs, the godot-voip plugin, or the audio recording demo
I just double-checked and confirmed – removing
-fPIC
from https://github.com/archlinux/svntogit-community/blob/packages/godot/trunk/PKGBUILD#L49-L50 fixes the issue. Is this a bug in Godot or in the Arch packaging? It seems like compiling with-fPIC
should work, though I also see this line https://github.com/archlinux/svntogit-community/blob/packages/godot/trunk/PKGBUILD#L23 messing with the automatically-addedpie
flags.The issue seems to be
-fPIC
in theCFLAGS
andCXXFLAGS