cpal icon indicating copy to clipboard operation
cpal copied to clipboard

No system sound recorded from Virtual_Audio_Input

Open ghost opened this issue 8 months ago • 8 comments

When there is no physical sound card in pulseaudio, cpal refuse to record any sound from the Virtual_Audio_Output

pactl list sinks
Sink #0
	State: IDLE
	Name: audio_output
	Description: Virtual_Audio_Output
	Driver: module-null-sink.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 0
	Mute: no
	Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor Source: audio_output.monitor
	Latency: 990983 usec, configured 2000000 usec
	Flags: DECIBEL_VOLUME LATENCY SET_FORMATS 
	Properties:
		device.description = "Virtual_Audio_Output"
		device.class = "abstract"
		device.icon_name = "audio-card"
	Formats:
		pcm
#!/usr/bin/pulseaudio -nF

### Create virtual output device sink
load-module module-null-sink sink_name=audio_output sink_properties=device.description="Virtual_Audio_Output"

### Create virtual input device sink
load-module module-null-sink sink_name=audio_input sink_properties=device.description="Virtual_Audio_Input"

### Create a virtual audio source linked up to the virtual input device
load-module module-virtual-source source_name=microphone master=audio_input.monitor source_properties=device.description="Virtual_Microphone"

### Allow pulse audio to be accessed via TCP (from localhost only), to allow other users to access the virtual devices
load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

ghost avatar Mar 31 '26 11:03 ghost

Could you share a minimal code snippet and the error or unexpected behaviour you're seeing? The audio_output.monitor source should appear in input_devices() and support recording. Knowing how you're selecting the device will help narrow this down.

roderickvd avatar Apr 12 '26 21:04 roderickvd

https://github.com/rustdesk/rustdesk/blob/2f694c0eb2b40774285447498bee6926837602ac/src/server/audio_service.rs#L161

vanmilleru avatar Apr 13 '26 04:04 vanmilleru

Can you be more explicit about the sources you're seeing, error that's thrown, etc.?

roderickvd avatar Apr 13 '26 18:04 roderickvd

I can see Virtual_Audio_Output on rustdesk's gui and it's not throwing any error. but it's simply not recording from pulseaudio.

meanwhile on exactly the same container i can record pulseaudio using other program which is not relying on cpal.

vanmilleru avatar Apr 14 '26 07:04 vanmilleru

Could you try cpal's record_wav example? I'd like to isolate whether this is a cpal or RustDesk thing.

roderickvd avatar Apr 14 '26 14:04 roderickvd

@roderickvd Could you send me a binary for x86 Linux?

vanmilleru avatar Apr 15 '26 14:04 vanmilleru

That's difficult given the amount of distros; cpal doesn't have binary distribution set up. Compiling from source is easy though:

  1. Install Rust using https://rustup.rs
  2. Clone cpal using git clone https://github.com/RustAudio/cpal
  3. Build and run using cargo run --example record_wav

roderickvd avatar Apr 15 '26 14:04 roderickvd

Closing as there is not enough information to work with, and OP's account has been deleted

LastExceed avatar Oct 11 '26 19:10 LastExceed