~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty

« back to all changes in this revision

Viewing changes to gst/gstbus.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-08-08 18:12:33 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120808181233-riejwxprfsxh1njl
Tags: 0.11.93-1
* New upstream release:
  + debian/libgstreamer.symbols:
    - Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
};
101
101
 
102
102
static void gst_bus_dispose (GObject * object);
 
103
static void gst_bus_finalize (GObject * object);
103
104
 
104
105
static guint gst_bus_signals[LAST_SIGNAL] = { 0 };
105
106
 
110
111
 
111
112
  GstBusSyncHandler sync_handler;
112
113
  gpointer sync_handler_data;
 
114
  GDestroyNotify sync_handler_notify;
113
115
 
114
116
  guint signal_watch_id;
115
117
  guint num_signal_watchers;
158
160
  GObjectClass *gobject_class = (GObjectClass *) klass;
159
161
 
160
162
  gobject_class->dispose = gst_bus_dispose;
 
163
  gobject_class->finalize = gst_bus_finalize;
161
164
  gobject_class->set_property = gst_bus_set_property;
162
165
  gobject_class->constructed = gst_bus_constructed;
163
166
 
164
 
  /* GstBus:enable-async:
 
167
  /**
 
168
   * GstBus::enable-async:
165
169
   *
166
170
   * Enable async message delivery support for bus watches,
167
171
   * gst_bus_pop() and similar API. Without this only the
169
173
   *
170
174
   * This property is used to create the child element buses
171
175
   * in #GstBin.
172
 
   *
173
 
   * Since: 0.10.33
174
176
   */
175
177
  g_object_class_install_property (gobject_class, PROP_ENABLE_ASYNC,
176
178
      g_param_spec_boolean ("enable-async", "Enable Async",
225
227
  g_mutex_init (&bus->priv->queue_lock);
226
228
  bus->priv->queue = gst_atomic_queue_new (32);
227
229
 
 
230
  /* clear floating flag */
 
231
  gst_object_ref_sink (bus);
 
232
 
228
233
  GST_DEBUG_OBJECT (bus, "created");
229
234
}
230
235
 
255
260
  G_OBJECT_CLASS (parent_class)->dispose (object);
256
261
}
257
262
 
 
263
static void
 
264
gst_bus_finalize (GObject * object)
 
265
{
 
266
  GstBus *bus = GST_BUS (object);
 
267
 
 
268
  if (bus->priv->sync_handler_notify)
 
269
    bus->priv->sync_handler_notify (bus->priv->sync_handler_data);
 
270
 
 
271
  G_OBJECT_CLASS (parent_class)->finalize (object);
 
272
}
 
273
 
258
274
/**
259
275
 * gst_bus_new:
260
276
 *
463
479
 *     with gst_message_unref() after usage.
464
480
 *
465
481
 * MT safe.
466
 
 *
467
 
 * Since: 0.10.15
468
482
 */
469
483
GstMessage *
470
484
gst_bus_timed_pop_filtered (GstBus * bus, GstClockTime timeout,
561
575
 * gst_message_unref() after usage.
562
576
 *
563
577
 * MT safe.
564
 
 *
565
 
 * Since: 0.10.12
566
578
 */
567
579
GstMessage *
568
580
gst_bus_timed_pop (GstBus * bus, GstClockTime timeout)
588
600
 *     gst_message_unref() after usage.
589
601
 *
590
602
 * MT safe.
591
 
 *
592
 
 * Since: 0.10.15
593
603
 */
594
604
GstMessage *
595
605
gst_bus_pop_filtered (GstBus * bus, GstMessageType types)
654
664
/**
655
665
 * gst_bus_set_sync_handler:
656
666
 * @bus: a #GstBus to install the handler on
657
 
 * @func: The handler function to install
658
 
 * @data: User data that will be sent to the handler function.
 
667
 * @func: (allow-none): The handler function to install
 
668
 * @user_data: User data that will be sent to the handler function.
 
669
 * @notify: called when @user_data becomes unused
659
670
 *
660
671
 * Sets the synchronous handler on the bus. The function will be called
661
672
 * every time a new message is posted on the bus. Note that the function
668
679
 * function, which will clear the existing handler.
669
680
 */
670
681
void
671
 
gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func, gpointer data)
 
