Release audio resources before reconnecting
This commit is contained in:
committed by
Brandon McGinty
parent
25467405b8
commit
d07d7342da
+17
@@ -81,6 +81,23 @@ type Barnard struct {
|
|||||||
adminACL *gumble.ACL
|
adminACL *gumble.ACL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanupConnectionAudio releases connection-owned audio resources before a
|
||||||
|
// reconnect replaces them. It is intentionally idempotent for repeated
|
||||||
|
// disconnect notifications.
|
||||||
|
func (b *Barnard) cleanupConnectionAudio() {
|
||||||
|
if b.Stream != nil {
|
||||||
|
stream := b.Stream
|
||||||
|
b.Stream = nil
|
||||||
|
stream.Destroy()
|
||||||
|
}
|
||||||
|
b.FileStreamMutex.Lock()
|
||||||
|
if b.FileStream != nil {
|
||||||
|
_ = b.FileStream.Stop()
|
||||||
|
b.FileStream = nil
|
||||||
|
}
|
||||||
|
b.FileStreamMutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Barnard) StopTransmission() {
|
func (b *Barnard) StopTransmission() {
|
||||||
if b.Tx {
|
if b.Tx {
|
||||||
b.Notify("micdown", "me", "")
|
b.Notify("micdown", "me", "")
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
|||||||
reason = e.String
|
reason = e.String
|
||||||
}
|
}
|
||||||
b.stopRecordingForDisconnect()
|
b.stopRecordingForDisconnect()
|
||||||
|
b.cleanupConnectionAudio()
|
||||||
|
|
||||||
// Tone test cleanup
|
// Tone test cleanup
|
||||||
if b.ToneTest {
|
if b.ToneTest {
|
||||||
|
|||||||
@@ -53,6 +53,14 @@ func TestNotificationExpansionIsSinglePassAndNotifyDoesNotBlock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression: reconnect replaced Stream without destroying the old capture
|
||||||
|
// and renderer resources. Cleanup must be safe for repeated disconnects.
|
||||||
|
func TestCleanupConnectionAudioIsIdempotent(t *testing.T) {
|
||||||
|
b := &Barnard{}
|
||||||
|
b.cleanupConnectionAudio()
|
||||||
|
b.cleanupConnectionAudio()
|
||||||
|
}
|
||||||
|
|
||||||
func TestUserChangeNotification(t *testing.T) {
|
func TestUserChangeNotification(t *testing.T) {
|
||||||
current := &gumble.Channel{ID: 1, Name: "Current"}
|
current := &gumble.Channel{ID: 1, Name: "Current"}
|
||||||
other := &gumble.Channel{ID: 2, Name: "Other"}
|
other := &gumble.Channel{ID: 2, Name: "Other"}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ Priority 1: transport, lifecycle, and correctness
|
|||||||
Stop and join all audio stream goroutines before renderer shutdown; make
|
Stop and join all audio stream goroutines before renderer shutdown; make
|
||||||
render reject work after shutdown without panicking.
|
render reject work after shutdown without panicking.
|
||||||
|
|
||||||
11. Reconnect leaks the old audio stream
|
[x] 11. Reconnect leaks the old audio stream
|
||||||
File: client.go
|
File: client.go
|
||||||
OnDisconnect starts reconnecting but never destroys the existing Stream or
|
OnDisconnect starts reconnecting but never destroys the existing Stream or
|
||||||
stops its file player/capture routine. connect creates a new Stream and
|
stops its file player/capture routine. connect creates a new Stream and
|
||||||
|
|||||||
Reference in New Issue
Block a user