Subject: patch for busy /dev/dsp
From: Robert Story (rstory-l@revelstone.com)
Date: Mon Jul 09 2001 - 23:14:11 MDT
I've had problems recently with MOL starting without sound. So I tracked it down to the open, which was failing with EBUSY. Since sound is REALLY important to me, I put in a retry loop and an exit. Probably the exit should be conditional based on /etc/molrc, but I was to lazy to add that. :)
Anyways, here is a patch to osi_sound.c:
diff -u -r -b -w -p --exclude-from=/home/rks/.diff-ignore --new-file mol-rsync/drivers/osi_sound.c mol-rstory/drivers/osi_sound.c
--- mol-rsync/drivers/osi_sound.c Thu Jun 28 11:47:14 2001
+++ mol-rstory/drivers/osi_sound.c Mon Jul 9 19:25:12 2001
@@ -102,6 +102,7 @@ static int
osi_sound_init( void )
{
int newsync;
+ int retries;
memset( &ss, 0, sizeof(ss) );
ss->fd = -1;
@@ -134,14 +135,19 @@ osi_sound_init( void )
/* We must open the sound device without blocking.
* Using fcntl to change the nonblock flag doesn't work (driver bug?)
*/
+ for( retries = 3; retries; --retries ) {
if( (ss->fd = open( "/dev/dsp", O_WRONLY | O_NONBLOCK )) != -1 ) {
close( ss->fd );
ss->fd = open( "/dev/dsp", O_WRONLY );
}
+ if( ( ss->fd != -1 ) || ( errno != EBUSY ) )
+ break;
+ sleep(1);
+ }
if( ss->fd < 0 ){
- printm("----> Failed to open /dev/dsp - Sound Disabled\n");
- return 1;
+ printm("----> Failed to open /dev/dsp (errno %d) - Sound Disabled\n", errno);
+ exit(1);
}
if( get_bool_res("play_startboing") )
This archive was generated by hypermail 2a24 : Mon Jul 09 2001 - 22:18:39 MDT