mirror of
https://github.com/pion/mediadevices.git
synced 2025-11-02 20:54:02 +08:00
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:
@@ -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,
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user