stream.go | 3 +++ stream_test.go | 7 ++++++- diff --git a/stream.go b/stream.go index 07a57435b2d99112471251da673f379d92774930..70053df5c796797a5fcf898c14eeac5111b30409 100644 --- a/stream.go +++ b/stream.go @@ -131,5 +131,8 @@ if s.oggfile == nil { return fmt.Errorf("opus stream is uninitialized or already closed") } C.op_free(s.oggfile) + if closer, ok := s.read.(io.Closer); ok { + return closer.Close() + } return nil } diff --git a/stream_test.go b/stream_test.go index 08c07fde8c4eb31f5cae58b84799498328cf54f6..f97089d1456bd6a21947e54ece255071b18e6f78 100644 --- a/stream_test.go +++ b/stream_test.go @@ -5,11 +5,12 @@ package opus import ( + "io" "strings" "testing" ) -func Test(t *testing.T) { +func TestStream(t *testing.T) { // Simple testing, no actual decoding reader := strings.NewReader("hello") _, err := NewStream(reader) @@ -17,3 +18,7 @@ if err == nil { t.Fatalf("Expected error while initializing illegal opus stream") } } + +func TestCloser(t *testing.T) { + /* TODO: test if stream.Close() also closes the underlying reader */ +}