GST_DEBUG_OBJECT (bus, "[msg %p] posting on bus %" GST_PTR_FORMAT, message,
message);
+ /* check we didn't accidentally add a public flag that maps to same value */
+ g_assert (!GST_MINI_OBJECT_FLAG_IS_SET (message,
+ GST_MESSAGE_FLAG_ASYNC_DELIVERY));
+
GST_OBJECT_LOCK (bus);
/* check if the bus is flushing */
if (GST_OBJECT_FLAG_IS_SET (bus, GST_BUS_FLUSHING))
g_cond_init (cond);
g_mutex_init (lock);
+ GST_MINI_OBJECT_FLAG_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY);
+
GST_DEBUG_OBJECT (bus, "[msg %p] waiting for async delivery", message);
/* now we lock the message mutex, send the message to the async
/* now block till the message is freed */
g_cond_wait (cond, lock);
+
+ /* we acquired a new ref from gst_message_dispose() so we can clean up */
g_mutex_unlock (lock);
GST_DEBUG_OBJECT (bus, "[msg %p] delivered asynchronously", message);
+ GST_MINI_OBJECT_FLAG_UNSET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY);
+
g_mutex_clear (lock);
g_cond_clear (cond);
+
+ gst_message_unref (message);
break;
}
default:
return 0;
}
+static gboolean
+_gst_message_dispose (GstMessage * message)
+{
+ gboolean do_free = TRUE;
+
+ if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
+ GST_INFO ("[msg %p] signalling async free", message);
+
+ GST_MESSAGE_LOCK (message);
+ GST_MESSAGE_SIGNAL (message);
+ GST_MESSAGE_UNLOCK (message);
+
+ /* don't free it yet, let bus finish with it first */
+ gst_message_ref (message);
+ do_free = FALSE;
+ }
+
+ return do_free;
+}
+
static void
_gst_message_free (GstMessage * message)
{
GST_MESSAGE_SRC (message) = NULL;
}
- if (message->lock.p) {
- GST_MESSAGE_LOCK (message);
- GST_MESSAGE_SIGNAL (message);
- GST_MESSAGE_UNLOCK (message);
- }
-
structure = GST_MESSAGE_STRUCTURE (message);
if (structure) {
gst_structure_set_parent_refcount (structure, NULL);
GstObject * src)
{
gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
- (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
+ (GstMiniObjectCopyFunction) _gst_message_copy,
+ (GstMiniObjectDisposeFunction) _gst_message_dispose,
(GstMiniObjectFreeFunction) _gst_message_free);
GST_MESSAGE_TYPE (message) = type;