AlexxIT/go2rtc · error
[alsa] set hw_params
Error message
[alsa] set hw_params: %w
What it means
The SNDRV_PCM_IOCTL_HW_PARAMS ioctl failed while applying hardware parameters (format, rate, channels, buffer size) to the ALSA PCM device. Wraps the errno from the kernel; common causes are unsupported sample format/rate/channel count for the device or the device being in an incompatible state. Called by Start and AddTrack.
Solutions
- Request a different sample format, rate, or channel count supported by the device
- Free other streams using the same PCM device and retry
- Check dmesg for ALSA driver details on why params were rejected
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at pkg/alsa/device/device_linux.go:135 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/8fb80eda95d12115.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/alsa/device/device_linux.go:135
return c2
}
return channels
}
const bufferSize = 4096
func (d *Device) SetHWParams(format byte, rate uint32, channels byte) error {
d.setInterval(SNDRV_PCM_HW_PARAM_CHANNELS, uint32(channels))
d.setInterval(SNDRV_PCM_HW_PARAM_RATE, rate)
d.setMask(SNDRV_PCM_HW_PARAM_FORMAT, uint32(format))
//d.setMask(SNDRV_PCM_HW_PARAM_SUBFORMAT, 0)
// important for smooth playback
d.setInterval(SNDRV_PCM_HW_PARAM_BUFFER_SIZE, bufferSize)
//d.setInterval(SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2000)
if err := ioctl(d.fd, SNDRV_PCM_IOCTL_HW_PARAMS, &d.hwparams); err != nil {
return fmt.Errorf("[alsa] set hw_params: %w", err)
}
_, i := d.getInterval(SNDRV_PCM_HW_PARAM_FRAME_BITS)
d.frameBytes = int(i / 8)
_, periods := d.getInterval(SNDRV_PCM_HW_PARAM_PERIODS)
_, periodSize := d.getInterval(SNDRV_PCM_HW_PARAM_PERIOD_SIZE)
threshold := snd_pcm_uframes_t(periods * periodSize) // same as bufferSize
swparams := snd_pcm_sw_params{
//tstamp_mode: SNDRV_PCM_TSTAMP_ENABLE,
period_step: 1,
avail_min: 1, // start as soon as possible
stop_threshold: threshold,
}
if d.IsCapture() {
swparams.start_threshold = 1View on GitHub (pinned to c245815e75)