diff --git a/internal/audio/c/audio.c b/internal/audio/c/audio.c index 2704340e..028f0151 100644 --- a/internal/audio/c/audio.c +++ b/internal/audio/c/audio.c @@ -588,6 +588,10 @@ static int configure_alsa_device(snd_pcm_t *handle, const char *device_name, uin *channels_swapped_out = is_swapped; } free(chmap); + } else { + fprintf(stdout, "INFO: %s: Channel map not available, assuming standard L/R order\n", + device_name); + fflush(stdout); } } @@ -627,6 +631,7 @@ int jetkvm_audio_capture_init() { if (encoder != NULL || pcm_capture_handle != NULL) { capture_initialized = 0; atomic_store(&capture_stop_requested, 1); + __sync_synchronize(); if (pcm_capture_handle) { snd_pcm_drop(pcm_capture_handle); diff --git a/internal/audio/cgo_source.go b/internal/audio/cgo_source.go index 0fb130c3..65edc28f 100644 --- a/internal/audio/cgo_source.go +++ b/internal/audio/cgo_source.go @@ -81,7 +81,9 @@ func (c *CgoSource) Connect() error { } func (c *CgoSource) connectOutput() error { - os.Setenv("ALSA_CAPTURE_DEVICE", c.alsaDevice) + if err := os.Setenv("ALSA_CAPTURE_DEVICE", c.alsaDevice); err != nil { + c.logger.Warn().Err(err).Str("device", c.alsaDevice).Msg("Failed to set ALSA_CAPTURE_DEVICE") + } const sampleRate = 48000 const frameSize = uint16(sampleRate * 20 / 1000) // 20ms frames @@ -124,7 +126,9 @@ func (c *CgoSource) connectOutput() error { } func (c *CgoSource) connectInput() error { - os.Setenv("ALSA_PLAYBACK_DEVICE", c.alsaDevice) + if err := os.Setenv("ALSA_PLAYBACK_DEVICE", c.alsaDevice); err != nil { + c.logger.Warn().Err(err).Str("device", c.alsaDevice).Msg("Failed to set ALSA_PLAYBACK_DEVICE") + } // USB Audio Gadget uses fixed 48kHz sample rate const inputSampleRate = 48000