mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +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 {
|
if err := p.src.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.runningReadLoop {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// p.runningReadLoop is set to false in the loop.
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
var context *Context
|
var context *Context
|
||||||
|
|
||||||
func init() {
|
func setup() {
|
||||||
var err error
|
var err error
|
||||||
context, err = NewContext(44100)
|
context, err = NewContext(44100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,8 +32,16 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func teardown() {
|
||||||
|
ResetContext()
|
||||||
|
context = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #746
|
// Issue #746
|
||||||
func TestGC(t *testing.T) {
|
func TestGC(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
p, _ := NewPlayer(context, BytesReadSeekCloser(make([]byte, 4)))
|
p, _ := NewPlayer(context, BytesReadSeekCloser(make([]byte, 4)))
|
||||||
got := PlayersNumForTesting()
|
got := PlayersNumForTesting()
|
||||||
if want := 0; got != want {
|
if want := 0; got != want {
|
||||||
@ -70,14 +78,17 @@ func TestGC(t *testing.T) {
|
|||||||
|
|
||||||
// Issue #853
|
// Issue #853
|
||||||
func TestSameSourcePlayers(t *testing.T) {
|
func TestSameSourcePlayers(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
|
||||||
src := BytesReadSeekCloser(make([]byte, 4))
|
src := BytesReadSeekCloser(make([]byte, 4))
|
||||||
p0, err := NewPlayer(context, src)
|
p0, err := NewPlayer(context, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
p1, err := NewPlayer(context, src)
|
p1, err := NewPlayer(context, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// As the player does not play yet, error doesn't happen.
|
// As the player does not play yet, error doesn't happen.
|
||||||
|
@ -21,3 +21,7 @@ func PlayersNumForTesting() int {
|
|||||||
c.m.Unlock()
|
c.m.Unlock()
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ResetContext() {
|
||||||
|
theContext = nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user