[gst-devel] vcdsrc patch

Joshua N Pritikin vishnu at pobox.com
Fri May 10 09:26:02 CEST 2002


On Fri, May 10, 2002 at 09:19:18PM +0530, Joshua N Pritikin wrote:
> The attached patch:
> 
> * Allows vcdsrc to read arbitrarily scratched VCDs.  It adds a "max-errors"
> parameters that can be increased beyond the default of 16.
> 
> * Make vcdsrc return an EOS event instead of exit(1).
> 
> Does this apply cleanly to CVS?  My patch is against 0.3.1.

The attached patch additionally:

* checks errno for EIO

* returns zero-filled sectors instead of skipping to the next sector.
i'm not sure if this is the best way to recover.

-- 
Victory to the Divine Mother!!         after all,
  http://sahajayoga.org                  http://why-compete.org
-------------- next part --------------
# This is a patch for gst-plugins-0.3.1 to update it to gst-plugins-0.3.1
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####

#### Patch data follows ####
diff -up '/tmp/mp12620.d/old/gst-plugins-0.3.1/sys/vcd/vcdsrc.c' 'gst-plugins-0.3.1/sys/vcd/vcdsrc.c'
Index: ./sys/vcd/vcdsrc.c
--- ./sys/vcd/vcdsrc.c	Sat Dec 29 01:54:41 2001
+++ ./sys/vcd/vcdsrc.c	Fri May 10 21:47:01 2002
@@ -56,6 +56,7 @@ enum {
   ARG_TRACK,
   ARG_BYTESPERREAD,
   ARG_OFFSET,
+  ARG_MAX_ERRORS,
 };
 
 static void			vcdsrc_class_init	(VCDSrcClass *klass);
@@ -117,6 +118,8 @@ vcdsrc_class_init (VCDSrcClass *klass)
   g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_OFFSET,
     g_param_spec_int("offset","offset","offset",
                      G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */
+  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MAX_ERRORS,
+    g_param_spec_int("max-errors","","", 0,G_MAXINT,16,G_PARAM_READWRITE));
 
   gobject_class->set_property = vcdsrc_set_property;
   gobject_class->get_property = vcdsrc_get_property;
@@ -139,6 +142,7 @@ vcdsrc_init (VCDSrc *vcdsrc)
   vcdsrc->curoffset = 0;
   vcdsrc->bytes_per_read = VCD_BYTES_PER_SECTOR;
   vcdsrc->seq = 0;
+  vcdsrc->max_errors = 16;
 }
 
 
@@ -174,6 +178,9 @@ vcdsrc_set_property (GObject *object, gu
     case ARG_OFFSET:
       src->curoffset = g_value_get_int (value) / VCD_BYTES_PER_SECTOR;
       break;
+    case ARG_MAX_ERRORS:
+      src->max_errors = g_value_get_int (value);
+      break;
     default:
       break;
   }
@@ -202,6 +209,9 @@ vcdsrc_get_property (GObject *object, gu
     case ARG_OFFSET:
       g_value_set_int (value, src->curoffset * VCD_BYTES_PER_SECTOR);
       break;
+    case ARG_MAX_ERRORS:
+      g_value_set_int (value, src->max_errors);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -249,17 +259,19 @@ vcdsrc_get (GstPad *pad)
   /* msf->cdmsf_frame0); */
 
   if (ioctl(vcdsrc->fd,CDROMREADRAW,msf)) {
-    if (++error_count > 16)
-      {
-	fprintf (stderr, "End of CD\n");
-	exit(1);
-      }
+    if (errno != EIO ||
+	(errno == EIO && ++error_count > vcdsrc->max_errors)) {
+      gst_element_set_eos (GST_ELEMENT (vcdsrc));
+      return GST_BUFFER (gst_event_new (GST_EVENT_EOS));
+    }
 
     fprintf (stderr, "%s while reading raw data from cdrom at %d:%d:%d\n",
 	     strerror (errno),
 	     msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
+    /*
     vcdsrc->curoffset += 1;
     goto read_sector;
+    */
   }
 
 
diff -up '/tmp/mp12620.d/old/gst-plugins-0.3.1/sys/vcd/vcdsrc.h' 'gst-plugins-0.3.1/sys/vcd/vcdsrc.h'
Index: ./sys/vcd/vcdsrc.h
--- ./sys/vcd/vcdsrc.h	Fri Dec 21 01:55:24 2001
+++ ./sys/vcd/vcdsrc.h	Fri May 10 20:49:28 2002
@@ -80,6 +80,7 @@ struct _VCDSrc {
   gulong bytes_per_read;		/* bytes per read */
 
   gulong seq;				/* buffer sequence number */
+  int max_errors;
 };
 
 struct _VCDSrcClass {
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Fri May 10 21:52:55 2002
# Generated by        : makepatch 2.00_03
# Recurse directories : Yes
# p 'sys/vcd/vcdsrc.c' 11159 1021047421 0100644
# p 'sys/vcd/vcdsrc.h' 2303 1021043968 0100644
#### End of ApplyPatch data ####

#### End of Patch kit [created: Fri May 10 21:52:55 2002] ####
#### Patch checksum: 99 3211 43373 ####
#### Checksum: 117 3906 35452 ####


More information about the gstreamer-devel mailing list