mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
audio/vorbis: Hide Stream struct
This commit is contained in:
parent
bc49108c40
commit
8c065a28e1
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user