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

@ -987,7 +987,7 @@ dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
if (location == NULL)
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;
/* FIXME: here is where we parse channels.conf */

@ -30,8 +30,8 @@
#include "parsechannels.h"
/* this will do zap style channels.conf only for the moment*/
GHashTable *
parse_channels_conf_from_file (const gchar * filename)
static GHashTable *
parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename)
{
gchar *contents;
gchar **lines;
@ -48,9 +48,12 @@ parse_channels_conf_from_file (const gchar * filename)
"modulation"
};
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);
res = g_hash_table_new (g_str_hash, g_str_equal);
@ -69,8 +72,7 @@ parse_channels_conf_from_file (const gchar * filename)
/* satellite */
int j;
g_hash_table_insert (params, g_strdup ("type"),
g_strdup ("satellite"));
g_hash_table_insert (params, g_strdup ("type"), g_strdup ("satellite"));
for (j = 2; j <= 4; j++) {
g_hash_table_insert (params, g_strdup (satellite[j - 2]),
g_strdup (fields[j]));
@ -124,9 +126,17 @@ parse_channels_conf_from_file (const gchar * filename)
}
g_strfreev (lines);
g_free (contents);
} else
GST_WARNING ("Couldn't open file");
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
@ -146,7 +156,7 @@ destroy_channels_hash (GHashTable * channels)
}
gboolean
set_properties_for_channel (GObject * dvbbasebin, const gchar * channel_name)
set_properties_for_channel (GstElement * dvbbasebin, const gchar * channel_name)
{
gboolean ret = FALSE;
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",
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);
if (channels) {

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