bool result = gst_init_check (ref argc, ref argv_ptr, out error_ptr);
if (error_ptr != IntPtr.Zero) {
- 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));
+ throw new GLib.GException (error_ptr);
} else if (!result) {
throw new ApplicationException ("gst_init_check() failed: Reason unknown");
}
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;
+ [StructLayout (LayoutKind.Sequential) ]
+ internal struct GError {
+ uint domain_quark;
+ int code;
+ IntPtr message;
- return GLib.Marshaller.PtrToStringGFree (message);
+ public uint Domain {
+ get {
+ return domain_quark;
+ }
+ set {
+ domain_quark = value;
+ }
}
- public static void Free (IntPtr error) {
- if (error != IntPtr.Zero)
- g_error_free (error);
+ public int Code {
+ get {
+ return code;
+ }
+ set {
+ code = value;
+ }
}
- [DllImport ("gstreamersharpglue-0.10") ]
- static extern IntPtr gstsharp_g_error_get_message (IntPtr error);
+ public string Message {
+ get {
+ if (message == IntPtr.Zero)
+ return null;
+ return GLib.Marshaller.Utf8PtrToString (message);
+ }
+ set {
+ if (message != IntPtr.Zero)
+ GLib.Marshaller.Free (message);
+ message = GLib.Marshaller.StringToPtrGStrdup (value);
+ }
+ }
+
+ public void Unset () {
+ GLib.Marshaller.Free (message);
+ message = IntPtr.Zero;
+ code = 0;
+ domain_quark = 0;
+ }
[DllImport ("glib-2.0.dll") ]
static extern void g_error_free (IntPtr error);
[DllImport ("gstreamersharpglue-0.10.dll") ]
private static extern IntPtr gstsharp_g_type_from_instance (IntPtr o);
-[DllImport ("gstreamersharpglue-0.10.dll") ]
-private static extern IntPtr gstsharp_g_value_type (ref GLib.Value val);
[DllImport ("gstreamer-0.10.dll") ]
private static extern IntPtr gst_value_dup_mini_object (ref GLib.Value v);
[DllImport ("gstreamer-0.10.dll") ]
message.c \
bin.c \
structure.c \
- gerror.c \
gobject.c
nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c
+++ /dev/null
-#include <glib.h>
-
-gchar *
-gstsharp_g_error_get_message (GError * error)
-{
- if (error->message)
- return g_strdup (error->message);
-
- return NULL;
-}
return G_TYPE_FROM_INSTANCE (instance);
}
-GType
-gstsharp_g_value_type (const GValue * val)
-{
- return G_VALUE_TYPE (val);
-}
-#include <glib/gerror.h>
-#include <gst/gstmessage.h>
-#include <glib/gquark.h>
-
-gchar *
-gstsharp_message_parse_error (GstMessage * message)
-{
- GError *gerror;
- gchar *error;
-
- gst_message_parse_error (message, &gerror, NULL);
-
- error = g_strdup (gerror->message);
- g_error_free (gerror);
-
- return error;
-}
-
-GError *
-gstsharp_message_error_new ()
-{
- GQuark domain = g_quark_from_string ("test");
- return g_error_new (domain, 10, "test error");
-}