mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
audio: Context should be reset for each test
As the context remembers the last error, the context should be re-created for each test.
This commit is contained in:
parent
396f257629
commit
7e2a679b17
@ -354,13 +354,6 @@ func (p *playerImpl) Close() error {
|
||||
if err := p.src.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !p.runningReadLoop {
|
||||
return nil
|
||||
}
|
||||
|
||||
// p.runningReadLoop is set to false in the loop.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
var context *Context
|
||||
|
||||
func init() {
|
||||
func setup() {
|
||||
var err error
|
||||
context, err = NewContext(44100)
|
||||
if err != nil {
|
||||
@ -32,8 +32,16 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func teardown() {
|
||||
ResetContext()
|
||||
context = nil
|
||||
}
|
||||
|
||||
// Issue #746
|
||||
func TestGC(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
p, _ := NewPlayer(context, BytesReadSeekCloser(make([]byte, 4)))
|
||||
got := PlayersNumForTesting()
|
||||
if want := 0; got != want {
|
||||
@ -70,14 +78,17 @@ func TestGC(t *testing.T) {
|
||||
|
||||
// Issue #853
|
||||
func TestSameSourcePlayers(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
src := BytesReadSeekCloser(make([]byte, 4))
|
||||
p0, err := NewPlayer(context, src)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
p1, err := NewPlayer(context, src)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// As the player does not play yet, error doesn't happen.
|
||||
|
@ -21,3 +21,7 @@ func PlayersNumForTesting() int {
|
||||
c.m.Unlock()
|
||||
return n
|
||||
}
|
||||
|
||||
func ResetContext() {
|
||||
theContext = nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user