mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
vorbis: Bug fix: Read was not responsible with Close (#569)
This commit is contained in:
parent
0d4bada021
commit
f4e018a336
@ -45,7 +45,11 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
|||||||
|
|
||||||
// Close is implementation of io.Closer's Close.
|
// Close is implementation of io.Closer's Close.
|
||||||
func (s *Stream) Close() error {
|
func (s *Stream) Close() error {
|
||||||
return s.decoded.Close()
|
runtime.SetFinalizer(s, nil)
|
||||||
|
if err := s.decoded.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Length returns the size of decoded stream in bytes.
|
// Length returns the size of decoded stream in bytes.
|
||||||
@ -83,9 +87,6 @@ func (d *decoded) readUntil(posInBytes int) error {
|
|||||||
d.readBytes += n * 2
|
d.readBytes += n * 2
|
||||||
}
|
}
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
if err := d.source.Close(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -143,6 +144,9 @@ func (d *decoded) Seek(offset int64, whence int) (int64, error) {
|
|||||||
|
|
||||||
func (d *decoded) Close() error {
|
func (d *decoded) Close() error {
|
||||||
runtime.SetFinalizer(d, nil)
|
runtime.SetFinalizer(d, nil)
|
||||||
|
if err := d.source.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,5 +201,7 @@ func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
|||||||
s = r
|
s = r
|
||||||
size = r.Length()
|
size = r.Length()
|
||||||
}
|
}
|
||||||
return &Stream{decoded: s, size: size}, nil
|
stream := &Stream{decoded: s, size: size}
|
||||||
|
runtime.SetFinalizer(stream, (*Stream).Close)
|
||||||
|
return stream, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user