stop file playback processes and their children reliably

Kill ffmpeg's whole process group rather than just the process.
ffmpeg spawns helpers for some inputs, so stopping playback left them
running and holding the output pipe open. The player now starts the
command in its own process group and signals the group.

Wait for the playback worker to finish before starting a new file.
Playing a second file while the first was shutting down left two
workers writing to the same stream.

Make pausing nonblocking.
The pause path could block on a full pipe and hang the UI thread that
requested it.

Install and reset the stereo encoder under the client lock.
File playback swapped the encoder field directly while a voice frame
could be encoding with it, and a finished file left the encoder
carrying state into the next one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Brandon McGinty
2026-08-20 14:42:52 -04:00
co-authored by Claude Opus 5
parent fbb6a148ff
commit c5baaae6a7
9 changed files with 189 additions and 80 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ func (b *Barnard) connect(reconnect bool) bool {
b.Stream.SetAGCEnabled(b.UserConfig.GetAGCEnabled())
// Initialize stereo encoder for file playback
b.Client.AudioEncoderStereo = opus.NewStereoEncoder()
b.Client.SetStereoEncoder(opus.NewStereoEncoder())
// Initialize file player
b.FileStreamMutex.Lock()