[farsight2/master] Return errors properly when there is problem while loading a transmitter plugin
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:19:27 PST 2008
---
gst-libs/gst/farsight/fs-plugin.c | 26 +++++++++++++++++++++-----
gst-libs/gst/farsight/fs-plugin.h | 1 +
gst-libs/gst/farsight/fs-transmitter.c | 5 ++++-
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/gst-libs/gst/farsight/fs-plugin.c b/gst-libs/gst/farsight/fs-plugin.c
index 84819e2..6bdbbb2 100644
--- a/gst-libs/gst/farsight/fs-plugin.c
+++ b/gst-libs/gst/farsight/fs-plugin.c
@@ -31,6 +31,8 @@
#include "fs-plugin.h"
+#include <gst/farsight/fs-stream.h>
+
#include <string.h>
/**
@@ -296,27 +298,41 @@ fs_plugin_get_by_name (const gchar * name, const gchar * type_suffix)
GObject *
fs_plugin_create_valist (const gchar *name, const gchar *type_suffix,
- const gchar *first_property_name, va_list var_args)
+ GError **error, const gchar *first_property_name, va_list var_args)
{
GObject *object;
FsPlugin *plugin;
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (type_suffix != NULL, NULL);
+ if (name == NULL) {
+ g_set_error (error, FS_STREAM_ERROR, FS_STREAM_ERROR_INVALID_ARGUMENTS,
+ "You need to pass a name");
+ return NULL;
+ }
+ if (type_suffix == NULL) {
+ g_set_error (error, FS_STREAM_ERROR, FS_STREAM_ERROR_INVALID_ARGUMENTS,
+ "You need to pass a type suffix");
+ return NULL;
+ }
plugin = fs_plugin_get_by_name (name, type_suffix);
if (!plugin) {
plugin = g_object_new (FS_TYPE_PLUGIN, NULL);
- if (!plugin)
+ if (!plugin) {
+ g_set_error (error, FS_STREAM_ERROR, FS_STREAM_ERROR_CONSTRUCTION,
+ "Could not create a fsplugin object");
return NULL;
+ }
plugin->name = g_strdup_printf ("%s-%s",name,type_suffix);
g_type_module_set_name (G_TYPE_MODULE (plugin), plugin->name);
plugins = g_list_append(plugins, plugin);
}
- if (!g_type_module_use (G_TYPE_MODULE (plugin)))
+ if (!g_type_module_use (G_TYPE_MODULE (plugin))) {
+ g_set_error (error, FS_STREAM_ERROR, FS_STREAM_ERROR_CONSTRUCTION,
+ "Could not load the %s-%s transmitter plugin", name, type_suffix);
return NULL;
+ }
object = g_object_new_valist (plugin->type, first_property_name, var_args);
diff --git a/gst-libs/gst/farsight/fs-plugin.h b/gst-libs/gst/farsight/fs-plugin.h
index 20820c7..8b6a831 100644
--- a/gst-libs/gst/farsight/fs-plugin.h
+++ b/gst-libs/gst/farsight/fs-plugin.h
@@ -85,6 +85,7 @@ GType fs_plugin_get_type (void);
GObject *fs_plugin_create_valist (const gchar *name,
const gchar *type_suffix,
+ GError **error,
const gchar *first_property_name,
va_list var_args);
diff --git a/gst-libs/gst/farsight/fs-transmitter.c b/gst-libs/gst/farsight/fs-transmitter.c
index 1793942..dcd5a28 100644
--- a/gst-libs/gst/farsight/fs-transmitter.c
+++ b/gst-libs/gst/farsight/fs-transmitter.c
@@ -287,9 +287,12 @@ fs_transmitter_new (gchar *type, GError **error)
g_return_val_if_fail (type != NULL, NULL);
- self = FS_TRANSMITTER(fs_plugin_create_valist(type, "transmitter",
+ self = FS_TRANSMITTER(fs_plugin_create_valist(type, "transmitter", error,
NULL, NULL));
+ if (!self)
+ return NULL;
+
if (self->construction_error) {
*error = self->construction_error;
g_object_unref (self);
--
1.5.6.5
More information about the farsight-commits
mailing list