From 25a150674124189b8b83bde2d72f826ad08cd446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 16 Aug 2011 17:07:43 +0200 Subject: [PATCH] Allow null as src argument in the Gst.Message constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spotted by Chow Loong Jin  --- gstreamer-sharp/Message.custom | 70 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/gstreamer-sharp/Message.custom b/gstreamer-sharp/Message.custom index 893c0749eb..dbfcf0f64f 100644 --- a/gstreamer-sharp/Message.custom +++ b/gstreamer-sharp/Message.custom @@ -118,7 +118,7 @@ public Gst.Structure Structure { static extern IntPtr gst_message_new_eos (IntPtr src); public static Message NewEos (Gst.Object src) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_eos (src.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_eos (src != null ? src.Handle : IntPtr.Zero), true); return msg; } @@ -154,7 +154,7 @@ public static Message NewError (Gst.Object src, Gst.CoreError error, string mess IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -176,7 +176,7 @@ public static Message NewError (Gst.Object src, Gst.StreamError error, string me IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -198,7 +198,7 @@ public static Message NewError (Gst.Object src, Gst.LibraryError error, string m IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -219,7 +219,7 @@ public static Message NewError (Gst.Object src, Gst.ResourceError error, string IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_error (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -292,7 +292,7 @@ public static Message NewWarning (Gst.Object src, Gst.CoreError error, string me IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -314,7 +314,7 @@ public static Message NewWarning (Gst.Object src, Gst.StreamError error, string IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -336,7 +336,7 @@ public static Message NewWarning (Gst.Object src, Gst.LibraryError error, string IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -358,7 +358,7 @@ public static Message NewWarning (Gst.Object src, Gst.ResourceError error, strin IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_warning (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -431,7 +431,7 @@ public static Message NewInfo (Gst.Object src, Gst.CoreError error, string messa IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -453,7 +453,7 @@ public static Message NewInfo (Gst.Object src, Gst.StreamError error, string mes IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -475,7 +475,7 @@ public static Message NewInfo (Gst.Object src, Gst.LibraryError error, string me IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -497,7 +497,7 @@ public static Message NewInfo (Gst.Object src, Gst.ResourceError error, string m IntPtr raw_ptr = (debug == null) ? IntPtr.Zero : Gst.GLib.Marshaller.StringToPtrGStrdup (debug); - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src.Handle, ref err, raw_ptr), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_info (src != null ? src.Handle : IntPtr.Zero, ref err, raw_ptr), true); Gst.GLib.Marshaller.Free (raw_ptr); err.Unset (); @@ -568,13 +568,13 @@ static extern IntPtr gst_message_new_tag_full (IntPtr src, IntPtr pad, IntPtr ta static extern IntPtr gst_tag_list_copy (IntPtr handle); public static Message NewTag (Gst.Object src, TagList tags) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_tag (src.Handle, gst_tag_list_copy (tags.Handle)), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_tag (src != null ? src.Handle : IntPtr.Zero, gst_tag_list_copy (tags.Handle)), true); return msg; } public static Message NewTag (Gst.Object src, Gst.Pad pad, TagList tags) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_tag_full (src.Handle, pad.Handle, gst_tag_list_copy (tags.Handle)), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_tag_full (src != null ? src.Handle : IntPtr.Zero, pad.Handle, gst_tag_list_copy (tags.Handle)), true); return msg; } @@ -620,7 +620,7 @@ public void ParseTag (out Gst.Pad pad, out TagList tags) { static extern IntPtr gst_message_new_buffering (IntPtr src, int percent); public static Message NewBuffering (Gst.Object src, int percent) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_buffering (src.Handle, percent), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_buffering (src != null ? src.Handle : IntPtr.Zero, percent), true); return msg; } @@ -661,7 +661,7 @@ public void ParseBufferingStats (out Gst.BufferingMode mode, out int avg_in, out static extern IntPtr gst_message_new_state_changed (IntPtr src, State oldstate, State newstate, State pendingstate); public static Message NewStateChanged (Gst.Object src, State oldstate, State newstate, State pendingstate) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_state_changed (src.Handle, oldstate, newstate, pendingstate), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_state_changed (src != null ? src.Handle : IntPtr.Zero, oldstate, newstate, pendingstate), true); return msg; } @@ -680,7 +680,7 @@ public void ParseStateChanged (out State oldstate, out State newstate, out State static extern IntPtr gst_message_new_state_dirty (IntPtr src); public static Message NewStateDirty (Gst.Object src) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_state_dirty (src.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_state_dirty (src != null ? src.Handle : IntPtr.Zero), true); return msg; } @@ -688,7 +688,7 @@ public static Message NewStateDirty (Gst.Object src) { static extern IntPtr gst_message_new_clock_provide (IntPtr src, IntPtr clock, bool ready); public static Message NewClockProvide (Gst.Object src, Gst.Clock clock, bool ready) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_clock_provide (src.Handle, clock.Handle, ready), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_clock_provide (src != null ? src.Handle : IntPtr.Zero, clock.Handle, ready), true); return msg; } @@ -711,7 +711,7 @@ public void ParseClockProvide (out Gst.Clock clock, out bool ready) { static extern IntPtr gst_message_new_clock_lost (IntPtr src, IntPtr clock); public static Message NewClockLost (Gst.Object src, Gst.Clock clock) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_clock_lost (src.Handle, clock.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_clock_lost (src != null ? src.Handle : IntPtr.Zero, clock.Handle), true); return msg; } @@ -734,7 +734,7 @@ public void ParseClockLost (out Gst.Clock clock) { static extern IntPtr gst_message_new_new_clock (IntPtr src, IntPtr clock); public static Message NewNewClock (Gst.Object src, Gst.Clock clock) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_new_clock (src.Handle, clock.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_new_clock (src != null ? src.Handle : IntPtr.Zero, clock.Handle), true); return msg; } @@ -757,7 +757,7 @@ public void ParseNewClock (out Gst.Clock clock) { static extern IntPtr gst_message_new_application (IntPtr src, IntPtr structure); public static Message NewApplication (Gst.Object src, Gst.Structure structure) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_application (src.Handle, (structure != null) ? structure.Handle : IntPtr.Zero), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_application (src != null ? src.Handle : IntPtr.Zero, (structure != null) ? structure.Handle : IntPtr.Zero), true); msg.cached_structure = structure; structure.FreeNative = false; @@ -768,7 +768,7 @@ public static Message NewApplication (Gst.Object src, Gst.Structure structure) { static extern IntPtr gst_message_new_element (IntPtr src, IntPtr structure); public static Message NewElement (Gst.Object src, Gst.Structure structure) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_element (src.Handle, (structure != null) ? structure.Handle : IntPtr.Zero), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_element (src != null ? src.Handle : IntPtr.Zero, (structure != null) ? structure.Handle : IntPtr.Zero), true); msg.cached_structure = structure; structure.FreeNative = false; @@ -779,7 +779,7 @@ public static Message NewElement (Gst.Object src, Gst.Structure structure) { static extern IntPtr gst_message_new_custom (Gst.MessageType type, IntPtr src, IntPtr structure); public static Message NewCustom (Gst.MessageType type, Gst.Object src, Gst.Structure structure) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_custom (type, src.Handle, (structure != null) ? structure.Handle : IntPtr.Zero), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_custom (type, src != null ? src.Handle : IntPtr.Zero, (structure != null) ? structure.Handle : IntPtr.Zero), true); msg.cached_structure = structure; structure.FreeNative = false; @@ -790,7 +790,7 @@ public static Message NewCustom (Gst.MessageType type, Gst.Object src, Gst.Struc static extern IntPtr gst_message_new_segment_start (IntPtr src, Gst.Format format, long position); public static Message NewSegmentStart (Gst.Object src, Gst.Format format, long position) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_segment_start (src.Handle, format, position), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_segment_start (src != null ? src.Handle : IntPtr.Zero, format, position), true); return msg; } @@ -809,7 +809,7 @@ public void ParseSegmentStart (out Gst.Format format, out long position) { static extern IntPtr gst_message_new_segment_done (IntPtr src, Gst.Format format, long position); public static Message NewSegmentDone (Gst.Object src, Gst.Format format, long position) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_segment_done (src.Handle, format, position), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_segment_done (src != null ? src.Handle : IntPtr.Zero, format, position), true); return msg; } @@ -828,7 +828,7 @@ public void ParseSegmentDone (out Gst.Format format, out long position) { static extern IntPtr gst_message_new_duration (IntPtr src, Gst.Format format, long duration); public static Message NewDuration (Gst.Object src, Gst.Format format, long duration) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_duration (src.Handle, format, duration), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_duration (src != null ? src.Handle : IntPtr.Zero, format, duration), true); return msg; } @@ -847,7 +847,7 @@ public void ParseDuration (out Gst.Format format, out long duration) { static extern IntPtr gst_message_new_latency (IntPtr src); public static Message NewLatency (Gst.Object src) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_latency (src.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_latency (src != null ? src.Handle : IntPtr.Zero), true); return msg; } @@ -856,7 +856,7 @@ public static Message NewLatency (Gst.Object src) { static extern IntPtr gst_message_new_async_start (IntPtr src, bool new_base_time); public static Message NewAsyncStart (Gst.Object src, bool new_base_time) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_async_start (src.Handle, new_base_time), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_async_start (src != null ? src.Handle : IntPtr.Zero, new_base_time), true); return msg; } @@ -875,7 +875,7 @@ public void ParseAsyncStart (out bool new_base_time) { static extern IntPtr gst_message_new_async_done (IntPtr src); public static Message NewAsyncDone (Gst.Object src) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_async_done (src.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_async_done (src != null ? src.Handle : IntPtr.Zero), true); return msg; } @@ -884,7 +884,7 @@ public static Message NewAsyncDone (Gst.Object src) { static extern IntPtr gst_message_new_structure_change (IntPtr src, StructureChangeType type, IntPtr owner, bool busy); public static Message NewStructureChange (Gst.Object src, StructureChangeType type, Gst.Element owner, bool busy) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_structure_change (src.Handle, type, owner.Handle, busy), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_structure_change (src != null ? src.Handle : IntPtr.Zero, type, owner.Handle, busy), true); return msg; } @@ -910,7 +910,7 @@ static Message () { static extern IntPtr gst_message_new_step_done (IntPtr src, Gst.Format format, ulong amount, double rate, bool flush, bool intermediate, ulong duration, bool eos); public static Message NewStepDone (Gst.Object src, Gst.Format format, ulong amount, double rate, bool flush, bool intermediate, ulong duration, bool eos) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_step_done (src.Handle, format, amount, rate, flush, intermediate, duration, eos), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_step_done (src != null ? src.Handle : IntPtr.Zero, format, amount, rate, flush, intermediate, duration, eos), true); return msg; } @@ -929,7 +929,7 @@ public void ParseStepDone (out Gst.Format format, out ulong amount, out double r static extern IntPtr gst_message_new_step_start (IntPtr src, bool active, Gst.Format format, ulong amount, double rate, bool flush, bool intermediate); public static Message NewStepDone (Gst.Object src, bool active, Gst.Format format, ulong amount, double rate, bool flush, bool intermediate) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_step_start (src.Handle, active, format, amount, rate, flush, intermediate), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_step_start (src != null ? src.Handle : IntPtr.Zero, active, format, amount, rate, flush, intermediate), true); return msg; } @@ -948,7 +948,7 @@ public void ParseStepStart (out bool active, out Gst.Format format, out ulong am static extern IntPtr gst_message_new_stream_status (IntPtr src, StreamStatusType type, IntPtr owner); public static Message NewStreamStatus (Gst.Object src, StreamStatusType type, Gst.Element owner) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_stream_status (src.Handle, type, owner.Handle), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_stream_status (src != null ? src.Handle : IntPtr.Zero, type, owner.Handle), true); return msg; } @@ -970,7 +970,7 @@ public void ParseStreamStatus (out StreamStatusType type, out Gst.Element owner) static extern IntPtr gst_message_new_request_state (IntPtr src, Gst.State state); public static Message NewRequestState (Gst.Object src, Gst.State state) { - Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_request_state (src.Handle, state), true); + Message msg = (Message) Gst.MiniObject.GetObject (gst_message_new_request_state (src != null ? src.Handle : IntPtr.Zero, state), true); return msg; }