mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
driver: Remove Suspend/ResumeAudio from UIContext
This commit is contained in:
parent
63fbffa9f6
commit
8e9f5b9535
@ -22,8 +22,6 @@ import (
|
||||
type UIContext interface {
|
||||
SetSize(width, height int, scale float64)
|
||||
Update(afterFrameUpdate func()) error
|
||||
SuspendAudio()
|
||||
ResumeAudio()
|
||||
}
|
||||
|
||||
// RegularTermination represents a regular termination.
|
||||
|
@ -33,6 +33,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/glfw"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/internal/thread"
|
||||
)
|
||||
|
||||
@ -850,10 +851,10 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
|
||||
u.input.update(u.window, u.getScale()*u.glfwScale())
|
||||
|
||||
defer context.ResumeAudio()
|
||||
defer hooks.ResumeAudio()
|
||||
|
||||
for !u.isRunnableInBackground() && u.window.GetAttrib(glfw.Focused) == 0 {
|
||||
context.SuspendAudio()
|
||||
hooks.SuspendAudio()
|
||||
// Wait for an arbitrary period to avoid busy loop.
|
||||
time.Sleep(time.Second / 60)
|
||||
glfw.PollEvents()
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
)
|
||||
|
||||
type UserInterface struct {
|
||||
@ -204,10 +205,10 @@ func (u *UserInterface) suspended() bool {
|
||||
|
||||
func (u *UserInterface) update() error {
|
||||
if u.suspended() {
|
||||
u.context.SuspendAudio()
|
||||
hooks.SuspendAudio()
|
||||
return nil
|
||||
}
|
||||
u.context.ResumeAudio()
|
||||
hooks.ResumeAudio()
|
||||
|
||||
u.input.UpdateGamepads()
|
||||
u.updateSize()
|
||||
@ -257,9 +258,9 @@ func (u *UserInterface) loop(context driver.UIContext) <-chan error {
|
||||
defer t.Stop()
|
||||
for range t.C {
|
||||
if u.suspended() {
|
||||
u.context.SuspendAudio()
|
||||
hooks.SuspendAudio()
|
||||
} else {
|
||||
u.context.ResumeAudio()
|
||||
hooks.ResumeAudio()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/internal/thread"
|
||||
)
|
||||
|
||||
@ -276,11 +277,11 @@ func (u *UserInterface) update(context driver.UIContext) error {
|
||||
select {
|
||||
case <-renderCh:
|
||||
case <-t.C:
|
||||
context.SuspendAudio()
|
||||
hooks.SuspendAudio()
|
||||
<-renderCh
|
||||
}
|
||||
|
||||
context.ResumeAudio()
|
||||
hooks.ResumeAudio()
|
||||
|
||||
defer func() {
|
||||
renderEndCh <- struct{}{}
|
||||
|
@ -131,11 +131,3 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *uiContext) SuspendAudio() {
|
||||
hooks.SuspendAudio()
|
||||
}
|
||||
|
||||
func (c *uiContext) ResumeAudio() {
|
||||
hooks.ResumeAudio()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user