682
gst_bus_set_sync_handler (GstBus * bus, GstBusSyncHandler func,
 
683
    gpointer user_data, GDestroyNotify notify)
672
684
{
 
685
  GDestroyNotify old_notify;
 
686
 
673
687
  g_return_if_fail (GST_IS_BUS (bus));
674
688
 
675
689
  GST_OBJECT_LOCK (bus);
676
 
 
677
690
  /* Assert if the user attempts to replace an existing sync_handler,
678
691
   * other than to clear it */
679
692
  if (func != NULL && bus->priv->sync_handler != NULL)
680
693
    goto no_replace;
681
694
 
 
695
  if ((old_notify = bus->priv->sync_handler_notify)) {
 
696
    gpointer old_data = bus->priv->sync_handler_data;
 
697
 
 
698
    bus->priv->sync_handler_data = NULL;
 
699
    bus->priv->sync_handler_notify = NULL;
 
700
    GST_OBJECT_UNLOCK (bus);
 
701
 
 
702
    old_notify (old_data);
 
703
 
 
704
    GST_OBJECT_LOCK (bus);
 
705
  }
682
706
  bus->priv->sync_handler = func;
683
 
  bus->priv->sync_handler_data = data;
 
707
  bus->priv->sync_handler_data = user_data;
 
708
  bus->priv->sync_handler_notify = notify;
684
709
  GST_OBJECT_UNLOCK (bus);
685
710
 
686
711
  return;
859
884
 * @notify: the function to call when the source is removed.
860
885
 *
861
886
 * Adds a bus watch to the default main context with the given @priority (e.g.
862
 
 * %G_PRIORITY_DEFAULT). Since 0.10.33 it is also possible to use a non-default
863
 
 * main context set up using g_main_context_push_thread_default() (before
 
887
 * %G_PRIORITY_DEFAULT). It is also possible to use a non-default  main
 
888
 * context set up using g_main_context_push_thread_default() (before
864
889
 * one had to create a bus watch source and attach it to the desired main
865
890
 * context 'manually').
866
891
 *
874
899
 * The watch can be removed using g_source_remove() or by returning FALSE
875
900
 * from @func.
876
901
 *
 
902
 * MT safe.
 
903
 *
877
904
 * Returns: The event source id.
878
905
 * Rename to: gst_bus_add_watch
879
 
 * MT safe.
880
906
 */
881
907
guint
882
908
gst_bus_add_watch_full (GstBus * bus, gint priority,
900
926
 * @user_data: user data passed to @func.
901
927
 *
902
928
 * Adds a bus watch to the default main context with the default priority
903
 
 * (%G_PRIORITY_DEFAULT). Since 0.10.33 it is also possible to use a non-default
904
 
 * main context set up using g_main_context_push_thread_default() (before
 
929
 * (%G_PRIORITY_DEFAULT). It is also possible to use a non-default main
 
930
 * context set up using g_main_context_push_thread_default() (before
905
931
 * one had to create a bus watch source and attach it to the desired main
906
932
 * context 'manually').
907
933
 *
1195
1221
 * @priority: The priority of the watch.
1196
1222
 *
1197
1223
 * Adds a bus signal watch to the default main context with the given @priority
1198
 
 * (e.g. %G_PRIORITY_DEFAULT). Since 0.10.33 it is also possible to use a
1199
 
 * non-default main context set up using g_main_context_push_thread_default()
 
1224
 * (e.g. %G_PRIORITY_DEFAULT). It is also possible to use a non-default main
 
1225
 * context set up using g_main_context_push_thread_default()
1200
1226
 * (before one had to create a bus watch source and attach it to the desired
1201
1227
 * main context 'manually').
1202
1228
 *
1254
1280
 * @bus: a #GstBus on which you want to receive the "message" signal
1255
1281
 *
1256
1282
 * Adds a bus signal watch to the default main context with the default priority
1257
 
 * (%G_PRIORITY_DEFAULT). Since 0.10.33 it is also possible to use a non-default
 
1283
 * (%G_PRIORITY_DEFAULT). It is also possible to use a non-default
1258
1284
 * main context set up using g_main_context_push_thread_default() (before
1259
1285
 * one had to create a bus watch source and attach it to the desired main
1260
1286
 * context 'manually').