mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
Revert "audio: bug fix: crash with uncomparable source"
This reverts commit e980d59191
.
Reason: Compile error with Go 1.19
This commit is contained in:
parent
e980d59191
commit
420a6c16de
@ -37,7 +37,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -189,15 +188,11 @@ func (c *Context) addPlayingPlayer(p *playerImpl) {
|
|||||||
defer c.m.Unlock()
|
defer c.m.Unlock()
|
||||||
c.playingPlayers[p] = struct{}{}
|
c.playingPlayers[p] = struct{}{}
|
||||||
|
|
||||||
if !reflect.ValueOf(p.sourceIdent()).Comparable() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the source duplication
|
// Check the source duplication
|
||||||
srcs := map[any]struct{}{}
|
srcs := map[any]struct{}{}
|
||||||
for p := range c.playingPlayers {
|
for p := range c.playingPlayers {
|
||||||
if _, ok := srcs[p.sourceIdent()]; ok {
|
if _, ok := srcs[p.sourceIdent()]; ok {
|
||||||
c.err = errors.New("audio: the same source must not be used by multiple Player objects")
|
c.err = errors.New("audio: a same source is used by multiple Player")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
srcs[p.sourceIdent()] = struct{}{}
|
srcs[p.sourceIdent()] = struct{}{}
|
||||||
|
@ -16,7 +16,6 @@ package audio_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
@ -148,32 +147,4 @@ func TestNonSeekableSource(t *testing.T) {
|
|||||||
|
|
||||||
p.Play()
|
p.Play()
|
||||||
p.Pause()
|
p.Pause()
|
||||||
|
|
||||||
if err := audio.UpdateForTesting(); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type uncomparableSource []int
|
|
||||||
|
|
||||||
func (uncomparableSource) Read(buf []byte) (int, error) {
|
|
||||||
return 0, io.EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
// Issue #3039
|
|
||||||
func TestUncomparableSource(t *testing.T) {
|
|
||||||
setup()
|
|
||||||
defer teardown()
|
|
||||||
|
|
||||||
p, err := context.NewPlayer(uncomparableSource{})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Play()
|
|
||||||
p.Pause()
|
|
||||||
|
|
||||||
if err := audio.UpdateForTesting(); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user