From 68b1bc54ce11a3e2baa2e3c9786466405b8948bc Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 24 Oct 2025 00:04:05 +0300 Subject: [PATCH] fix: add stub implementation for CGO audio on non-ARM platforms Provides no-op AudioSource implementations for platforms that don't support ARM CGO audio (x86_64, darwin, etc.). This allows golangci-lint to run successfully on any platform without requiring ARM cross-compilation toolchain. The stub implementations return errors when called, ensuring that if they're accidentally used at runtime on non-ARM platforms, it will fail gracefully with a clear error message rather than undefined symbols. Build constraints ensure the real CGO implementation is used on linux/arm and linux/arm64, while stubs are used everywhere else. --- internal/audio/cgo_source_stub.go | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/audio/cgo_source_stub.go diff --git a/internal/audio/cgo_source_stub.go b/internal/audio/cgo_source_stub.go new file mode 100644 index 00000000..0df2121d --- /dev/null +++ b/internal/audio/cgo_source_stub.go @@ -0,0 +1,50 @@ +//go:build !linux || (!arm && !arm64) + +package audio + +import "fmt" + +// StubSource is a no-op implementation for platforms without CGO audio support +type StubSource struct { + direction string + alsaDevice string +} + +// NewCgoOutputSource creates a stub audio source for output (unsupported platforms) +func NewCgoOutputSource(alsaDevice string) AudioSource { + return &StubSource{ + direction: "output", + alsaDevice: alsaDevice, + } +} + +// NewCgoInputSource creates a stub audio source for input (unsupported platforms) +func NewCgoInputSource(alsaDevice string) AudioSource { + return &StubSource{ + direction: "input", + alsaDevice: alsaDevice, + } +} + +// Connect returns an error indicating CGO audio is not supported +func (s *StubSource) Connect() error { + return fmt.Errorf("CGO audio not supported on this platform") +} + +// Disconnect is a no-op +func (s *StubSource) Disconnect() {} + +// IsConnected returns false +func (s *StubSource) IsConnected() bool { + return false +} + +// ReadMessage returns an error +func (s *StubSource) ReadMessage() (uint8, []byte, error) { + return 0, nil, fmt.Errorf("CGO audio not supported on this platform") +} + +// WriteMessage returns an error +func (s *StubSource) WriteMessage(msgType uint8, payload []byte) error { + return fmt.Errorf("CGO audio not supported on this platform") +}