mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
audio: Bug fix: Duplicated pausing at reader players
This caused unexpected 'Unread' calls.
This commit is contained in:
parent
1083233d5f
commit
7696d51839
@ -117,11 +117,14 @@ func (p *readerPlayer) ensurePlayer() error {
|
||||
func (p *readerPlayer) Play() {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
p.context.setError(err)
|
||||
return
|
||||
}
|
||||
|
||||
if p.player.IsPlaying() {
|
||||
return
|
||||
}
|
||||
p.player.Play()
|
||||
p.context.addPlayer(p)
|
||||
}
|
||||
@ -129,8 +132,11 @@ func (p *readerPlayer) Play() {
|
||||
func (p *readerPlayer) Pause() {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
p.context.setError(err)
|
||||
|
||||
if p.player == nil {
|
||||
return
|
||||
}
|
||||
if !p.player.IsPlaying() {
|
||||
return
|
||||
}
|
||||
|
||||
@ -143,33 +149,32 @@ func (p *readerPlayer) Pause() {
|
||||
func (p *readerPlayer) IsPlaying() bool {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
p.context.setError(err)
|
||||
|
||||
if p.player == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return p.player.IsPlaying()
|
||||
}
|
||||
|
||||
func (p *readerPlayer) Volume() float64 {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
p.context.setError(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
return p.player.Volume()
|
||||
}
|
||||
|
||||
func (p *readerPlayer) SetVolume(volume float64) {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
if err := p.ensurePlayer(); err != nil {
|
||||
p.context.setError(err)
|
||||
return
|
||||
}
|
||||
|
||||
p.player.SetVolume(volume)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user