From 02e2d6e3fc4ca8a06b0cf0cb6f09aab9206888d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 22 Apr 2009 11:54:49 +0200 Subject: [PATCH] Also use the copy-on-unref workaround for the message-owned Structure here instead of always copying --- gstreamer-sharp/Message.custom | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gstreamer-sharp/Message.custom b/gstreamer-sharp/Message.custom index 8aec26a..2877c0a 100644 --- a/gstreamer-sharp/Message.custom +++ b/gstreamer-sharp/Message.custom @@ -67,17 +67,29 @@ public uint Seqnum { } +private Gst.Structure cached_structure = null; + [DllImport ("gstreamer-0.10.dll") ] static extern IntPtr gst_message_get_structure (IntPtr raw); public Gst.Structure Structure { get { - IntPtr raw_ret = gst_structure_copy (gst_message_get_structure (Handle)); - Gst.Structure ret = raw_ret == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Structure), false); + if (cached_structure != null) + return cached_structure; + + IntPtr raw_ret = gst_message_get_structure (Handle); + Gst.Structure ret = raw_ret == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Structure), true); + ret.FreeNative = false; + cached_structure = ret; return ret; } } +~Message () { + cached_structure.CreateNativeCopy (); + cached_structure = null; +} + [DllImport ("gstreamer-0.10.dll") ] static extern IntPtr gst_message_new_eos (IntPtr src); -- 2.7.4