From 6cd74a9f4db2d6efd1b11ee670e508d76e2ef4de Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 19 Aug 2019 00:13:56 +0900 Subject: [PATCH] uidriver/mobile: Simplify updating logic --- internal/uidriver/mobile/ui.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/internal/uidriver/mobile/ui.go b/internal/uidriver/mobile/ui.go index f0d9b0c1a..2f81fd552 100644 --- a/internal/uidriver/mobile/ui.go +++ b/internal/uidriver/mobile/ui.go @@ -269,19 +269,16 @@ func (u *UserInterface) scaleImpl() float64 { } func (u *UserInterface) update(context driver.UIContext) error { -render: - for { - t := time.NewTimer(500 * time.Millisecond) - defer t.Stop() + t := time.NewTimer(500 * time.Millisecond) + defer t.Stop() - select { - case <-renderCh: - break render - case <-t.C: - context.SuspendAudio() - continue - } + select { + case <-renderCh: + case <-t.C: + context.SuspendAudio() + <-renderCh } + context.ResumeAudio() defer func() {