diff --git a/gstreamer-sharp/Application.cs b/gstreamer-sharp/Application.cs index 817248037c..6a8bb78f8e 100644 --- a/gstreamer-sharp/Application.cs +++ b/gstreamer-sharp/Application.cs @@ -55,16 +55,23 @@ namespace Gst bool result = gst_init_check(ref argc, ref argv_ptr, out error_ptr); if(error_ptr != IntPtr.Zero) { - throw new ApplicationException("gst_init_check set error"); + string message = GError.GetMessage (error_ptr); + + if (message == String.Empty) + message = "Reason unknown"; + + GError.Free (error_ptr); + + throw new ApplicationException(String.Format ("gst_init_check() failed: {0}", message)); } else if(!result) { - throw new ApplicationException("gst_init_check failed, error not set"); + throw new ApplicationException("gst_init_check() failed: Reason unknown"); } } else { gst_init(ref argc, ref argv_ptr); } if(argv_ptr != argv.Handle) { - string init_call = check ? "gst_init_check" : "gst_init"; + string init_call = check ? "gst_init_check()" : "gst_init()"; throw new ApplicationException(init_call + " returned a new argv handle"); } @@ -76,7 +83,7 @@ namespace Gst Array.Copy(progargs, 1, args, 0, argc - 1); } } - + [DllImport("gstreamer-0.10")] private static extern void gst_init(ref int argc, ref IntPtr argv); diff --git a/gstreamer-sharp/GError.cs b/gstreamer-sharp/GError.cs new file mode 100644 index 0000000000..efaa13f367 --- /dev/null +++ b/gstreamer-sharp/GError.cs @@ -0,0 +1,37 @@ +// +// Copyright (c) 2009 Sebastian Dröge +// +// This class implements some helper functions to handle GError +// + +using System; +using System.Runtime.InteropServices; + +namespace Gst { + internal static class GError + { + public static string GetMessage (IntPtr error) + { + if (error == IntPtr.Zero) + return String.Empty; + + IntPtr message = gstsharp_g_error_get_message (error); + if (message == IntPtr.Zero) + return String.Empty; + + return GLib.Marshaller.PtrToStringGFree (message); + } + + public static void Free (IntPtr error) + { + if (error != IntPtr.Zero) + g_error_free (error); + } + + [DllImport("gstreamersharpglue-0.10")] + static extern IntPtr gstsharp_g_error_get_message (IntPtr error); + + [DllImport("glib-2.0.dll")] + static extern void g_error_free (IntPtr error); + } +} diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index 4b00017d84..7bfbcdad71 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -112,6 +112,8 @@ GstPad + + 1 1 @@ -120,6 +122,8 @@ ObjectFlags.Last << 1 ObjectFlags.Last << 8 + + ret_val 1 1 @@ -192,7 +196,7 @@ ObjectFlags.Last << 0 ObjectFlags.Last << 4 - 1 + 1 1 1 diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index 446d3cd78d..cc7f5c62d4 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -43,6 +43,7 @@ sources = \ Version.cs \ AssemblyInfo.cs \ CommonTags.cs \ + GError.cs \ plugins-base/PlayBin.cs \ plugins-base/DecodeBin.cs \ plugins-base/TypeFindElement.cs diff --git a/gstreamer-sharp/glue/Makefile.am b/gstreamer-sharp/glue/Makefile.am index 60cecc35d5..6321e17f8f 100644 --- a/gstreamer-sharp/glue/Makefile.am +++ b/gstreamer-sharp/glue/Makefile.am @@ -6,7 +6,8 @@ libgstreamersharpglue_0_10_la_SOURCES = \ message.c \ miniobject.c \ bin.c \ - dynamicsignal.c + dynamicsignal.c \ + gerror.c nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c diff --git a/gstreamer-sharp/glue/gerror.c b/gstreamer-sharp/glue/gerror.c new file mode 100644 index 0000000000..d5f64fb573 --- /dev/null +++ b/gstreamer-sharp/glue/gerror.c @@ -0,0 +1,11 @@ +#include + +gchar * +gstsharp_g_error_get_message (GError * error) +{ + if (error->message) + return g_strdup (error->message); + + return NULL; +} +