Ref/unref the Src field of Gst.Event/Message when setting it

This commit is contained in:
Sebastian Dröge 2009-04-23 14:39:50 +02:00
parent 6e766fc1d5
commit 48fc341b06
2 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,12 @@ public ulong Timestamp {
[DllImport ("gstreamersharpglue-0.10") ]
extern static uint gstsharp_gst_event_get_src_offset ();
[DllImport ("gobject-2.0.dll")]
extern static IntPtr g_object_ref (IntPtr handle);
[DllImport ("gobject-2.0.dll")]
extern static void g_object_unref (IntPtr handle);
static uint src_offset = gstsharp_gst_event_get_src_offset ();
public Gst.Object Src {
get {
@ -39,9 +45,12 @@ public Gst.Object Src {
if (!IsWritable)
throw new ApplicationException ();
if (Src != null)
g_object_unref (Src.Handle);
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + src_offset);
*raw_ptr = value == null ? IntPtr.Zero : value.Handle;
*raw_ptr = value == null ? IntPtr.Zero : g_object_ref (value.Handle);
}
}
}

View file

@ -27,6 +27,12 @@ public ulong Timestamp {
[DllImport ("gstreamersharpglue-0.10") ]
extern static uint gstsharp_gst_message_get_src_offset ();
[DllImport ("gobject-2.0.dll")]
extern static IntPtr g_object_ref (IntPtr handle);
[DllImport ("gobject-2.0.dll")]
extern static void g_object_unref (IntPtr handle);
static uint src_offset = gstsharp_gst_message_get_src_offset ();
public Gst.Object Src {
get {
@ -39,9 +45,12 @@ public Gst.Object Src {
if (!IsWritable)
throw new ApplicationException ();
if (Src != null)
g_object_unref (Src.Handle);
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + src_offset);
*raw_ptr = value == null ? IntPtr.Zero : value.Handle;
*raw_ptr = value == null ? IntPtr.Zero : g_object_ref (value.Handle);
}
}
}