[cogl/wip/cogl-gst] gst-video-sink: Use integers for emitting the signals



commit c0257cd20797812241c59c3888e5dee505053aed
Author: Neil Roberts <neil linux intel com>
Date:   Fri Mar 1 13:20:38 2013 +0000

    gst-video-sink: Use integers for emitting the signals
    
    Usually when a GObject creates its signals it stores the integer ids
    for them in a static array so that it can later emit them without
    having to look them up from a string name.
    
    This patch also changes it to add a class closure for the two signals
    because that is the norm.
    
    The names have been changed to ‘pipeline-ready’ and ‘new-frame’
    because it is not usual to encode any namespacing in the signal names.

 cogl-gst/cogl-gst-video-sink.c     |   44 ++++++++++++++++++++++++++++-------
 cogl-gst/cogl-gst-video-sink.h     |    5 ++++
 examples/cogl-basic-video-player.c |    7 +----
 3 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/cogl-gst/cogl-gst-video-sink.c b/cogl-gst/cogl-gst-video-sink.c
index 9c82ff7..fae22c5 100644
--- a/cogl-gst/cogl-gst-video-sink.c
+++ b/cogl-gst/cogl-gst-video-sink.c
@@ -78,6 +78,16 @@ enum
   PROP_UPDATE_PRIORITY
 };
 
+enum
+{
+  PIPELINE_READY_SIGNAL,
+  NEW_FRAME_SIGNAL,
+
+  LAST_SIGNAL
+};
+
+static guint video_sink_signals[LAST_SIGNAL] = { 0, };
+
 typedef enum
 {
   COGL_GST_NOFORMAT,
@@ -232,7 +242,7 @@ create_template_pipeline (CoglGstVideoSink *sink,
       cogl_object_unref (snippet);
     }
 
-  g_signal_emit_by_name (sink, "cogl-pipeline-ready", NULL);
+  g_signal_emit (sink, video_sink_signals[PIPELINE_READY_SIGNAL], 0, NULL);
 }
 
 static void
@@ -834,7 +844,9 @@ cogl_gst_source_dispatch (GSource *source,
       if (!priv->renderer->upload (gst_source->sink, buffer))
         goto fail_upload;
 
-      g_signal_emit_by_name (gst_source->sink, "cogl-gst-new-frame", NULL);
+      g_signal_emit (gst_source->sink,
+                     video_sink_signals[NEW_FRAME_SIGNAL], 0,
+                     NULL);
       gst_buffer_unref (buffer);
     }
   else
@@ -1076,13 +1088,27 @@ cogl_gst_video_sink_class_init (CoglGstVideoSinkClass *klass)
 
   g_object_class_install_property (go_class, PROP_UPDATE_PRIORITY, pspec);
 
-  g_signal_new ("cogl-pipeline-ready", COGL_GST_TYPE_VIDEO_SINK,
-                G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
-                G_TYPE_NONE, 0, G_TYPE_NONE);
-
-  g_signal_new ("cogl-gst-new-frame", COGL_GST_TYPE_VIDEO_SINK,
-                G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
-                G_TYPE_NONE, 0, G_TYPE_NONE);
+  video_sink_signals[PIPELINE_READY_SIGNAL] =
+    g_signal_new ("pipeline-ready",
+                  COGL_GST_TYPE_VIDEO_SINK,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (CoglGstVideoSinkClass, pipeline_ready),
+                  NULL, /* accumulator */
+                  NULL, /* accu_data */
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0 /* n_params */);
+
+  video_sink_signals[NEW_FRAME_SIGNAL] =
+    g_signal_new ("new-frame",
+                  COGL_GST_TYPE_VIDEO_SINK,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (CoglGstVideoSinkClass, new_frame),
+                  NULL, /* accumulator */
+                  NULL, /* accu_data */
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0 /* n_params */);
 }
 
 CoglGstVideoSink*
diff --git a/cogl-gst/cogl-gst-video-sink.h b/cogl-gst/cogl-gst-video-sink.h
index 53f6245..26e34b1 100644
--- a/cogl-gst/cogl-gst-video-sink.h
+++ b/cogl-gst/cogl-gst-video-sink.h
@@ -87,6 +87,11 @@ struct _CoglGstVideoSink
 struct _CoglGstVideoSinkClass
 {
   GstBaseSinkClass parent_class;
+
+  void (* new_frame) (CoglGstVideoSink *sink);
+  void (* pipeline_ready) (CoglGstVideoSink *sink);
+
+  void *_padding_dummy[8];
 };
 
 GType       cogl_gst_video_sink_get_type    (void) G_GNUC_CONST;
diff --git a/examples/cogl-basic-video-player.c b/examples/cogl-basic-video-player.c
index 51929a1..984b30b 100644
--- a/examples/cogl-basic-video-player.c
+++ b/examples/cogl-basic-video-player.c
@@ -149,10 +149,7 @@ _set_up_pipeline (gpointer instance,
      frame-rate of the video.
   */
 
-  g_signal_connect (data->sink,
-                    "cogl-gst-new-frame",
-                    G_CALLBACK (_new_frame_cb),
-                    data);
+  g_signal_connect (data->sink, "new-frame", G_CALLBACK (_new_frame_cb), data);
 }
 
 int
@@ -234,7 +231,7 @@ main (int argc,
     is prepared to retrieve and attach the first frame of the video.
   */
 
-  g_signal_connect (data.sink, "cogl-pipeline-ready",
+  g_signal_connect (data.sink, "pipeline-ready",
                     G_CALLBACK (_set_up_pipeline), &data);
 
   data.draw_ready = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]