summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2013-04-21 18:28:52 +0100
committerTim-Philipp Müller <tim@centricular.net>2013-04-21 18:28:52 +0100
commitbd504e379b76b54e71ce22f2d09fb6ed8edaeca8 (patch)
tree953a21512815a0d6dd8ef772f58c66b13a83a28b
parentfc2b55919db4503d9b78de5d7e392b8b8ef6d2a8 (diff)
downloadgstreamer-plugins-bad-bd504e379b76b54e71ce22f2d09fb6ed8edaeca8.tar.gz
dvbbasebin: better error reporting
https://bugzilla.gnome.org/show_bug.cgi?id=678892
-rw-r--r--sys/dvb/dvbbasebin.c19
-rw-r--r--sys/dvb/gstdvb.c9
-rw-r--r--sys/dvb/gstdvbsrc.c7
-rw-r--r--sys/dvb/parsechannels.c30
-rw-r--r--sys/dvb/parsechannels.h5
5 files changed, 44 insertions, 26 deletions
diff --git a/sys/dvb/dvbbasebin.c b/sys/dvb/dvbbasebin.c
index 9a1bbd9fe..5361a0b35 100644
--- a/sys/dvb/dvbbasebin.c
+++ b/sys/dvb/dvbbasebin.c
@@ -920,6 +920,7 @@ dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
DvbBaseBin *dvbbasebin = GST_DVB_BASE_BIN (handler);
+ GError *err = NULL;
gchar *location;
location = gst_uri_get_location (uri);
@@ -927,7 +928,7 @@ dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
if (location == NULL)
goto no_location;
- if (!set_properties_for_channel (GST_ELEMENT (dvbbasebin), location))
+ if (!set_properties_for_channel (GST_ELEMENT (dvbbasebin), location, &err))
goto set_properties_failed;
/* FIXME: here is where we parse channels.conf */
@@ -935,18 +936,24 @@ dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
g_free (location);
return TRUE;
/* ERRORS */
+post_error_and_exit:
+ {
+ gst_element_message_full (GST_ELEMENT (dvbbasebin), GST_MESSAGE_ERROR,
+ err->domain, err->code, g_strdup (err->message), NULL, __FILE__,
+ GST_FUNCTION, __LINE__);
+ g_propagate_error (error, err);
+ return FALSE;
+ }
no_location:
{
- g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ g_set_error (&err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"No details to DVB URI");
- return FALSE;
+ goto post_error_and_exit;
}
set_properties_failed:
{
- g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
- "Could not set properties from DVB URI");
g_free (location);
- return FALSE;
+ goto post_error_and_exit;
}
}
diff --git a/sys/dvb/gstdvb.c b/sys/dvb/gstdvb.c
index 90a6cf74a..3942debfa 100644
--- a/sys/dvb/gstdvb.c
+++ b/sys/dvb/gstdvb.c
@@ -24,12 +24,21 @@
#include "config.h"
#endif
+#include <gst/gst-i18n-plugin.h>
+
#include "gstdvbsrc.h"
#include "dvbbasebin.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
+#ifdef ENABLE_NLS
+ GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
+ LOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
if (!gst_dvbsrc_plugin_init (plugin))
return FALSE;
diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c
index 057cb4d0d..f1aca863e 100644
--- a/sys/dvb/gstdvbsrc.c
+++ b/sys/dvb/gstdvbsrc.c
@@ -913,13 +913,6 @@ gst_dvbsrc_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gstdvbsrc_debug, "dvbsrc", 0, "DVB Source Element");
-#ifdef ENABLE_NLS
- GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
- LOCALEDIR);
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
return gst_element_register (plugin, "dvbsrc", GST_RANK_NONE,
GST_TYPE_DVBSRC);
}
diff --git a/sys/dvb/parsechannels.c b/sys/dvb/parsechannels.c
index ea6423aa0..4a29af77d 100644
--- a/sys/dvb/parsechannels.c
+++ b/sys/dvb/parsechannels.c
@@ -31,6 +31,8 @@
#include <string.h>
#include <gst/gst.h>
+#include <gst/gst-i18n-plugin.h>
+
#include "parsechannels.h"
GST_DEBUG_CATEGORY_EXTERN (dvb_base_bin_debug);
@@ -43,7 +45,8 @@ GST_DEBUG_CATEGORY_EXTERN (dvb_base_bin_debug);
/* this will do zap style channels.conf only for the moment */
static GHashTable *
-parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename)
+parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename,
+ GError ** error)
{
gchar *contents;
gchar **lines;
@@ -149,17 +152,21 @@ parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename)
open_fail:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Opening channels configuration file '%s' failed : %s", filename,
- err->message));
+ if (err->code == G_FILE_ERROR_NOENT) {
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
+ _("Couldn't find DVB channel configuration file"));
+ } else {
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
+ _("Couldn't load DVB channel configuration file: %s"), err->message);
+ }
g_clear_error (&err);
return NULL;
}
no_channels:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Channels configuration file doesn't contain any channels"));
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
+ _("DVB channel configuration file doesn't contain any channels"));
g_hash_table_unref (res);
return NULL;
}
@@ -182,7 +189,8 @@ destroy_channels_hash (GHashTable * channels)
}
gboolean
-set_properties_for_channel (GstElement * dvbbasebin, const gchar * channel_name)
+set_properties_for_channel (GstElement * dvbbasebin,
+ const gchar * channel_name, GError ** error)
{
gboolean ret = FALSE;
GHashTable *channels, *params;
@@ -195,7 +203,7 @@ set_properties_for_channel (GstElement * dvbbasebin, const gchar * channel_name)
filename = g_build_filename (g_get_user_config_dir (),
"gstreamer-" GST_API_VERSION, "dvb-channels.conf", NULL);
}
- channels = parse_channels_conf_from_file (dvbbasebin, filename);
+ channels = parse_channels_conf_from_file (dvbbasebin, filename, error);
g_free (filename);
if (!channels)
@@ -424,9 +432,9 @@ beach:
unknown_channel:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Couldn't find configuration properties for channel \"%s\"",
- channel_name));
+ /* FIXME: is channel name guaranteed to be ASCII or UTF-8? */
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
+ _("Couldn't find details for DVB channel %s"), channel_name);
destroy_channels_hash (channels);
return FALSE;
}
diff --git a/sys/dvb/parsechannels.h b/sys/dvb/parsechannels.h
index b5a493609..3e59fe72d 100644
--- a/sys/dvb/parsechannels.h
+++ b/sys/dvb/parsechannels.h
@@ -24,7 +24,8 @@
#ifndef PARSE_CHANNELS_H
#define PARSE_CHANNELS_H
-gboolean set_properties_for_channel(GstElement *dvbbasebin,
- const gchar* channel_name);
+gboolean set_properties_for_channel (GstElement * dvbbasebin,
+ const gchar * channel_name,
+ GError ** error);
#endif