Skip to content

Commit

Permalink
openal: Use dummyDriver when no sound driver is found
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Jun 19, 2019
1 parent 3b9e94d commit 5407e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions driver_openal.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ func alFormat(channelNum, bitDepthInBytes int) C.ALenum {

const numBufs = 2

func newDriver(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes int) (*driver, error) {
func newDriver(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes int) (tryWriteCloser, error) {
name := C.alGetString(C.ALC_DEFAULT_DEVICE_SPECIFIER)
d := alDevice(C._alcOpenDevice((*C.ALCchar)(name)))
if d == 0 {
return nil, fmt.Errorf("oto: alcOpenDevice must not return null")
// No device was found. Return the dummy device (#77).
// TODO: Retry to open the device when possible.
return newDummyDriver(sampleRate, channelNum, bitDepthInBytes), nil
}
c := alContext(C._alcCreateContext(C.uintptr_t(d), nil))
if c == 0 {
Expand Down
2 changes: 1 addition & 1 deletion driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func newDriver(sampleRate, channelNum, bitDepthInBytes, bufferSizeInBytes int) (
w, err := waveOutOpen(f)
const elementNotFound = 1168
if e, ok := err.(*winmmError); ok && e.errno == elementNotFound {
// No device was found. Return the dummy device.
// No device was found. Return the dummy device (#77).
// TODO: Retry to open the device when possible.
return newDummyDriver(sampleRate, channelNum, bitDepthInBytes), nil
}
Expand Down

0 comments on commit 5407e1c

Please sign in to comment.