/dev/dspの多重オープン
やはり、Cygwinでは/dev/dspの多重オープンができないようです。
これは次のコードでも確認できます。
#include <cassert> #include <fcntl.h> int main() { assert(::open("/dev/dsp", O_RDONLY) != -1); assert(::open("/dev/dsp", O_WRONLY) != -1); }
Cygwinのソースコードを覗いてみると、fhandler_dsp.ccに次の記述を見つけました。
Implementation Notes
2. Every open call creates a new instance of the handler. After a
successful open, every subsequent open from the same process
to the device fails with EBUSY.
そういうものだと、諦めるしかないようです。テストではpcm_sinkの代わりにnull_sinkに書き込むことにします。
なお、BOOST_WINDOWSを定義してコンパイルした場合は、WindowsのWaveform Audioを直接使用するので、この問題は起きません。