dvbbasebin: Emit an error when we fail reading the channels file

Conflicts:

	sys/dvb/dvbbasebin.c
This commit is contained in:
Edward Hervey 2012-06-19 10:22:50 +02:00 committed by Sebastian Dröge
parent 1ee6a35949
commit 068598e237
3 changed files with 85 additions and 76 deletions

View File

@ -987,7 +987,7 @@ dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
if (location == NULL) if (location == NULL)
goto no_location; goto no_location;
if (!set_properties_for_channel (G_OBJECT (dvbbasebin), location)) if (!set_properties_for_channel (GST_ELEMENT (dvbbasebin), location))
goto set_properties_failed; goto set_properties_failed;
/* FIXME: here is where we parse channels.conf */ /* FIXME: here is where we parse channels.conf */

View File

@ -30,8 +30,8 @@
#include "parsechannels.h" #include "parsechannels.h"
/* this will do zap style channels.conf only for the moment*/ /* this will do zap style channels.conf only for the moment*/
GHashTable * static GHashTable *
parse_channels_conf_from_file (const gchar * filename) parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename)
{ {
gchar *contents; gchar *contents;
gchar **lines; gchar **lines;
@ -48,9 +48,12 @@ parse_channels_conf_from_file (const gchar * filename)
"modulation" "modulation"
}; };
int i; int i;
GHashTable *res = NULL; GHashTable *res;
GError *err = NULL;
if (!g_file_get_contents (filename, &contents, NULL, &err))
goto open_fail;
if (g_file_get_contents (filename, &contents, NULL, NULL)) {
lines = g_strsplit (contents, "\n", 0); lines = g_strsplit (contents, "\n", 0);
res = g_hash_table_new (g_str_hash, g_str_equal); res = g_hash_table_new (g_str_hash, g_str_equal);
@ -69,8 +72,7 @@ parse_channels_conf_from_file (const gchar * filename)
/* satellite */ /* satellite */
int j; int j;
g_hash_table_insert (params, g_strdup ("type"), g_hash_table_insert (params, g_strdup ("type"), g_strdup ("satellite"));
g_strdup ("satellite"));
for (j = 2; j <= 4; j++) { for (j = 2; j <= 4; j++) {
g_hash_table_insert (params, g_strdup (satellite[j - 2]), g_hash_table_insert (params, g_strdup (satellite[j - 2]),
g_strdup (fields[j])); g_strdup (fields[j]));
@ -124,9 +126,17 @@ parse_channels_conf_from_file (const gchar * filename)
} }
g_strfreev (lines); g_strfreev (lines);
g_free (contents); g_free (contents);
} else
GST_WARNING ("Couldn't open file");
return res; return res;
open_fail:
{
GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
("Opening channels configuration file failed : %s", filename,
err->message));
g_clear_error (&err);
return NULL;
}
} }
static gboolean static gboolean
@ -146,7 +156,7 @@ destroy_channels_hash (GHashTable * channels)
} }
gboolean gboolean
set_properties_for_channel (GObject * dvbbasebin, const gchar * channel_name) set_properties_for_channel (GstElement * dvbbasebin, const gchar * channel_name)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
GHashTable *channels; GHashTable *channels;
@ -160,7 +170,7 @@ set_properties_for_channel (GObject * dvbbasebin, const gchar * channel_name)
filename = g_strdup_printf ("%s/gstreamer-%d.%d/dvb-channels.conf", filename = g_strdup_printf ("%s/gstreamer-%d.%d/dvb-channels.conf",
g_get_user_config_dir (), major, minor); g_get_user_config_dir (), major, minor);
} }
channels = parse_channels_conf_from_file (filename); channels = parse_channels_conf_from_file (dvbbasebin, filename);
g_free (filename); g_free (filename);
if (channels) { if (channels) {

View File

@ -24,8 +24,7 @@
#ifndef PARSE_CHANNELS_H #ifndef PARSE_CHANNELS_H
#define PARSE_CHANNELS_H #define PARSE_CHANNELS_H
GHashTable* parse_channels_conf_from_file(const gchar* filename); gboolean set_properties_for_channel(GstElement *dvbbasebin,
gboolean set_properties_for_channel(GObject *dvbbasebin,
const gchar* channel_name); const gchar* channel_name);
#endif #endif