diff options
author | Jan Schmidt <thaytan@mad.scientist.com> | 2008-05-20 10:42:33 +0000 |
---|---|---|
committer | Jan Schmidt <thaytan@mad.scientist.com> | 2008-05-20 10:42:33 +0000 |
commit | 0de3094950661600a9984075709fcde19831fc7a (patch) | |
tree | c41876d49c68657c3d6b1ad05b6fe418b5191424 /gst/videomixer | |
parent | 1361d068742cde907d2932a1ab1589d1311dc086 (diff) |
gst/videomixer/videomixer.*: Instead of a random number for the request pad id's, use a counter.
Original commit message from CVS:
* gst/videomixer/videomixer.c:
* gst/videomixer/videomixer.h:
Instead of a random number for the request pad id's,
use a counter.
Register the videomixerpad class from the element's class_init
where it's safer, and allows the docs generator to scan it.
Diffstat (limited to 'gst/videomixer')
-rw-r--r-- | gst/videomixer/videomixer.c | 12 | ||||
-rw-r--r-- | gst/videomixer/videomixer.h | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c index a25775d2..2df7464e 100644 --- a/gst/videomixer/videomixer.c +++ b/gst/videomixer/videomixer.c @@ -57,7 +57,6 @@ #include <gst/base/gstcollectpads.h> #include <gst/controller/gstcontroller.h> -#include <stdlib.h> #include <string.h> #include "videomixer.h" @@ -500,6 +499,9 @@ gst_videomixer_class_init (GstVideoMixerClass * klass) GST_DEBUG_FUNCPTR (gst_videomixer_release_pad); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_videomixer_change_state); + + /* Register the pad class */ + (void) (GST_TYPE_VIDEO_MIXER_PAD); } static void @@ -532,6 +534,8 @@ gst_videomixer_reset (GstVideoMixer * mix) gst_videomixer_collect_free (data); walk = g_slist_next (walk); } + + mix->next_sinkpad = 0; } static void @@ -622,11 +626,13 @@ gst_videomixer_request_new_pad (GstElement * element, GstVideoMixerCollect *mixcol = NULL; if (req_name == NULL || strlen (req_name) < 6) { - /* no name given when requesting the pad, use random serial number */ - serial = rand (); + /* no name given when requesting the pad, use next available int */ + serial = mix->next_sinkpad++; } else { /* parse serial number from requested padname */ serial = atoi (&req_name[5]); + if (serial >= mix->next_sinkpad) + mix->next_sinkpad = serial + 1; } /* create new pad with the name */ name = g_strdup_printf ("sink_%d", serial); diff --git a/gst/videomixer/videomixer.h b/gst/videomixer/videomixer.h index 102d3e16..81f6d804 100644 --- a/gst/videomixer/videomixer.h +++ b/gst/videomixer/videomixer.h @@ -87,6 +87,9 @@ struct _GstVideoMixer gint fps_n; gint fps_d; + + /* Next available sinkpad index */ + gint next_sinkpad; }; struct _GstVideoMixerClass |