mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-13 03:23:14 +01:00
audio, audio/vorbis: ignore error at the initial Seek
This mitigates the issue of non-seekable source. At least, vorbis.DecodeF32 and audio.NewPlayerF32 works. Updates #3192
This commit is contained in:
parent
38f370f819
commit
6cdc2a693b
@ -408,7 +408,9 @@ func newTimeStream(r io.Reader, seekable bool, sampleRate int, bitDepthInBytes i
|
|||||||
// Get the current position of the source.
|
// Get the current position of the source.
|
||||||
pos, err := s.r.(io.Seeker).Seek(0, io.SeekCurrent)
|
pos, err := s.r.(io.Seeker).Seek(0, io.SeekCurrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
// Ignore the error, as the undelrying source might not support Seek (#3192).
|
||||||
|
// This happens when vorbis.Decode* is used, as vorbis.Stream is io.Seeker whichever the underlying source is.
|
||||||
|
pos = 0
|
||||||
}
|
}
|
||||||
s.pos.Store(pos)
|
s.pos.Store(pos)
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,8 @@ func TestNonSeeker(t *testing.T) {
|
|||||||
if got, want := s.SampleRate(), audioContext.SampleRate(); got != want {
|
if got, want := s.SampleRate(), audioContext.SampleRate(); got != want {
|
||||||
t.Errorf("s.SampleRate(): got: %d, want: %d", got, want)
|
t.Errorf("s.SampleRate(): got: %d, want: %d", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Check the result of io.ReadAll (#3192).
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNonSeekerF32(t *testing.T) {
|
func TestNonSeekerF32(t *testing.T) {
|
||||||
@ -150,4 +152,12 @@ func TestNonSeekerF32(t *testing.T) {
|
|||||||
if got, want := s.Length(), int64(0); got != want {
|
if got, want := s.Length(), int64(0); got != want {
|
||||||
t.Errorf("s.Length(): got: %d, want: %d", got, want)
|
t.Errorf("s.Length(): got: %d, want: %d", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf, err := io.ReadAll(s)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("io.ReadAll: %v", err)
|
||||||
|
}
|
||||||
|
if len(buf) == 0 {
|
||||||
|
t.Errorf("len(buf): got: %d, want: > 0", len(buf))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user