First working version of two monos at the same time.

This commit is contained in:
Pbopbo
2026-04-02 18:55:10 +02:00
parent 036b5f80dd
commit a126613739
4 changed files with 11 additions and 12 deletions

View File

@@ -145,6 +145,7 @@ class PyAlsaAudioInput(audio_io.ThreadedAudioInput):
def __init__(self, device, pcm_format: audio_io.PcmFormat):
super().__init__()
logging.info("PyALSA: device = %s", device)
self._device = str(device) if not isinstance(device, str) else device
if self._device.isdigit():
self._device = 'default' if self._device == '0' else f'hw:{self._device}'
@@ -221,7 +222,7 @@ class PyAlsaAudioInput(audio_io.ThreadedAudioInput):
expected_mono = self._periodsize * 2
expected_stereo = self._periodsize * 2 * 2
# self._hw_channels = 2 if len(data) == expected_stereo else 1
self._hw_channels = 2 # TODO fix stereo detection, on first read might detect 0 data
self._hw_channels = self._actual_channels
logging.info("PyALSA first read: bytes=%d detected_hw_channels=%d requested_channels=%d",
len(data), self._hw_channels, self._actual_channels)
self._first_read = False

View File

@@ -398,11 +398,8 @@ async def init_radio(transport: str, conf: auracast_config.AuracastConfigGroup,
# Skip ch2 in stereo mode as it's already captured as part of stereo pair
continue
else:
# Mono mode: individual channel capture
device_index = resolve_input_device_index(sel)
if device_index is None:
raise HTTPException(status_code=400, detail=f"Audio device '{sel}' not found.")
big.audio_source = f'device:{device_index}'
# Mono mode: use dsnoop virtual device directly (ch1=left, ch2=right)
big.audio_source = f'device:{sel}'
big.input_format = f"int16le,{hardware_capture_rate},1"
continue
@@ -944,7 +941,7 @@ async def _startup_autostart_event():
log.info("[STARTUP] Auracast multicast server startup: initializing settings cache, I2C, and PipeWire cache")
# Run install_asoundconf.sh script
script_path = os.path.join(os.path.dirname(__file__), '..', 'misc', 'install_asoundconf.sh')
script_path = os.path.join(os.path.dirname(__file__), '..', '..', 'misc', 'install_asoundconf.sh')
try:
log.info("[STARTUP] Running install_asoundconf.sh script")
result = subprocess.run(['bash', script_path], capture_output=True, text=True, check=True)

View File

@@ -6,8 +6,8 @@ pcm.ch1 {
channels 2
rate 48000
format S16_LE
period_size 120
buffer_size 240
period_size 240
buffer_size 960
}
bindings.0 0
}
@@ -21,8 +21,8 @@ pcm.ch2 {
channels 2
rate 48000
format S16_LE
period_size 120
buffer_size 240
period_size 240
buffer_size 960
}
bindings.0 1
}

View File

@@ -1 +1,2 @@
sudo cp src/misc/asound.conf /etc/asound.conf
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
sudo cp "$SCRIPT_DIR/asound.conf" /etc/asound.conf