/dev/dsp - dup and open_count
Sat Jun 12 16:50:00 GMT 2004
After some experiments with two cygwin shells, on my Win2000
machine with cygwin 1.5.10-3, I found that
two processes actually can write to /dev/dsp simultaneously,
so a single process should be able to open two instances, too.
So for writes to /dev/dsp, open_count is not needed at all.
However, for reading from /dev/dsp, if the wave device is already in use,
an error is returned by the win32 call and passed on as EIO - I/O Error. Currently this occurs not yet in open(), but in the first read().
I decided to open the wave device late - not in the open() to
/dev/dsp but in the read() - to make applications that use
fork() work properly.
My conclusions are:
1. The windows wave device should decide if it can handle another open
or not. So we should get rid of open_count and query the device instead.
In this case, every open file descriptor has its own audio pointers,
audio buffers, wave device handles etc.
2. At least on my machine, the second open for reading from /dev/dsp
should fail, because the hardware does not support it.
3. dup is different from a second open. It creates a second instance,
but it should use the same buffers and wave device handles.
dup() should thus work for both reading and writing. Maybe,
a dup_count variable is the way to go forward.
More information about the Cygwin-developers