diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /sys/vcd | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'sys/vcd')
-rw-r--r-- | sys/vcd/vcdsrc.c | 242 | ||||
-rw-r--r-- | sys/vcd/vcdsrc.h | 74 |
2 files changed, 157 insertions, 159 deletions
diff --git a/sys/vcd/vcdsrc.c b/sys/vcd/vcdsrc.c index 0824e679..b2868628 100644 --- a/sys/vcd/vcdsrc.c +++ b/sys/vcd/vcdsrc.c @@ -37,21 +37,21 @@ #include <vcdsrc.h> -static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS ( - "VCD Source", - "Source/File", - "Asynchronous read from VCD disk", - "Erik Walthinsen <omega@cse.ogi.edu>" -); +static GstElementDetails vcdsrc_details = GST_ELEMENT_DETAILS ("VCD Source", + "Source/File", + "Asynchronous read from VCD disk", + "Erik Walthinsen <omega@cse.ogi.edu>"); /* VCDSrc signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATION, ARG_TRACK, @@ -60,20 +60,24 @@ enum { ARG_MAX_ERRORS, }; -static void vcdsrc_base_init (gpointer g_class); -static void vcdsrc_class_init (VCDSrcClass *klass); -static void vcdsrc_init (VCDSrc *vcdsrc); -static void vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void vcdsrc_base_init (gpointer g_class); +static void vcdsrc_class_init (VCDSrcClass * klass); +static void vcdsrc_init (VCDSrc * vcdsrc); +static void vcdsrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void vcdsrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstData *vcdsrc_get (GstPad * pad); -static GstData * vcdsrc_get (GstPad *pad); /*static GstBuffer * vcdsrc_get_region (GstPad *pad,gulong offset,gulong size); */ -static GstElementStateReturn vcdsrc_change_state (GstElement *element); +static GstElementStateReturn vcdsrc_change_state (GstElement * element); -static void vcdsrc_recalculate(VCDSrc *vcdsrc); +static void vcdsrc_recalculate (VCDSrc * vcdsrc); static GstElementClass *parent_class = NULL; + /*static guint vcdsrc_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -83,17 +87,18 @@ vcdsrc_get_type (void) if (!vcdsrc_type) { static const GTypeInfo vcdsrc_info = { - sizeof(VCDSrcClass), + sizeof (VCDSrcClass), vcdsrc_base_init, NULL, - (GClassInitFunc)vcdsrc_class_init, + (GClassInitFunc) vcdsrc_class_init, NULL, NULL, - sizeof(VCDSrc), + sizeof (VCDSrc), 0, - (GInstanceInitFunc)vcdsrc_init, + (GInstanceInitFunc) vcdsrc_init, }; - vcdsrc_type = g_type_register_static(GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0); + vcdsrc_type = + g_type_register_static (GST_TYPE_ELEMENT, "VCDSrc", &vcdsrc_info, 0); } return vcdsrc_type; } @@ -102,34 +107,27 @@ static void vcdsrc_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (element_class, &vcdsrc_details); } static void -vcdsrc_class_init (VCDSrcClass *klass) +vcdsrc_class_init (VCDSrcClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_peek_parent (klass); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATION, - g_param_spec_string("location","location","location", - NULL, G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_TRACK, - g_param_spec_int("track","track","track", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_BYTESPERREAD, - g_param_spec_int("bytesperread","bytesperread","bytesperread", - G_MININT,G_MAXINT,0,G_PARAM_READABLE)); /* CHECKME */ - 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)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, g_param_spec_string ("location", "location", "location", NULL, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TRACK, g_param_spec_int ("track", "track", "track", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTESPERREAD, g_param_spec_int ("bytesperread", "bytesperread", "bytesperread", G_MININT, G_MAXINT, 0, G_PARAM_READABLE)); /* CHECKME */ + 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; @@ -138,12 +136,12 @@ vcdsrc_class_init (VCDSrcClass *klass) } static void -vcdsrc_init (VCDSrc *vcdsrc) +vcdsrc_init (VCDSrc * vcdsrc) { - vcdsrc->srcpad = gst_pad_new("src",GST_PAD_SRC); + vcdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (vcdsrc->srcpad, vcdsrc_get); /* gst_pad_set_get_region_function (vcdsrc->srcpad, vcdsrc_getregion); */ - gst_element_add_pad(GST_ELEMENT(vcdsrc),vcdsrc->srcpad); + gst_element_add_pad (GST_ELEMENT (vcdsrc), vcdsrc->srcpad); vcdsrc->device = g_strdup ("/dev/cdrom"); vcdsrc->track = 2; @@ -157,30 +155,32 @@ vcdsrc_init (VCDSrc *vcdsrc) static void -vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +vcdsrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { VCDSrc *src; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_VCDSRC(object)); - src = VCDSRC(object); + g_return_if_fail (GST_IS_VCDSRC (object)); + src = VCDSRC (object); switch (prop_id) { case ARG_LOCATION: /* the element must be stopped in order to do this */ /* g_return_if_fail(!GST_FLAG_IS_SET(src,GST_STATE_RUNNING)); */ - if (src->device) g_free(src->device); + if (src->device) + g_free (src->device); /* clear the filename if we get a NULL (is that possible?) */ if (g_value_get_string (value) == NULL) - src->device = NULL; + src->device = NULL; /* otherwise set the new filename */ else - src->device = g_strdup(g_value_get_string (value)); + src->device = g_strdup (g_value_get_string (value)); break; case ARG_TRACK: src->track = g_value_get_int (value); - vcdsrc_recalculate(src); + vcdsrc_recalculate (src); break; /* case ARG_BYTESPERREAD: src->bytes_per_read = g_value_get_int (value); @@ -198,13 +198,14 @@ vcdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParam } static void -vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +vcdsrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { VCDSrc *src; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_VCDSRC(object)); - src = VCDSRC(object); + g_return_if_fail (GST_IS_VCDSRC (object)); + src = VCDSRC (object); switch (prop_id) { case ARG_LOCATION: @@ -229,7 +230,7 @@ vcdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec * } static GstData * -vcdsrc_get (GstPad *pad) +vcdsrc_get (GstPad * pad) { VCDSrc *vcdsrc; GstBuffer *buf; @@ -239,25 +240,25 @@ vcdsrc_get (GstPad *pad) /* fprintf(stderr,"in vcdsrc_push\n"); */ - g_return_val_if_fail(pad != NULL, NULL); - g_return_val_if_fail(GST_IS_PAD(pad), NULL); + g_return_val_if_fail (pad != NULL, NULL); + g_return_val_if_fail (GST_IS_PAD (pad), NULL); vcdsrc = VCDSRC (GST_OBJECT_PARENT (pad)); g_return_val_if_fail (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN), NULL); /* create the buffer */ /* FIXME: should eventually use a bufferpool for this */ - buf = gst_buffer_new(); - g_return_val_if_fail(buf != NULL, NULL); + buf = gst_buffer_new (); + g_return_val_if_fail (buf != NULL, NULL); /* allocate the space for the buffer data */ - GST_BUFFER_DATA(buf) = g_malloc(vcdsrc->bytes_per_read); - memset(GST_BUFFER_DATA(buf),0,vcdsrc->bytes_per_read); - g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, NULL); + GST_BUFFER_DATA (buf) = g_malloc (vcdsrc->bytes_per_read); + memset (GST_BUFFER_DATA (buf), 0, vcdsrc->bytes_per_read); + g_return_val_if_fail (GST_BUFFER_DATA (buf) != NULL, NULL); - msf = (struct cdrom_msf *)GST_BUFFER_DATA(buf); + msf = (struct cdrom_msf *) GST_BUFFER_DATA (buf); - read_sector: +read_sector: /* read it in from the device */ offset = vcdsrc->trackoffset + vcdsrc->curoffset; @@ -268,16 +269,14 @@ vcdsrc_get (GstPad *pad) /*gst_info("msf is %d:%d:%d\n",msf->cdmsf_min0,msf->cdmsf_sec0, */ /* msf->cdmsf_frame0); */ - if (ioctl(vcdsrc->fd,CDROMREADRAW,msf)) { - if (++error_count > vcdsrc->max_errors) - { - gst_element_set_eos (GST_ELEMENT (vcdsrc)); - return GST_DATA (gst_event_new (GST_EVENT_EOS)); - } + if (ioctl (vcdsrc->fd, CDROMREADRAW, msf)) { + if (++error_count > vcdsrc->max_errors) { + gst_element_set_eos (GST_ELEMENT (vcdsrc)); + return GST_DATA (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); + strerror (errno), msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0); vcdsrc->curoffset += 1; /* Or we can return a zero-filled buffer. Which is better? */ @@ -285,8 +284,8 @@ vcdsrc_get (GstPad *pad) } - GST_BUFFER_OFFSET(buf) = vcdsrc->curoffset; - GST_BUFFER_SIZE(buf) = vcdsrc->bytes_per_read; + GST_BUFFER_OFFSET (buf) = vcdsrc->curoffset; + GST_BUFFER_SIZE (buf) = vcdsrc->bytes_per_read; vcdsrc->curoffset += 1; return GST_DATA (buf); @@ -294,22 +293,22 @@ vcdsrc_get (GstPad *pad) /* open the file, necessary to go to RUNNING state */ static gboolean -vcdsrc_open_file(VCDSrc *src) +vcdsrc_open_file (VCDSrc * src) { int i; - g_return_val_if_fail(!GST_FLAG_IS_SET(src,VCDSRC_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (src, VCDSRC_OPEN), FALSE); /* open the device */ - src->fd = open(src->device,O_RDONLY); + src->fd = open (src->device, O_RDONLY); if (src->fd < 0) { GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM); return FALSE; } /* read the table of contents */ - if (ioctl(src->fd,CDROMREADTOCHDR,&src->tochdr)) { - perror("reading toc of VCD\n"); + if (ioctl (src->fd, CDROMREADTOCHDR, &src->tochdr)) { + perror ("reading toc of VCD\n"); /* FIXME */ /* exit(1); */ } @@ -319,96 +318,91 @@ vcdsrc_open_file(VCDSrc *src) src->tracks = g_new (struct cdrom_tocentry, src->numtracks); /* read each track entry */ - for (i=0;i<src->numtracks;i++) { - src->tracks[i].cdte_track = i+1; + for (i = 0; i < src->numtracks; i++) { + src->tracks[i].cdte_track = i + 1; src->tracks[i].cdte_format = CDROM_MSF; - if (ioctl(src->fd,CDROMREADTOCENTRY, &src->tracks[i])) { - perror("reading tocentry"); + if (ioctl (src->fd, CDROMREADTOCENTRY, &src->tracks[i])) { + perror ("reading tocentry"); /* FIXME */ /* exit(1);*/ } - fprintf(stderr,"VCDSrc: track begins at %d:%d:%d\n", - src->tracks[i].cdte_addr.msf.minute, - src->tracks[i].cdte_addr.msf.second, - src->tracks[i].cdte_addr.msf.frame); + fprintf (stderr, "VCDSrc: track begins at %d:%d:%d\n", + src->tracks[i].cdte_addr.msf.minute, + src->tracks[i].cdte_addr.msf.second, + src->tracks[i].cdte_addr.msf.frame); } src->trackoffset = -(((src->tracks[src->track-1].cdte_addr.msf.minute * 60) + - src->tracks[src->track-1].cdte_addr.msf.second) * 75) + - src->tracks[src->track-1].cdte_addr.msf.frame; - fprintf(stderr,"VCDSrc: track offset is %ld\n",src->trackoffset); + (((src->tracks[src->track - 1].cdte_addr.msf.minute * 60) + + src->tracks[src->track - 1].cdte_addr.msf.second) * 75) + + src->tracks[src->track - 1].cdte_addr.msf.frame; + fprintf (stderr, "VCDSrc: track offset is %ld\n", src->trackoffset); - GST_FLAG_SET(src,VCDSRC_OPEN); + GST_FLAG_SET (src, VCDSRC_OPEN); return TRUE; } /* close the file */ static void -vcdsrc_close_file (VCDSrc *src) +vcdsrc_close_file (VCDSrc * src) { - g_return_if_fail(GST_FLAG_IS_SET(src,VCDSRC_OPEN)); + g_return_if_fail (GST_FLAG_IS_SET (src, VCDSRC_OPEN)); /* close the file */ - close(src->fd); + close (src->fd); /* zero out a lot of our state */ src->fd = 0; src->curoffset = 0; src->seq = 0; - GST_FLAG_UNSET(src,VCDSRC_OPEN); + GST_FLAG_UNSET (src, VCDSRC_OPEN); } static GstElementStateReturn -vcdsrc_change_state (GstElement *element) +vcdsrc_change_state (GstElement * element) { - g_return_val_if_fail(GST_IS_VCDSRC(element), GST_STATE_FAILURE); + g_return_val_if_fail (GST_IS_VCDSRC (element), GST_STATE_FAILURE); /* if going down into NULL state, close the file if it's open */ - if (GST_STATE_PENDING(element) == GST_STATE_NULL) { - if (GST_FLAG_IS_SET(element,VCDSRC_OPEN)) - vcdsrc_close_file(VCDSRC(element)); - /* otherwise (READY or higher) we need to open the sound card */ + if (GST_STATE_PENDING (element) == GST_STATE_NULL) { + if (GST_FLAG_IS_SET (element, VCDSRC_OPEN)) + vcdsrc_close_file (VCDSRC (element)); + /* otherwise (READY or higher) we need to open the sound card */ } else { - if (!GST_FLAG_IS_SET(element,VCDSRC_OPEN)) { - if (!vcdsrc_open_file(VCDSRC(element))) - return GST_STATE_FAILURE; + if (!GST_FLAG_IS_SET (element, VCDSRC_OPEN)) { + if (!vcdsrc_open_file (VCDSRC (element))) + return GST_STATE_FAILURE; } } - if (GST_ELEMENT_CLASS(parent_class)->change_state) - return GST_ELEMENT_CLASS(parent_class)->change_state(element); + if (GST_ELEMENT_CLASS (parent_class)->change_state) + return GST_ELEMENT_CLASS (parent_class)->change_state (element); return GST_STATE_SUCCESS; } static void -vcdsrc_recalculate (VCDSrc *vcdsrc) +vcdsrc_recalculate (VCDSrc * vcdsrc) { - if (GST_FLAG_IS_SET(vcdsrc,VCDSRC_OPEN)) { + if (GST_FLAG_IS_SET (vcdsrc, VCDSRC_OPEN)) { /* calculate track offset (beginning of track) */ vcdsrc->trackoffset = -(((vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.minute * 60) + - vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.second) * 75) + - vcdsrc->tracks[vcdsrc->track-1].cdte_addr.msf.frame; - fprintf(stderr,"VCDSrc: track offset is %ld\n",vcdsrc->trackoffset); + (((vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.minute * 60) + + vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.second) * 75) + + vcdsrc->tracks[vcdsrc->track - 1].cdte_addr.msf.frame; + fprintf (stderr, "VCDSrc: track offset is %ld\n", vcdsrc->trackoffset); } } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE, GST_TYPE_VCDSRC); + return gst_element_register (plugin, "vcdsrc", GST_RANK_NONE, + GST_TYPE_VCDSRC); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "vcdsrc", - "Asynchronous read from VCD disk", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "vcdsrc", + "Asynchronous read from VCD disk", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/sys/vcd/vcdsrc.h b/sys/vcd/vcdsrc.h index ab2c74da..5026cd78 100644 --- a/sys/vcd/vcdsrc.h +++ b/sys/vcd/vcdsrc.h @@ -28,8 +28,9 @@ #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define VCD_BYTES_PER_SECTOR 2352 @@ -46,51 +47,54 @@ extern "C" { (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VCDSRC)) /* NOTE: per-element flags start with 16 for now */ -typedef enum { - VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST, + typedef enum + { + VCDSRC_OPEN = GST_ELEMENT_FLAG_LAST, - VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2, -} VCDSrcFlags; + VCDSRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, + } VCDSrcFlags; -typedef struct _VCDSrc VCDSrc; -typedef struct _VCDSrcClass VCDSrcClass; + typedef struct _VCDSrc VCDSrc; + typedef struct _VCDSrcClass VCDSrcClass; -struct _VCDSrc { - GstElement element; - /* pads */ - GstPad *srcpad; + struct _VCDSrc + { + GstElement element; + /* pads */ + GstPad *srcpad; - /* device */ - gchar *device; - /* track number */ - gint track; - /* fd */ - gint fd; + /* device */ + gchar *device; + /* track number */ + gint track; + /* fd */ + gint fd; - struct cdrom_tochdr tochdr; - gint numtracks; - struct cdrom_tocentry *tracks; + struct cdrom_tochdr tochdr; + gint numtracks; + struct cdrom_tocentry *tracks; - /* current time offset */ - gulong trackoffset; - gulong frameoffset; + /* current time offset */ + gulong trackoffset; + gulong frameoffset; - gulong curoffset; /* current offset in file */ - gulong bytes_per_read; /* bytes per read */ + gulong curoffset; /* current offset in file */ + gulong bytes_per_read; /* bytes per read */ - gulong seq; /* buffer sequence number */ - int max_errors; -}; + gulong seq; /* buffer sequence number */ + int max_errors; + }; -struct _VCDSrcClass { - GstElementClass parent_class; -}; + struct _VCDSrcClass + { + GstElementClass parent_class; + }; -GType vcdsrc_get_type(void); + GType vcdsrc_get_type (void); #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __VCDSRC_H__ */ +#endif /* __VCDSRC_H__ */ |