mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio: Rename stream -> src
This commit is contained in:
parent
6a1afe8fbe
commit
a0bd31ef1f
@ -21,21 +21,21 @@ import (
|
|||||||
|
|
||||||
// InfiniteLoop represents a loop which never ends.
|
// InfiniteLoop represents a loop which never ends.
|
||||||
type InfiniteLoop struct {
|
type InfiniteLoop struct {
|
||||||
stream ReadSeekCloser
|
src ReadSeekCloser
|
||||||
size int64
|
size int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInfiniteLoop creates a new infinite loop stream with a stream and size in bytes.
|
// NewInfiniteLoop creates a new infinite loop stream with a source stream and size in bytes.
|
||||||
func NewInfiniteLoop(stream ReadSeekCloser, size int64) *InfiniteLoop {
|
func NewInfiniteLoop(src ReadSeekCloser, size int64) *InfiniteLoop {
|
||||||
return &InfiniteLoop{
|
return &InfiniteLoop{
|
||||||
stream: stream,
|
src: src,
|
||||||
size: size,
|
size: size,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read is implementation of ReadSeekCloser's Read.
|
// Read is implementation of ReadSeekCloser's Read.
|
||||||
func (i *InfiniteLoop) Read(b []byte) (int, error) {
|
func (i *InfiniteLoop) Read(b []byte) (int, error) {
|
||||||
n, err := i.stream.Read(b)
|
n, err := i.src.Read(b)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
if _, err := i.Seek(0, io.SeekStart); err != nil {
|
if _, err := i.Seek(0, io.SeekStart); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -52,7 +52,7 @@ func (i *InfiniteLoop) Seek(offset int64, whence int) (int64, error) {
|
|||||||
case io.SeekStart:
|
case io.SeekStart:
|
||||||
next = offset
|
next = offset
|
||||||
case io.SeekCurrent:
|
case io.SeekCurrent:
|
||||||
current, err := i.stream.Seek(0, io.SeekCurrent)
|
current, err := i.src.Seek(0, io.SeekCurrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func (i *InfiniteLoop) Seek(offset int64, whence int) (int64, error) {
|
|||||||
return 0, fmt.Errorf("audio: position must >= 0")
|
return 0, fmt.Errorf("audio: position must >= 0")
|
||||||
}
|
}
|
||||||
next %= i.size
|
next %= i.size
|
||||||
pos, err := i.stream.Seek(next, io.SeekStart)
|
pos, err := i.src.Seek(next, io.SeekStart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -73,5 +73,5 @@ func (i *InfiniteLoop) Seek(offset int64, whence int) (int64, error) {
|
|||||||
|
|
||||||
// Close is implementation of ReadSeekCloser's Close.
|
// Close is implementation of ReadSeekCloser's Close.
|
||||||
func (l *InfiniteLoop) Close() error {
|
func (l *InfiniteLoop) Close() error {
|
||||||
return l.stream.Close()
|
return l.src.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user