mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Small cleanups
Original commit message from CVS: Small cleanups Added a bound to the number of switches, also fix a small bug
This commit is contained in:
parent
03391373ef
commit
a4e4bb5795
5 changed files with 70 additions and 111 deletions
34
gst/gst.c
34
gst/gst.c
|
@ -199,6 +199,16 @@ load_plugin_func (gpointer data, gpointer user_data)
|
|||
g_free (data);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_number (gchar *number, guint32 *val)
|
||||
{
|
||||
/* handle either 0xHEX or dec */
|
||||
if (*(number+1) == 'x') {
|
||||
sscanf (number+2, "%08x", val);
|
||||
} else {
|
||||
sscanf (number, "%d", val);
|
||||
}
|
||||
}
|
||||
|
||||
/* returns FALSE if the program can be aborted */
|
||||
static gboolean
|
||||
|
@ -219,13 +229,7 @@ gst_init_check (int *argc,
|
|||
if (!strncmp ("--gst-info-mask=", (*argv)[i], 16)) {
|
||||
guint32 val;
|
||||
|
||||
/* handle either 0xHEX or dec */
|
||||
if (*((*argv)[i]+17) == 'x') {
|
||||
sscanf ((*argv)[i]+18, "%08x", &val);
|
||||
} else {
|
||||
sscanf ((*argv)[i]+16, "%d", &val);
|
||||
}
|
||||
|
||||
parse_number ((*argv)[i]+16, &val);
|
||||
gst_info_set_categories (val);
|
||||
|
||||
(*argv)[i] = NULL;
|
||||
|
@ -233,13 +237,7 @@ gst_init_check (int *argc,
|
|||
else if (!strncmp ("--gst-debug-mask=", (*argv)[i], 17)) {
|
||||
guint32 val;
|
||||
|
||||
/* handle either 0xHEX or dec */
|
||||
if (*((*argv)[i]+18) == 'x') {
|
||||
sscanf ((*argv)[i]+19, "%08x", &val);
|
||||
} else {
|
||||
sscanf ((*argv)[i]+17, "%d", &val);
|
||||
}
|
||||
|
||||
parse_number ((*argv)[i]+17, &val);
|
||||
gst_debug_set_categories (val);
|
||||
|
||||
(*argv)[i] = NULL;
|
||||
|
@ -247,13 +245,7 @@ gst_init_check (int *argc,
|
|||
else if (!strncmp ("--gst-mask=", (*argv)[i], 11)) {
|
||||
guint32 val;
|
||||
|
||||
/* handle either 0xHEX or dec */
|
||||
if (*((*argv)[i]+12) == 'x') {
|
||||
sscanf ((*argv)[i]+13, "%08x", &val);
|
||||
} else {
|
||||
sscanf ((*argv)[i]+11, "%d", &val);
|
||||
}
|
||||
|
||||
parse_number ((*argv)[i]+11, &val);
|
||||
gst_debug_set_categories (val);
|
||||
gst_info_set_categories (val);
|
||||
|
||||
|
|
|
@ -381,10 +381,11 @@ gst_bin_child_state_change (GstBin *bin, GstElementState old, GstElementState ne
|
|||
|
||||
for (i = GST_NUM_STATES - 1; i >= 0; i--) {
|
||||
if (bin->child_states[i] != 0) {
|
||||
if (GST_STATE (bin) != (1 << i)) {
|
||||
gint state = (1 << i);
|
||||
if (GST_STATE (bin) != state) {
|
||||
GST_INFO (GST_CAT_STATES, "bin %s need state change to %s",
|
||||
GST_ELEMENT_NAME (bin), gst_element_statename (1 << i));
|
||||
GST_STATE_PENDING (bin) = (1 << i);
|
||||
GST_ELEMENT_NAME (bin), gst_element_statename (state));
|
||||
GST_STATE_PENDING (bin) = state;
|
||||
gst_bin_change_state_norecurse (bin);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -102,20 +102,20 @@ gst_object_class_init (GstObjectClass *klass)
|
|||
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_object_set_property);
|
||||
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property);
|
||||
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME,
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME,
|
||||
g_param_spec_string ("name", "Name", "The name of the object",
|
||||
NULL, G_PARAM_READWRITE));
|
||||
|
||||
gst_object_signals[PARENT_SET] =
|
||||
g_signal_new("parent_set", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
||||
g_signal_new ("parent_set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstObjectClass, parent_set), NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,G_TYPE_NONE,1,
|
||||
g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
|
||||
G_TYPE_OBJECT);
|
||||
#ifndef GST_DISABLE_LOADSAVE_REGISTRY
|
||||
gst_object_signals[OBJECT_SAVED] =
|
||||
g_signal_new("object_saved", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
||||
g_signal_new ("object_saved", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstObjectClass, object_saved), NULL, NULL,
|
||||
g_cclosure_marshal_VOID__POINTER,G_TYPE_NONE,1,
|
||||
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
#endif
|
||||
|
||||
|
|
105
gst/gstprops.c
105
gst/gstprops.c
|
@ -590,7 +590,28 @@ gst_props_copy_on_write (GstProps *props)
|
|||
gst_props_unref (props);
|
||||
}
|
||||
|
||||
return props;
|
||||
return new;
|
||||
}
|
||||
|
||||
static GstPropsEntry*
|
||||
gst_props_get_entry_func (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
|
||||
g_return_val_if_fail (props != NULL, NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
return thisentry;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -605,24 +626,13 @@ gst_props_copy_on_write (GstProps *props)
|
|||
gint
|
||||
gst_props_get_int (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
g_return_val_if_fail (props != NULL, 0);
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
thisentry = gst_props_get_entry_func (props, name);
|
||||
|
||||
if (thisentry) {
|
||||
return thisentry->data.int_data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -638,21 +648,13 @@ gst_props_get_int (GstProps *props, const gchar *name)
|
|||
gfloat
|
||||
gst_props_get_float (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
thisentry = gst_props_get_entry_func (props, name);
|
||||
|
||||
if (thisentry) {
|
||||
return thisentry->data.float_data;
|
||||
}
|
||||
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
|
@ -668,24 +670,13 @@ gst_props_get_float (GstProps *props, const gchar *name)
|
|||
gulong
|
||||
gst_props_get_fourcc_int (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
g_return_val_if_fail (props != NULL, 0);
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
thisentry = gst_props_get_entry_func (props, name);
|
||||
|
||||
if (thisentry) {
|
||||
return thisentry->data.fourcc_data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -701,24 +692,13 @@ gst_props_get_fourcc_int (GstProps *props, const gchar *name)
|
|||
gboolean
|
||||
gst_props_get_boolean (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
g_return_val_if_fail (props != NULL, FALSE);
|
||||
g_return_val_if_fail (name != NULL, FALSE);
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
thisentry = gst_props_get_entry_func (props, name);
|
||||
|
||||
if (thisentry) {
|
||||
return thisentry->data.bool_data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -734,24 +714,13 @@ gst_props_get_boolean (GstProps *props, const gchar *name)
|
|||
const gchar*
|
||||
gst_props_get_string (GstProps *props, const gchar *name)
|
||||
{
|
||||
GList *lentry;
|
||||
GQuark quark;
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
g_return_val_if_fail (props != NULL, NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
quark = g_quark_from_string (name);
|
||||
|
||||
lentry = g_list_find_custom (props->properties, GINT_TO_POINTER (quark), props_find_func);
|
||||
|
||||
if (lentry) {
|
||||
GstPropsEntry *thisentry;
|
||||
|
||||
thisentry = (GstPropsEntry *)lentry->data;
|
||||
thisentry = gst_props_get_entry_func (props, name);
|
||||
|
||||
if (thisentry) {
|
||||
return thisentry->data.string_data.string;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,17 +341,18 @@ static void
|
|||
gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstRealPad *peer = GST_RPAD_PEER (pad);
|
||||
gint loop_count = 100;
|
||||
|
||||
GST_DEBUG_ENTER ("(%s:%s)", GST_DEBUG_PAD_NAME (pad));
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "putting buffer %p in peer \"%s:%s\"'s pen\n", buf,
|
||||
GST_DEBUG_PAD_NAME (peer));
|
||||
|
||||
/* FIXME this should be bounded
|
||||
/*
|
||||
* loop until the bufferpen is empty so we can fill it up again
|
||||
*/
|
||||
while (GST_RPAD_BUFPEN (pad) != NULL) {
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "switching to %p to empty bufpen\n",
|
||||
GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)));
|
||||
while (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) != NULL && --loop_count) {
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "switching to %p to empty bufpen %d\n",
|
||||
GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), loop_count);
|
||||
cothread_switch (GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)));
|
||||
|
||||
/* we may no longer be the same pad, check. */
|
||||
|
@ -361,6 +362,11 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstBuffer * buf)
|
|||
}
|
||||
}
|
||||
|
||||
if (loop_count == 0) {
|
||||
gst_element_error (GST_PAD_PARENT (pad),
|
||||
"(internal error) maximum number of switches exceeded");
|
||||
return;
|
||||
}
|
||||
g_assert (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) == NULL);
|
||||
/* now fill the bufferpen and switch so it can be consumed */
|
||||
GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = buf;
|
||||
|
@ -374,8 +380,6 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstBuffer * buf)
|
|||
static void
|
||||
gst_basic_scheduler_select_proxy (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
g_print ("select proxy (%s:%s)\n", GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
GST_DEBUG_ENTER ("(%s:%s)", GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "putting buffer %p in peer's pen\n", buf);
|
||||
|
@ -385,13 +389,10 @@ gst_basic_scheduler_select_proxy (GstPad * pad, GstBuffer * buf)
|
|||
GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = buf;
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "switching to %p\n",
|
||||
GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)));
|
||||
g_print ("%p %s\n", GST_ELEMENT (GST_PAD_PARENT (pad)),
|
||||
gst_element_get_name (GST_ELEMENT (GST_PAD_PARENT (pad))));
|
||||
GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad = pad;
|
||||
|
||||
cothread_switch (GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)));
|
||||
|
||||
g_print ("done switching\n");
|
||||
GST_DEBUG (GST_CAT_DATAFLOW, "done switching\n");
|
||||
}
|
||||
|
||||
|
@ -1165,7 +1166,6 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist)
|
|||
pad = GST_PAD (padlist2->data);
|
||||
|
||||
if (gst_pad_peek (pad)) {
|
||||
g_print ("found something in pad %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
||||
return pad;
|
||||
}
|
||||
|
||||
|
@ -1185,12 +1185,9 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist)
|
|||
|
||||
cothread_switch (GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (peer)));
|
||||
|
||||
g_print ("%p %s\n", GST_ELEMENT (GST_PAD_PARENT (pad)),
|
||||
gst_element_get_name (GST_ELEMENT (GST_PAD_PARENT (pad))));
|
||||
pad = GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad;
|
||||
|
||||
g_assert (pad != NULL);
|
||||
g_print ("back from select (%s:%s)\n", GST_DEBUG_PAD_NAME (pad));
|
||||
}
|
||||
return pad;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue