mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-06-27 18:30:51 +00:00
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:
parent
c824d8eaf9
commit
8c54486378
|
@ -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
|
||||||
|
|
||||||
|
@ -346,14 +347,22 @@ gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audiosink_open_audio (GstAudioSink *sink)
|
gst_audiosink_open_audio (GstAudioSink *sink)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (sink->fd == -1, FALSE);
|
g_return_val_if_fail (sink->fd == -1, FALSE);
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -366,33 +375,33 @@ gst_audiosink_open_audio (GstAudioSink *sink)
|
||||||
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
||||||
|
|
||||||
g_print("audiosink: Capabilities\n");
|
g_print("audiosink: Capabilities\n");
|
||||||
|
|
||||||
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
||||||
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
||||||
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
||||||
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
||||||
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
||||||
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
||||||
|
|
||||||
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
||||||
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audiosink_close_audio (GstAudioSink *sink)
|
gst_audiosink_close_audio (GstAudioSink *sink)
|
||||||
{
|
{
|
||||||
if (sink->fd < 0) return;
|
if (sink->fd < 0) return;
|
||||||
|
|
||||||
close(sink->fd);
|
close(sink->fd);
|
||||||
sink->fd = -1;
|
sink->fd = -1;
|
||||||
|
|
||||||
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
||||||
|
|
||||||
g_print("audiosink: closed sound device\n");
|
g_print("audiosink: closed sound device\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -346,14 +347,22 @@ gst_audiosink_get_arg (GtkObject *object, GtkArg *arg, guint id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_audiosink_open_audio (GstAudioSink *sink)
|
gst_audiosink_open_audio (GstAudioSink *sink)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (sink->fd == -1, FALSE);
|
g_return_val_if_fail (sink->fd == -1, FALSE);
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -366,33 +375,33 @@ gst_audiosink_open_audio (GstAudioSink *sink)
|
||||||
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
ioctl(sink->fd, SNDCTL_DSP_GETCAPS, &sink->caps);
|
||||||
|
|
||||||
g_print("audiosink: Capabilities\n");
|
g_print("audiosink: Capabilities\n");
|
||||||
|
|
||||||
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
if (sink->caps & DSP_CAP_DUPLEX) g_print("audiosink: Full duplex\n");
|
||||||
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
if (sink->caps & DSP_CAP_REALTIME) g_print("audiosink: Realtime\n");
|
||||||
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
if (sink->caps & DSP_CAP_BATCH) g_print("audiosink: Batch\n");
|
||||||
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
if (sink->caps & DSP_CAP_COPROC) g_print("audiosink: Has coprocessor\n");
|
||||||
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
if (sink->caps & DSP_CAP_TRIGGER) g_print("audiosink: Trigger\n");
|
||||||
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
if (sink->caps & DSP_CAP_MMAP) g_print("audiosink: Direct access\n");
|
||||||
|
|
||||||
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
g_print("audiosink: opened audio with fd=%d\n", sink->fd);
|
||||||
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
GST_FLAG_SET (sink, GST_AUDIOSINK_OPEN);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audiosink_close_audio (GstAudioSink *sink)
|
gst_audiosink_close_audio (GstAudioSink *sink)
|
||||||
{
|
{
|
||||||
if (sink->fd < 0) return;
|
if (sink->fd < 0) return;
|
||||||
|
|
||||||
close(sink->fd);
|
close(sink->fd);
|
||||||
sink->fd = -1;
|
sink->fd = -1;
|
||||||
|
|
||||||
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
GST_FLAG_UNSET (sink, GST_AUDIOSINK_OPEN);
|
||||||
|
|
||||||
g_print("audiosink: closed sound device\n");
|
g_print("audiosink: closed sound device\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue