diff --git a/exp/audio/vorbis/vorbis.go b/exp/audio/vorbis/vorbis.go index dae486974..67f65a703 100644 --- a/exp/audio/vorbis/vorbis.go +++ b/exp/audio/vorbis/vorbis.go @@ -27,11 +27,11 @@ import ( "github.com/hajimehoshi/go-vorbis" ) -type Stream struct { +type stream struct { buf *bytes.Reader } -func Decode(context *audio.Context, src io.Reader) (*Stream, error) { +func Decode(context *audio.Context, src io.Reader) (io.ReadSeeker, error) { decoded, channels, sampleRate, err := vorbis.Decode(src) if err != nil { return nil, err @@ -48,16 +48,16 @@ func Decode(context *audio.Context, src io.Reader) (*Stream, error) { if err != nil { return nil, err } - s := &Stream{ + s := &stream{ buf: bytes.NewReader(b), } return s, nil } -func (s *Stream) Read(p []byte) (int, error) { +func (s *stream) Read(p []byte) (int, error) { return s.buf.Read(p) } -func (s *Stream) Seek(offset int64, whence int) (int64, error) { +func (s *stream) Seek(offset int64, whence int) (int64, error) { return s.buf.Seek(offset, whence) } diff --git a/exp/audio/vorbis/vorbis_js.go b/exp/audio/vorbis/vorbis_js.go index 6080dc14d..bdf0052ba 100644 --- a/exp/audio/vorbis/vorbis_js.go +++ b/exp/audio/vorbis/vorbis_js.go @@ -25,19 +25,19 @@ import ( "github.com/hajimehoshi/ebiten/exp/audio" ) -type Stream struct { +type stream struct { buf *bytes.Reader } // TODO: This just uses decodeAudioData can treat audio files other than Ogg/Vorbis. // TODO: This doesn't work on iOS which doesn't have Ogg/Vorbis decoder. -func Decode(context *audio.Context, src io.Reader) (*Stream, error) { +func Decode(context *audio.Context, src io.Reader) (io.ReadSeeker, error) { b, err := ioutil.ReadAll(src) if err != nil { return nil, err } - s := &Stream{} + s := &stream{} ch := make(chan struct{}) // TODO: 1 is a correct second argument? @@ -61,10 +61,10 @@ func Decode(context *audio.Context, src io.Reader) (*Stream, error) { return s, nil } -func (s *Stream) Read(p []byte) (int, error) { +func (s *stream) Read(p []byte) (int, error) { return s.buf.Read(p) } -func (s *Stream) Seek(offset int64, whence int) (int64, error) { +func (s *stream) Seek(offset int64, whence int) (int64, error) { return s.buf.Seek(offset, whence) }