+2005-08-24 Jan Schmidt <thaytan@mad.scientist.com>
+
+ * check/gst/gstbin.c: (GST_START_TEST):
+ * gst/gstbin.c: (bin_bus_handler):
+ * gst/gstmessage.c: (gst_message_finalize), (_gst_message_copy),
+ (gst_message_new), (gst_message_new_eos), (gst_message_new_error),
+ (gst_message_new_warning), (gst_message_new_tag),
+ (gst_message_new_state_changed), (gst_message_new_segment_start),
+ (gst_message_new_segment_done), (gst_message_new_custom):
+ * gst/gstmessage.h:
+ * tools/gst-launch.c: (event_loop):
+ * tools/gst-md5sum.c: (event_loop):
+ Change GST_MESSAGE_SRC to be a GObject rather than a GstObject, so
+ that applications can sensibly post custom messages with references
+ to their own objects.
+
2005-08-24 Andy Wingo <wingo@pobox.com>
* gst/gstpad.c (gst_pad_fixate_caps): Check if the caps is fixed
== GST_MESSAGE_STATE_CHANGED, "did not get GST_MESSAGE_STATE_CHANGED");
message = gst_bus_pop (bus);
- fail_unless (message->src == GST_OBJECT (src));
+ fail_unless (GST_MESSAGE_SRC (message) == G_OBJECT (src));
gst_message_unref (message);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
== GST_MESSAGE_STATE_CHANGED, "did not get GST_MESSAGE_STATE_CHANGED");
message = gst_bus_pop (bus);
- fail_unless (message->src == GST_OBJECT (bin));
+ fail_unless (GST_MESSAGE_SRC (message) == G_OBJECT (bin));
gst_message_unref (message);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_EOS:{
- gchar *name = gst_object_get_name (GST_MESSAGE_SRC (message));
+ GObject *src = GST_MESSAGE_SRC (message);
+ gchar *name;
+
+ if (src && GST_IS_OBJECT (src))
+ name = gst_object_get_name (GST_OBJECT (src));
+ else
+ name = g_strdup ("(null)");
GST_DEBUG_OBJECT (bin, "got EOS message from %s", name);
g_free (name);
GST_CAT_INFO (GST_CAT_MESSAGE, "finalize message %p", message);
if (GST_MESSAGE_SRC (message)) {
- gst_object_unref (GST_MESSAGE_SRC (message));
+ if (GST_IS_OBJECT (GST_MESSAGE_SRC (message)))
+ gst_object_unref (GST_OBJECT (GST_MESSAGE_SRC (message)));
+ else
+ g_object_unref (GST_MESSAGE_SRC (message));
GST_MESSAGE_SRC (message) = NULL;
}
GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
if (GST_MESSAGE_SRC (message)) {
- GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
+ if (GST_IS_OBJECT (GST_MESSAGE_SRC (message)))
+ GST_MESSAGE_SRC (copy) =
+ gst_object_ref (GST_OBJECT (GST_MESSAGE_SRC (message)));
+ else
+ GST_MESSAGE_SRC (copy) = g_object_ref (GST_MESSAGE_SRC (message));
}
if (message->structure) {
}
static GstMessage *
-gst_message_new (GstMessageType type, GstObject * src)
+gst_message_new (GstMessageType type, GObject * src)
{
GstMessage *message;
message->type = type;
if (src) {
- message->src = gst_object_ref (src);
+ if (GST_IS_OBJECT (src))
+ message->src = gst_object_ref (GST_OBJECT (src));
+ else
+ message->src = g_object_ref (src);
+
GST_CAT_DEBUG_OBJECT (GST_CAT_MESSAGE, src, "message source");
} else {
message->src = NULL;
{
GstMessage *message;
- message = gst_message_new (GST_MESSAGE_EOS, src);
+ message = gst_message_new (GST_MESSAGE_EOS, (GObject *) (src));
return message;
}
GstMessage *message;
GstStructure *s;
- message = gst_message_new (GST_MESSAGE_ERROR, src);
+ message = gst_message_new (GST_MESSAGE_ERROR, (GObject *) (src));
/* gst_structure_new takes copies of the types passed in */
s = gst_structure_new ("GstMessageError", "gerror", GST_TYPE_G_ERROR, error,
"debug", G_TYPE_STRING, debug, NULL);
GstMessage *message;
GstStructure *s;
- message = gst_message_new (GST_MESSAGE_WARNING, src);
+ message = gst_message_new (GST_MESSAGE_WARNING, (GObject *) (src));
/* gst_structure_new takes copies of the types passed in */
s = gst_structure_new ("GstMessageWarning", "gerror", GST_TYPE_G_ERROR, error,
"debug", G_TYPE_STRING, debug, NULL);
g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
- message = gst_message_new (GST_MESSAGE_TAG, src);
+ message = gst_message_new (GST_MESSAGE_TAG, (GObject *) (src));
gst_structure_set_parent_refcount (tag_list, &message->mini_object.refcount);
message->structure = tag_list;
GstMessage *message;
GstStructure *s;
- message = gst_message_new (GST_MESSAGE_STATE_CHANGED, src);
+ message = gst_message_new (GST_MESSAGE_STATE_CHANGED, (GObject *) (src));
s = gst_structure_new ("GstMessageState", "old-state", G_TYPE_INT, (gint) old,
"new-state", G_TYPE_INT, (gint) new, NULL);
GstMessage *message;
GstStructure *s;
- message = gst_message_new (GST_MESSAGE_SEGMENT_START, src);
+ message = gst_message_new (GST_MESSAGE_SEGMENT_START, (GObject *) (src));
s = gst_structure_new ("GstMessageSegmentStart", "timestamp", G_TYPE_INT64,
(gint64) timestamp, NULL);
GstMessage *message;
GstStructure *s;
- message = gst_message_new (GST_MESSAGE_SEGMENT_DONE, src);
+ message = gst_message_new (GST_MESSAGE_SEGMENT_DONE, (GObject *) (src));
s = gst_structure_new ("GstMessageSegmentDone", "timestamp", G_TYPE_INT64,
(gint64) timestamp, NULL);
* MT safe.
*/
GstMessage *
-gst_message_new_custom (GstMessageType type, GstObject * src,
+gst_message_new_custom (GstMessageType type, GObject * src,
GstStructure * structure)
{
GstMessage *message;
/*< public > *//* with COW */
GstMessageType type;
guint64 timestamp;
- GstObject *src;
+ GObject *src;
GstStructure *structure;
GstMessage * gst_message_new_segment_start (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_segment_done (GstObject * src, GstClockTime timestamp);
GstMessage * gst_message_new_custom (GstMessageType type,
- GstObject * src,
+ GObject * src,
GstStructure * structure);
#define gst_message_new_application(src, str) \
gst_message_new_custom (GST_MESSAGE_APPLICATION, src, str)
== GST_MESSAGE_STATE_CHANGED, "did not get GST_MESSAGE_STATE_CHANGED");
message = gst_bus_pop (bus);
- fail_unless (message->src == GST_OBJECT (src));
+ fail_unless (GST_MESSAGE_SRC (message) == G_OBJECT (src));
gst_message_unref (message);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
== GST_MESSAGE_STATE_CHANGED, "did not get GST_MESSAGE_STATE_CHANGED");
message = gst_bus_pop (bus);
- fail_unless (message->src == GST_OBJECT (bin));
+ fail_unless (GST_MESSAGE_SRC (message) == G_OBJECT (bin));
gst_message_unref (message);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
gchar *debug;
gst_message_parse_error (message, &gerror, &debug);
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ if (GST_IS_OBJECT (GST_MESSAGE_SRC (message)))
+ gst_object_default_error (GST_OBJECT (GST_MESSAGE_SRC (message)),
+ gerror, debug);
gst_message_unref (message);
if (gerror)
g_error_free (gerror);
gst_message_parse_state_changed (message, &old, &new);
if (!(old == GST_STATE_PLAYING && new == GST_STATE_PAUSED &&
- GST_MESSAGE_SRC (message) == GST_OBJECT (pipeline))) {
+ GST_MESSAGE_SRC (message) == G_OBJECT (pipeline))) {
gst_message_unref (message);
break;
}
gst_message_parse_error (message, &gerror, &debug);
gst_message_unref (message);
- gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
+ if (GST_IS_OBJECT (GST_MESSAGE_SRC (message)))
+ gst_object_default_error (GST_OBJECT (GST_MESSAGE_SRC (message)),
+ gerror, debug);
g_error_free (gerror);
g_free (debug);
return TRUE;