the 'OSS hangs when opening the device when in use' bug.

Original commit message from CVS:
Applied the patch from Sepp Wijnands <mrrazz@garbage-coderz.net> that solves
the 'OSS hangs when opening the device when in use' bug.
This commit is contained in:
Sepp Wijnands 2001-01-21 00:57:50 +00:00 committed by Wim Taymans
parent c824d8eaf9
commit 8c54486378
2 changed files with 36 additions and 18 deletions

View file

@ -27,6 +27,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/soundcard.h> #include <sys/soundcard.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
//#define DEBUG_ENABLED //#define DEBUG_ENABLED
@ -354,6 +355,14 @@ gst_audiosink_open_audio (GstAudioSink *sink)
g_print ("audiosink: attempting to open sound device\n"); g_print ("audiosink: attempting to open sound device\n");
/* first try to open the sound card */ /* first try to open the sound card */
sink->fd = open("/dev/dsp", O_WRONLY | O_NONBLOCK);
if (errno == EBUSY) {
g_print ("audiosink: unable to open the sound device (in use ?)\n");
return FALSE;
}
/* re-open the sound device in blocking mode */
close(sink->fd);
sink->fd = open("/dev/dsp", O_WRONLY); sink->fd = open("/dev/dsp", O_WRONLY);
/* if we have it, set the default parameters and go have fun */ /* if we have it, set the default parameters and go have fun */

View file

@ -27,6 +27,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/soundcard.h> #include <sys/soundcard.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
//#define DEBUG_ENABLED //#define DEBUG_ENABLED
@ -354,6 +355,14 @@ gst_audiosink_open_audio (GstAudioSink *sink)
g_print ("audiosink: attempting to open sound device\n"); g_print ("audiosink: attempting to open sound device\n");
/* first try to open the sound card */ /* first try to open the sound card */
sink->fd = open("/dev/dsp", O_WRONLY | O_NONBLOCK);
if (errno == EBUSY) {
g_print ("audiosink: unable to open the sound device (in use ?)\n");
return FALSE;
}
/* re-open the sound device in blocking mode */
close(sink->fd);
sink->fd = open("/dev/dsp", O_WRONLY); sink->fd = open("/dev/dsp", O_WRONLY);
/* if we have it, set the default parameters and go have fun */ /* if we have it, set the default parameters and go have fun */