Index: gst-plugins//ChangeLog
===================================================================
RCS file: /export/cvs/head/gstreamer/gst-plugins/ChangeLog,v
retrieving revision 1.1373
diff -p -u -5 -r1.1373 ChangeLog
--- gst-plugins//ChangeLog	2004/12/09 15:57:39	1.1373
+++ gst-plugins//ChangeLog	2004/12/10 13:56:52
@@ -1,5 +1,12 @@
+2004-12-09  Archana Shah  <archana.shah@wipro.com>
+	* sys/oss/gstosselement.c: (gst_osselement_open_audio):
+	  If /dev/dsp is being used by another application, keep trying to get
+	  the device. If do not get, throw up the error dialog after 5 seconds and 
+	  return appropriate error.
+	  Fixes bug#160340
+
 2004-12-09  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
 	* ext/ogg/gstoggdemux.c: (get_relative):
 	  Check for non-NULL before accessing member (end-of-chain).
 
Index: gst-plugins//sys/oss/gstosselement.c
===================================================================
RCS file: /export/cvs/head/gstreamer/gst-plugins/sys/oss/gstosselement.c,v
retrieving revision 1.44
diff -p -u -5 -r1.44 gstosselement.c
--- gst-plugins//sys/oss/gstosselement.c	2004/11/01 14:43:38	1.44
+++ gst-plugins//sys/oss/gstosselement.c	2004/12/10 13:56:52
@@ -683,10 +683,11 @@ static gboolean
 gst_osselement_open_audio (GstOssElement * oss)
 {
   gint caps;
   GstOssOpenMode mode = GST_OSSELEMENT_READ;
   const GList *padlist;
+  GTimer *timer = NULL;
 
   g_return_val_if_fail (oss->fd == -1, FALSE);
   GST_INFO ("osselement: attempting to open sound device");
 
   /* Ok, so how do we open the device? We assume that we have (max.) one
@@ -700,10 +701,11 @@ gst_osselement_open_audio (GstOssElement
     }
   } else {
     goto do_mixer;
   }
 
+try_again:
   /* first try to open the sound card */
   if (mode == GST_OSSELEMENT_WRITE) {
     /* open non blocking first so that it returns immediatly with an error
      * when we cannot get to the device */
     oss->fd = open (oss->device, O_WRONLY | O_NONBLOCK);
@@ -719,10 +721,19 @@ gst_osselement_open_audio (GstOssElement
   }
 
   if (oss->fd < 0) {
     switch (errno) {
       case EBUSY:
+        if (!timer) {
+          timer = g_timer_new ();
+          g_timer_start (timer);
+        }
+        /* We will keep trying to get the device.
+         * Wait for 5 seconds before giving up */
+        while (g_timer_elapsed (timer, NULL) <= 5)
+          goto try_again;
+
         GST_ELEMENT_ERROR (oss, RESOURCE, BUSY,
             (_("OSS device \"%s\" is already in use by another program."),
                 oss->device), (NULL));
         break;
       case EACCES:
@@ -753,10 +764,16 @@ gst_osselement_open_audio (GstOssElement
           GST_ELEMENT_ERROR (oss, RESOURCE, OPEN_READ,
               (_("Could not open device \"%s\" for reading."), oss->device),
               GST_ERROR_SYSTEM);
         break;
     }
+
+    if (timer) {
+      g_timer_stop (timer);
+      g_timer_destroy (timer);
+    }
+
     return FALSE;
   }
 
   oss->mode = mode;
 
@@ -819,10 +836,14 @@ gst_osselement_open_audio (GstOssElement
 
   GST_INFO ("osselement: opened audio (%s) with fd=%d", oss->device, oss->fd);
 
   oss->caps = caps;
 
+  if (timer) {
+    g_timer_stop (timer);
+    g_timer_destroy (timer);
+  }
 do_mixer:
   gst_ossmixer_build_list (oss);
 
   return TRUE;
 }
