summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorChristian Schaller <uraeus@gnome.org>2003-01-12 11:43:46 +0000
committerChristian Schaller <uraeus@gnome.org>2003-01-12 11:43:46 +0000
commite250f197a57c5ca7256d0fdac07a91aeddf50ad4 (patch)
treed2790f63c9a021e2898b5340c0b62ce87dd3cd36 /sys
parent1bcd623c76a6011da4d50d90a5555236a0ffef35 (diff)
Applied patch from Martin Schlemmer for locking issue, see bug http://bugzilla.gnome.org/show_bug.cgi?id=102025
Original commit message from CVS: Applied patch from Martin Schlemmer for locking issue, see bug http://bugzilla.gnome.org/show_bug.cgi?id=102025
Diffstat (limited to 'sys')
-rw-r--r--sys/oss/gstosscommon.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/oss/gstosscommon.c b/sys/oss/gstosscommon.c
index 65c8a780..255ac6a0 100644
--- a/sys/oss/gstosscommon.c
+++ b/sys/oss/gstosscommon.c
@@ -281,9 +281,23 @@ gst_osscommon_open_audio (GstOssCommon *common, GstOssOpenMode mode, gchar **err
GST_INFO (GST_CAT_PLUGIN_INFO, "common: attempting to open sound device");
/* first try to open the sound card */
- /* FIXME: this code is dubious, why do we need to open and close this ?*/
+ /* FIXME: This code is dubious, why do we need to open and close this ?
+ * For linux at least this causes the second open to never return
+ * if the device was already in use .. */
+#ifndef __linux__
if (mode == GST_OSSCOMMON_WRITE) {
+#endif
common->fd = open (common->device, O_WRONLY | O_NONBLOCK);
+#ifdef __linux__
+ if (common->fd >= 0) {
+ /* remove the non-blocking flag */
+ if(fcntl (common->fd, F_SETFL, 0) < 0) {
+ *error = g_strdup_printf ("osscommon: Can't make filedescriptor blocking for %s",
+ common->device);
+ return FALSE;
+ }
+ }
+#else
if (errno == EBUSY) {
g_warning ("osscommon: unable to open the sound device (in use ?)\n");
}
@@ -297,9 +311,14 @@ gst_osscommon_open_audio (GstOssCommon *common, GstOssOpenMode mode, gchar **err
else {
common->fd = open (common->device, O_RDONLY);
}
+#endif
if (common->fd < 0) {
switch (errno) {
+ case EBUSY:
+ *error = g_strdup_printf ("osscommon: Unable to open %s (in use ?)",
+ common->device);
+ break;
case EISDIR:
*error = g_strdup_printf ("osscommon: Device %s is a directory",
common->device);