Hello,
Old games (I sometimes play UFO or DOOM2) under dosbox became silent.
Reason? SDL library wants a blocking `write` call to /dev/dsp.
Sounf thread looks like:
 while(enabled) {
        err = write(dsp_fd, audio_buf, buf_len);
        if (err <=0) {
                enabled = 0;
        }
 }

So EAGAIN in non-blocking write leads to silence.
/dev/dsp device is opened like:

dsp_fd = open("/dev/dsp", O_WRONLY|O_NONBLOCK);
if (dsp_fd < 0) return(-1);

flags = fcntl(dsp_fd, F_GETFL);
flags &= ~O_NONBLOCK;

if ( fcntl(dsp_fd, F_SETFL, flags) < 0 ) {
    SDL_SetError("Couldn't set audio blocking mode");
    DSP_CloseAudio(this);
    return(-1);
}

Unfortunely fcntl() changes some internal flags while 'wrch->flags' remains 
unchanged so we still have non-blocking mode.

Then I discovered dsp_ioctl(struct dev_ioctl_args *ap) function at 
sys/dev/sound/pcm/dsp.c:1092 with SNDCTL_DSP_NONBLOCK and FIONBIO ioctls 
(sys/dev/sound/pcm/dsp.c:1365).
SNDCTL_DSP_NONBLOCK only sets non-blocking io.
And FIONBIO... well this line will never get control: 
FIONBIO is intercepted somewhere in generic device code.

So what we have here...
There is no way to change blocking mode for /dev/dsp after opening :(

TBH I'm not sure that I read all the code correctly, may be there is a simple
solution?

P.S. Like ``Don't use SDL'' :)

-- 
  with best reagrds, Yellow Rabbit
  DragonFly 4.1-DEVELOPMENT x86_64

Reply via email to