From 6eac1f9c4c9bec13deade8ca77f1b06e066f7649 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 22 Jan 2004 20:51:08 +0000 Subject: [PATCH] sys/oss/gstosselement.c: Fix the ossmixer case where we shouldn't open /dev/dsp* because it might block operations (w... Original commit message from CVS: 2004-01-22 Ronald Bultje * sys/oss/gstosselement.c: (gst_osselement_class_probe_devices): Fix the ossmixer case where we shouldn't open /dev/dsp* because it might block operations (which is bad for a mixer). --- ChangeLog | 6 ++++++ sys/oss/gstosselement.c | 22 ++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f8f8165f1..74f65a159e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-01-22 Ronald Bultje + + * sys/oss/gstosselement.c: (gst_osselement_class_probe_devices): + Fix the ossmixer case where we shouldn't open /dev/dsp* because + it might block operations (which is bad for a mixer). + 2004-01-22 Thomas Vander Stichele * gst-libs/gst/media-info/media-info-priv.c: (have_type_callback), diff --git a/sys/oss/gstosselement.c b/sys/oss/gstosselement.c index 1ed365424f..1219cc4f72 100644 --- a/sys/oss/gstosselement.c +++ b/sys/oss/gstosselement.c @@ -207,8 +207,24 @@ static gboolean gst_osselement_class_probe_devices (GstOssElementClass *klass, gboolean check) { + GstElementClass *eklass = GST_ELEMENT_CLASS (klass); static gboolean init = FALSE; static GList *device_combinations; + GList *padtempllist; + gint openmode = O_RDONLY; + gboolean mixer = FALSE; + + /* Ok, so how do we open the device? We assume that we have (max.) one + * pad, and if this is a sinkpad, we're osssink (w). else, we're osssrc + * (r) */ + padtempllist = gst_element_class_get_pad_template_list (eklass); + if (padtempllist != NULL) { + GstPadTemplate *firstpadtempl = padtempllist->data; + if (GST_PAD_TEMPLATE_DIRECTION (firstpadtempl) == GST_PAD_SINK) { + openmode = O_WRONLY; + } + mixer = TRUE; + } if (!init && !check) { gchar *dsp_base[] = { "/dev/dsp", "/dev/sound/dsp", NULL }; @@ -249,8 +265,10 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass, continue; /* we just check the dsp. we assume the mixer always works. - * we don't need a mixer anyway (says OSS)... */ - if ((fd = open (devices[n].dsp, O_RDONLY)) > 0 || errno == EBUSY) { + * we don't need a mixer anyway (says OSS)... If we are a + * mixer element, we use the mixer anyway. */ + if ((fd = open (mixer ? devices[n].mixer : + devices[n].dsp, openmode)) > 0 || errno == EBUSY) { GstOssDeviceCombination *combi; if (fd > 0)