Avoid treating capture timing as microphone failure

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 12:58:15 -04:00
committed by Brandon McGinty
parent 5db174e92f
commit 64d0ef6f0f
+3 -2
View File
@@ -674,8 +674,9 @@ func (s *Stream) sourceRoutine(inputDevice *string) {
// available. PipeWire and PulseAudio do not guarantee that a Go // available. PipeWire and PulseAudio do not guarantee that a Go
// ticker fires precisely on a capture-frame boundary. // ticker fires precisely on a capture-frame boundary.
hasMicInput := false hasMicInput := false
available := s.deviceSource.CapturedSamples()
var buff []byte var buff []byte
if s.deviceSource.CapturedSamples() >= uint32(frameSize) { if available >= uint32(frameSize) {
buff = s.deviceSource.CaptureSamples(uint32(frameSize)) buff = s.deviceSource.CaptureSamples(uint32(frameSize))
} }
if len(buff) == sampleCount*2 { if len(buff) == sampleCount*2 {
@@ -700,7 +701,7 @@ func (s *Stream) sourceRoutine(inputDevice *string) {
} else { } else {
s.processStereoSamples(int16Buffer, frameSize) s.processStereoSamples(int16Buffer, frameSize)
} }
} else if !micFailed { } else if available >= uint32(frameSize) && !micFailed {
micFailed = true micFailed = true
if s.errorFunc != nil { if s.errorFunc != nil {
s.errorFunc(ErrMic) s.errorFunc(ErrMic)