sys/oss/gstosssrc.*: Cache probed caps, so _get_caps() during recording doesn't cause...
authorMark Nauwelaerts <manauw@skynet.be>
Tue, 11 Mar 2008 23:12:04 +0000 (23:12 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Tue, 11 Mar 2008 23:12:04 +0000 (23:12 +0000)
Original commit message from CVS:
Patch by: Mark Nauwelaerts <manauw skynet be>
* sys/oss/gstosssrc.c: (gst_oss_src_init), (gst_oss_src_getcaps),
(gst_oss_src_close):
* sys/oss/gstosssrc.h:
Cache probed caps, so _get_caps() during recording doesn't cause
ioctl calls which may disrupt the recording (fixes #521875).

ChangeLog
sys/oss/gstosssrc.c
sys/oss/gstosssrc.h

index 844ae75..35994e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-11  Tim-Philipp Müller  <tim at centricular dot net>
+
+       Patch by: Mark Nauwelaerts <manauw skynet be>
+
+       * sys/oss/gstosssrc.c: (gst_oss_src_init), (gst_oss_src_getcaps),
+         (gst_oss_src_close):
+       * sys/oss/gstosssrc.h:
+         Cache probed caps, so _get_caps() during recording doesn't cause
+         ioctl calls which may disrupt the recording (fixes #521875).
+
 2008-03-11  Wim Taymans  <wim.taymans@collabora.co.uk>
 
        * gst/qtdemux/qtdemux.c: (gst_qtdemux_perform_seek),
index 36aa92d..417bdcf 100644 (file)
@@ -243,6 +243,7 @@ gst_oss_src_init (GstOssSrc * osssrc, GstOssSrcClass * g_class)
   osssrc->fd = -1;
   osssrc->device = g_strdup (device);
   osssrc->device_name = g_strdup (DEFAULT_DEVICE_NAME);
+  osssrc->probed_caps = NULL;
 }
 
 static void
@@ -263,12 +264,23 @@ gst_oss_src_getcaps (GstBaseSrc * bsrc)
   osssrc = GST_OSS_SRC (bsrc);
 
   if (osssrc->fd == -1) {
-    caps = gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
-            (bsrc)));
-  } else {
-    caps = gst_oss_helper_probe_caps (osssrc->fd);
+    GST_DEBUG_OBJECT (osssrc, "device not open, using template caps");
+    return NULL;                /* base class will get template caps for us */
   }
 
+  if (osssrc->probed_caps) {
+    GST_LOG_OBJECT (osssrc, "Returning cached caps");
+    return gst_caps_ref (osssrc->probed_caps);
+  }
+
+  caps = gst_oss_helper_probe_caps (osssrc->fd);
+
+  if (caps) {
+    osssrc->probed_caps = gst_caps_ref (caps);
+  }
+
+  GST_INFO_OBJECT (osssrc, "returning caps %" GST_PTR_FORMAT, caps);
+
   return caps;
 }
 
@@ -395,6 +407,8 @@ gst_oss_src_close (GstAudioSrc * asrc)
     oss->mixer = NULL;
   }
 
+  gst_caps_replace (&oss->probed_caps, NULL);
+
   return TRUE;
 }
 
index 1766298..0d14613 100644 (file)
@@ -51,6 +51,8 @@ struct _GstOssSrc {
   gchar *device;
   gchar *device_name;
 
+  GstCaps       *probed_caps;
+
   GstOssMixer *mixer;
 };