mirror of https://github.com/jetkvm/kvm.git
Add memory barrier and improve error logging in audio implementation
- Add missing __sync_synchronize() in capture init to match playback init path - Add error handling for os.Setenv calls with warning logs on failure - Add logging when ALSA channel map is unavailable (assumes standard L/R order)
This commit is contained in:
parent
d42024b024
commit
55bf170a14
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue