Allow double close of codecs (#364)

Video/AudioTrack.NewRTPReader() internally closes encoder on error.
It caused double free if user closes reader after error.
This commit is contained in:
Atsushi Watanabe
2021-11-21 22:57:50 +09:00
committed by GitHub
parent 1f313a9d61
commit a88c2daf89
12 changed files with 147 additions and 1 deletions

View File

@@ -1,10 +1,11 @@
package opus
import (
"testing"
"github.com/pion/mediadevices/pkg/codec/internal/codectest"
"github.com/pion/mediadevices/pkg/prop"
"github.com/pion/mediadevices/pkg/wave"
"testing"
)
func TestEncoder(t *testing.T) {
@@ -27,4 +28,16 @@ func TestEncoder(t *testing.T) {
}),
)
})
t.Run("CloseTwice", func(t *testing.T) {
p, err := NewParams()
if err != nil {
t.Fatal(err)
}
codectest.AudioEncoderCloseTwiceTest(t, &p, prop.Media{
Audio: prop.Audio{
SampleRate: 48000,
ChannelCount: 2,
},
})
})
}