AlexxIT/go2rtc · error

alsa: format S16LE not supported

Error message

alsa: format S16LE not supported

What it means

ALSA Open's capability guard: the device opened fine but does not support the hardcoded PCM format S16_LE which this implementation requires. The device is closed and Open fails — the hardware/driver simply cannot provide 16-bit little-endian samples.

Solutions

  1. Pick a device (pcm path) whose driver supports S16_LE
  2. Configure the system to enable S16 conversion via an ALSA 'plug' device (e.g. plug:... instead of hw:...)
  3. Feed audio through a format-converting producer instead of direct ALSA
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at pkg/alsa/open_linux.go:32 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/764425f036862edd. Report an issue: GitHub.

Appendix: source

Thrown at pkg/alsa/open_linux.go:32

	// alsa:device?audio=/dev/snd/pcmC0D0p
	// TODO: ?audio=default
	// TODO: ?audio=hw:0,0
	// TODO: &sample_rate=48000&channels=2
	// TODO: &backchannel=1
	u, err := url.Parse(rawURL)
	if err != nil {
		return nil, err
	}

	path := u.Query().Get("audio")
	dev, err := device.Open(path)
	if err != nil {
		return nil, err
	}

	if !dev.CheckFormat(device.SNDRV_PCM_FORMAT_S16_LE) {
		_ = dev.Close()
		return nil, errors.New("alsa: format S16LE not supported")
	}

	switch path[len(path)-1] {
	case 'p': // playback
		return newPlayback(dev)
	case 'c': // capture
		return newCapture(dev)
	}

	_ = dev.Close()
	return nil, fmt.Errorf("alsa: unknown path: %s", path)
}

View on GitHub (pinned to c245815e75)