audio: Bug fix: nosync might cause unexpected panics because of runtime.Gosched

This commit is contained in:
Hajime Hoshi 2017-06-04 03:42:26 +09:00
parent 873b3905df
commit cf452bb709

View File

@ -31,10 +31,10 @@ import (
"errors"
"io"
"runtime"
"sync"
"time"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/internal/sync"
"github.com/hajimehoshi/oto"
)
@ -118,32 +118,32 @@ func (p *players) Read(b []byte) (int, error) {
func (p *players) addPlayer(player *Player) {
p.Lock()
defer p.Unlock()
p.players[player] = struct{}{}
p.Unlock()
}
func (p *players) removePlayer(player *Player) {
p.Lock()
defer p.Unlock()
delete(p.players, player)
p.Unlock()
}
func (p *players) addSeeking(player *Player) {
p.Lock()
defer p.Unlock()
p.seekings[player] = struct{}{}
p.Unlock()
}
func (p *players) removeSeeking(player *Player) {
p.Lock()
defer p.Unlock()
delete(p.seekings, player)
p.Unlock()
}
func (p *players) hasPlayer(player *Player) bool {
p.RLock()
defer p.RUnlock()
_, ok := p.players[player]
p.RUnlock()
return ok
}