add a value-changed signal so that subclasses can precalculate stuff after a value...
authorSteve Baker <steve@stevebaker.org>
Wed, 29 May 2002 18:45:25 +0000 (18:45 +0000)
committerSteve Baker <steve@stevebaker.org>
Wed, 29 May 2002 18:45:25 +0000 (18:45 +0000)
Original commit message from CVS:
add a value-changed signal so that subclasses can precalculate stuff after a value has been changed

libs/gst/control/dparam.c
libs/gst/control/dparam.h

index c0cd33ee73f2ee6a570443ae597a4f48b5b1d786..f23e09d4f5b0185e829299622f5c52a6b1aa0d9f 100644 (file)
@@ -39,6 +39,13 @@ enum {
        ARG_VALUE_INT64,
 };
 
+enum {
+  VALUE_CHANGED,
+  LAST_SIGNAL
+};
+
+static guint gst_dparam_signals[LAST_SIGNAL] = { 0 };
+
 GType 
 gst_dparam_get_type(void) {
        static GType dparam_type = 0;
@@ -89,6 +96,10 @@ gst_dparam_class_init (GstDParamClass *klass)
                      
        gobject_class->dispose = gst_dparam_dispose;
        
+       gst_dparam_signals[VALUE_CHANGED] =
+               g_signal_new ("value_changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (GstDParamClass, value_changed), NULL, NULL,
+                             gst_marshal_VOID__VOID, G_TYPE_NONE, 0);
        /*gstobject_class->save_thyself = gst_dparam_save_thyself; */
 
 }
@@ -150,27 +161,30 @@ gst_dparam_set_property (GObject *object, guint prop_id, const GValue *value, GP
                case ARG_VALUE_FLOAT:
                        GST_DEBUG(GST_CAT_PARAMS, "setting value from %f to %f", dparam->value_float, g_value_get_float (value));
                        dparam->value_float = g_value_get_float (value);
-                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
+                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        break;
                        
                case ARG_VALUE_INT:
                        GST_DEBUG(GST_CAT_PARAMS, "setting value from %d to %d", dparam->value_int, g_value_get_int (value));
                        dparam->value_int = g_value_get_int (value);
-                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
+                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        break;
                        
                case ARG_VALUE_INT64:
                        GST_DEBUG(GST_CAT_PARAMS, "setting value from %lld to %lld", dparam->value_int64, g_value_get_int64 (value));
                        dparam->value_int64 = g_value_get_int (value);
-                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam);
+                       GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE;
                        break;
                        
                default:
                        break;
        }
+
+       /* note that this signal is sent while we still have the lock. */
+       g_signal_emit (G_OBJECT (dparam), gst_dparam_signals[VALUE_CHANGED], 0);
        GST_DPARAM_UNLOCK(dparam);
 }
 
@@ -199,9 +213,9 @@ gst_dparam_do_update_default (GstDParam *dparam, gint64 timestamp, GValue *value
                        break;
        }
 
-       GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
        GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp;
        GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp;
+       GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
 
        GST_DPARAM_UNLOCK(dparam);
 }
index 8f1975e2f95d5e83f9bc1467df16dc922fc7bd44..7ea2f914a9dab743445e1ea23f55ab93af81c275 100644 (file)
@@ -92,6 +92,7 @@ struct _GstDParamClass {
        GstObjectClass parent_class;
 
        /* signal callbacks */
+       void (*value_changed) (GstDParam *dparam);
 };