alsa icon indicating copy to clipboard operation
alsa copied to clipboard

Open() blocking forever

Open diamondburned opened this issue 5 years ago • 2 comments

The issue

In https://github.com/yobert/alsa/blob/master/device.go#L107, the os.OpenFile call does not have a syscall.O_NONBLOCK flag. I suspect this is causing the beep example on my pure ALSA setup to block. (I've tested and nailed it down to the Open() method). This does not happen with PulseAudio.

Proposal:

Add syscall.O_NONBLOCK like so:

device.fh, err = os.OpenFile(device.Path, os.O_RDWR | syscall.O_NONBLOCK, 0755)

diamondburned avatar Jun 10 '19 14:06 diamondburned

Ah! Yeah! Good idea. Though we might need to expose the behavior as an argument to the function, because from what I'm reading this might have a lot to do with which driver your sound card uses. Some of them only support one thing using it at a time, which means the blocking behavior might be more correct (at least in the POSIX-ey sense.)

yobert avatar Aug 27 '20 17:08 yobert

It does seem pedantic though to block until the sound becomes free. I wouldn't really want some queued up HONK to happen after stopping my music player.

yobert avatar Sep 01 '20 20:09 yobert