ソースを参照

fix ffmpeg fallback decoder pipe deadlock

Prevent the fallback FFmpeg decoder from deadlocking on longer-running streams.

The decoder previously drained stderr with io.ReadAll() before reading PCM from stdout. Once FFmpeg filled the stdout pipe buffer, the process blocked on further stdout writes, never closed stderr, and io.ReadAll(stderr) never returned. That stalled the decoder before readPCM() could even start.

Drain stderr concurrently in its own goroutine so stdin, stdout, and stderr can all make progress in parallel. This matches the expected pipe handling model for long-running FFmpeg processes and keeps the fallback decoder usable for real streams.
main
Jan 1ヶ月前
コミット
da68cd965d
1個のファイルの変更10行の追加1行の削除
  1. +10
    -1
      internal/ingest/decoder/fallback/ffmpeg.go

+ 10
- 1
internal/ingest/decoder/fallback/ffmpeg.go ファイルの表示

@@ -81,7 +81,16 @@ func (d *FFmpegDecoder) DecodeStream(ctx context.Context, r io.Reader, meta deco
}
}()

stderrData, _ := io.ReadAll(stderr)
// DEADLOCK FIX: stderr and stdout must be drained concurrently.
// Reading stderr synchronously before readPCM means ffmpeg blocks when
// stdout's pipe buffer fills (typically 64KB), which prevents it from
// closing stderr, which prevents ReadAll from returning — deadlock.
var stderrData []byte
wg.Add(1)
go func() {
defer wg.Done()
stderrData, _ = io.ReadAll(stderr)
}()
readErr := d.readPCM(ctx, stdout, sampleRate, channels, meta.SourceID, emit)
waitErr := cmd.Wait()
wg.Wait()


読み込み中…
キャンセル
保存