diff --git a/audio/audio.go b/audio/audio.go index d6ba8cc3b..2a4e72f61 100644 --- a/audio/audio.go +++ b/audio/audio.go @@ -60,11 +60,6 @@ const ( type Context struct { playerFactory *playerFactory - // inited represents whether the audio device is initialized and available or not. - // On Android, audio loop cannot be started unless JVM is accessible. After updating one frame, JVM should exist. - inited chan struct{} - initedOnce sync.Once - sampleRate int err error ready bool @@ -100,7 +95,6 @@ func NewContext(sampleRate int) *Context { sampleRate: sampleRate, playerFactory: newPlayerFactory(sampleRate), playingPlayers: map[*playerImpl]struct{}{}, - inited: make(chan struct{}), semaphore: make(chan struct{}, 1), } theContext = c @@ -128,10 +122,6 @@ func NewContext(sampleRate int) *Context { }) h.AppendHookOnBeforeUpdate(func() error { - c.initedOnce.Do(func() { - close(c.inited) - }) - var err error theContextLock.Lock() if theContext != nil { @@ -316,18 +306,6 @@ func (c *Context) SampleRate() int { return c.sampleRate } -func (c *Context) acquireSemaphore() { - c.semaphore <- struct{}{} -} - -func (c *Context) releaseSemaphore() { - <-c.semaphore -} - -func (c *Context) waitUntilInited() { - <-c.inited -} - // Player is an audio player which has one stream. // // Even when all references to a Player object is gone, diff --git a/audio/context.go b/audio/context.go index 85f744c25..37002b102 100644 --- a/audio/context.go +++ b/audio/context.go @@ -30,20 +30,12 @@ func newContext(sampleRate int) (context, chan struct{}, error) { return &contextProxy{ctx}, ready, err } -// otoContext is an interface for *oto.Context. -type otoContext interface { - NewPlayer(io.Reader) *oto.Player - Suspend() error - Resume() error - Err() error -} - // contextProxy is a proxy between otoContext and context. type contextProxy struct { - otoContext + *oto.Context } // NewPlayer implements context. func (c *contextProxy) NewPlayer(r io.Reader) player { - return c.otoContext.NewPlayer(r) + return c.Context.NewPlayer(r) }