mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 06:08:14 +00:00
Print reason if InitCheck() failed and introduce GError helper functions
This commit is contained in:
parent
9225f847a9
commit
dba4fc945c
6 changed files with 67 additions and 6 deletions
|
@ -55,16 +55,23 @@ namespace Gst
|
||||||
bool result = gst_init_check(ref argc, ref argv_ptr, out error_ptr);
|
bool result = gst_init_check(ref argc, ref argv_ptr, out error_ptr);
|
||||||
|
|
||||||
if(error_ptr != IntPtr.Zero) {
|
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) {
|
} else if(!result) {
|
||||||
throw new ApplicationException("gst_init_check failed, error not set");
|
throw new ApplicationException("gst_init_check() failed: Reason unknown");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gst_init(ref argc, ref argv_ptr);
|
gst_init(ref argc, ref argv_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(argv_ptr != argv.Handle) {
|
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");
|
throw new ApplicationException(init_call + " returned a new argv handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +83,7 @@ namespace Gst
|
||||||
Array.Copy(progargs, 1, args, 0, argc - 1);
|
Array.Copy(progargs, 1, args, 0, argc - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gstreamer-0.10")]
|
[DllImport("gstreamer-0.10")]
|
||||||
private static extern void gst_init(ref int argc, ref IntPtr argv);
|
private static extern void gst_init(ref int argc, ref IntPtr argv);
|
||||||
|
|
||||||
|
|
37
gstreamer-sharp/GError.cs
Normal file
37
gstreamer-sharp/GError.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -112,6 +112,8 @@
|
||||||
|
|
||||||
<attr path="/api/namespace/object[@name='GhostPad']" name="parent">GstPad</attr>
|
<attr path="/api/namespace/object[@name='GhostPad']" name="parent">GstPad</attr>
|
||||||
|
|
||||||
|
<remove-node path="/api/namespace/class[@name='Global']/method[@cname='gst_version_string']" />
|
||||||
|
|
||||||
<attr path="/api/namespace/object[@name='Index']/field[@cname='resolver']" name="hidden">1</attr>
|
<attr path="/api/namespace/object[@name='Index']/field[@cname='resolver']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/object[@name='Index']/property[@cname='resolver']" name="hidden">1</attr>
|
<attr path="/api/namespace/object[@name='Index']/property[@cname='resolver']" name="hidden">1</attr>
|
||||||
|
|
||||||
|
@ -120,6 +122,8 @@
|
||||||
<attr path="/api/namespace/enum[@name='IndexFlags']/member[@cname='GST_INDEX_READABLE']" name="value">ObjectFlags.Last << 1</attr>
|
<attr path="/api/namespace/enum[@name='IndexFlags']/member[@cname='GST_INDEX_READABLE']" name="value">ObjectFlags.Last << 1</attr>
|
||||||
<attr path="/api/namespace/enum[@name='IndexFlags']/member[@cname='GST_INDEX_FLAG_LAST']" name="value">ObjectFlags.Last << 8</attr>
|
<attr path="/api/namespace/enum[@name='IndexFlags']/member[@cname='GST_INDEX_FLAG_LAST']" name="value">ObjectFlags.Last << 8</attr>
|
||||||
|
|
||||||
|
<remove-node path="/api/namespace/class[@name='Init']" />
|
||||||
|
|
||||||
<attr path="/api/namespace/struct[@name='Iterator']/method[@name='Fold']/parameters/*[@name='ret']" name="name">ret_val</attr>
|
<attr path="/api/namespace/struct[@name='Iterator']/method[@name='Fold']/parameters/*[@name='ret']" name="name">ret_val</attr>
|
||||||
<attr path="/api/namespace/struct[@name='Iterator']/field[@name='Next']" name="hidden">1</attr>
|
<attr path="/api/namespace/struct[@name='Iterator']/field[@name='Next']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/struct[@name='Iterator']/field[@name='Item']" name="hidden">1</attr>
|
<attr path="/api/namespace/struct[@name='Iterator']/field[@name='Item']" name="hidden">1</attr>
|
||||||
|
@ -192,7 +196,7 @@
|
||||||
<attr path="/api/namespace/enum[@name='PadTemplateFlags']/member[@cname='GST_PAD_TEMPLATE_FIXED']" name="value">ObjectFlags.Last << 0</attr>
|
<attr path="/api/namespace/enum[@name='PadTemplateFlags']/member[@cname='GST_PAD_TEMPLATE_FIXED']" name="value">ObjectFlags.Last << 0</attr>
|
||||||
<attr path="/api/namespace/enum[@name='PadTemplateFlags']/member[@cname='GST_PAD_TEMPLATE_FLAG_LAST']" name="value">ObjectFlags.Last << 4</attr>
|
<attr path="/api/namespace/enum[@name='PadTemplateFlags']/member[@cname='GST_PAD_TEMPLATE_FLAG_LAST']" name="value">ObjectFlags.Last << 4</attr>
|
||||||
|
|
||||||
<attr path="/api/namespace/class[@name='Param']" name="hidden">1</attr>
|
<remove-node path="/api/namespace/class[@name='Param']" name="hidden">1</attr>
|
||||||
|
|
||||||
<attr path="/api/namespace/object[@name='ParamSpecFraction']" name="hidden">1</attr>
|
<attr path="/api/namespace/object[@name='ParamSpecFraction']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/object[@name='ParamSpecMiniObject']" name="hidden">1</attr>
|
<attr path="/api/namespace/object[@name='ParamSpecMiniObject']" name="hidden">1</attr>
|
||||||
|
|
|
@ -43,6 +43,7 @@ sources = \
|
||||||
Version.cs \
|
Version.cs \
|
||||||
AssemblyInfo.cs \
|
AssemblyInfo.cs \
|
||||||
CommonTags.cs \
|
CommonTags.cs \
|
||||||
|
GError.cs \
|
||||||
plugins-base/PlayBin.cs \
|
plugins-base/PlayBin.cs \
|
||||||
plugins-base/DecodeBin.cs \
|
plugins-base/DecodeBin.cs \
|
||||||
plugins-base/TypeFindElement.cs
|
plugins-base/TypeFindElement.cs
|
||||||
|
|
|
@ -6,7 +6,8 @@ libgstreamersharpglue_0_10_la_SOURCES = \
|
||||||
message.c \
|
message.c \
|
||||||
miniobject.c \
|
miniobject.c \
|
||||||
bin.c \
|
bin.c \
|
||||||
dynamicsignal.c
|
dynamicsignal.c \
|
||||||
|
gerror.c
|
||||||
|
|
||||||
nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c
|
nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c
|
||||||
|
|
||||||
|
|
11
gstreamer-sharp/glue/gerror.c
Normal file
11
gstreamer-sharp/glue/gerror.c
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gstsharp_g_error_get_message (GError * error)
|
||||||
|
{
|
||||||
|
if (error->message)
|
||||||
|
return g_strdup (error->message);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue