Hello Stk-users/devs,<br><br>I've been working on fixing STK's alsa backend so that RtApiAlsa doesn't hog the sound device it's using (i.e. other programs can use it at the same time). I've been doing the work on github, in an appropriately-named "fix_alsa" branch:<br>
<br><a href="https://github.com/tmatth/stk/tree/fix_alsa">https://github.com/tmatth/stk/tree/fix_alsa</a><br><br>There are two things that had to be changed:<br>1) snd_pcm_open needed to be called with the SND_PCM_NONBLOCK flag, not the SND_PCM_ASYNC flag. The SND_PCM_ASYNC flag just causes SIGIO to be emitted every period (which wasn't getting handled anywhere). Furthermore, when writing to the device in NONBLOCK mode, you have to wait on the device before writing to it (with snd_pcm_wait).<br>
2) The interface to use by default should be "default", not "hw:0". This is because using the hw:0 interface name means ALSA will try to open it for exclusive use. The device pointed to by "default" can be changed in one's .asoundrc file.<br>
<br>The second point is a bit trickier, because RtAudio by default expects to be able to enumerate the devices by number. ALSA is expecting devices to be specified by name rather than number, that's why defaulting the first device is not great behaviour. In my branch, currently I set the device name to "default" unless the user has specified the HOG_DEVICE flag in their stream parameters, in which case it will grab the interface corresponding to the integer deviceID. I discussed this a bit off-list with Stephen Sinclair, but wanted more feedback since it seems like a poor solution.<br>
<br>Best,<br>Tristan<br><br clear="all"><br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com">http://tristanswork.blogspot.com</a><br>