Skip to content

Commit a3a27d0

Browse files
committed
windows: bug fix: error when no audio device is found w/ WinMM
Updates hajimehoshi/ebiten#2318
1 parent 4fabdd8 commit a3a27d0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

driver_winmm_windows.go

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"errors"
1919
"fmt"
2020
"sync"
21+
"time"
2122
"unsafe"
2223

2324
"golang.org/x/sys/windows"
@@ -323,6 +324,10 @@ func (c *winmmContext) appendBuffers() {
323324
switch {
324325
case errors.Is(err, _MMSYSERR_NOMEM):
325326
continue
327+
case errors.Is(err, _MMSYSERR_NODRIVER):
328+
sleep := time.Duration(float64(time.Second) * float64(len(c.buf32)) / float64(c.channelCount) / float64(c.sampleRate))
329+
time.Sleep(sleep)
330+
return
326331
case errors.Is(err, windows.ERROR_NOT_FOUND):
327332
// This error can happen when e.g. a new HDMI connection is detected (#51).
328333
// TODO: Retry later.

0 commit comments

Comments
 (0)