totem r5493 - in trunk: . src src/backend
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: totem r5493 - in trunk: . src src/backend
- Date: Fri, 27 Jun 2008 16:37:00 +0000 (UTC)
Author: hadess
Date: Fri Jun 27 16:36:59 2008
New Revision: 5493
URL: http://svn.gnome.org/viewvc/totem?rev=5493&view=rev
Log:
2008-06-27 Bastien Nocera <hadess hadess net>
* src/backend/bacon-video-widget.h: Kill bacon_video_widget_can_play
and get errors directly from _get_mrls().
* src/backend/bacon-video-widget-gst-0.10.c
(bacon_video_widget_get_channels_file),
(bacon_video_widget_get_dvd_mrls),
(bacon_video_widget_get_dvb_mrls), (bacon_video_widget_get_mrls):
* src/backend/bacon-video-widget-xine.c (xine_try_error),
(bacon_video_widget_get_mrls):
Better errors when a device isn't present, channels file is missing,
or the device is busy
* src/totem.c (totem_action_load_media): Changes for the above
(Closes: #539319)
Modified:
trunk/ChangeLog
trunk/src/backend/bacon-video-widget-gst-0.10.c
trunk/src/backend/bacon-video-widget-xine.c
trunk/src/backend/bacon-video-widget.h
trunk/src/totem.c
Modified: trunk/src/backend/bacon-video-widget-gst-0.10.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-gst-0.10.c (original)
+++ trunk/src/backend/bacon-video-widget-gst-0.10.c Fri Jun 27 16:36:59 2008
@@ -3907,81 +3907,23 @@
gchar *filename;
filename = g_strdup(g_getenv("GST_DVB_CHANNELS_CONF"));
- if (filename == NULL) {
+ if (filename == NULL || g_file_test (filename, G_FILE_TEST_IS_REGULAR) == FALSE) {
gchar *directory;
-
guint major, minor, micro, nano;
+
+ g_free (filename);
gst_version(&major, &minor, µ, &nano);
directory = g_strdup_printf (".gstreamer-%d.%d", major, minor);
filename = g_build_filename (g_get_home_dir (), directory, "dvb-channels.conf", NULL);
g_free (directory);
- }
-
- return filename;
-}
-
-BaconVideoWidgetCanPlayStatus
-bacon_video_widget_can_play (BaconVideoWidget * bvw, TotemDiscMediaType type)
-{
- BaconVideoWidgetCanPlayStatus res;
-
- g_return_val_if_fail (bvw != NULL, FALSE);
- g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
- g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
-
- switch (type) {
- case MEDIA_TYPE_VCD:
- res = BVW_CAN_PLAY_SUCCESS;
- break;
- case MEDIA_TYPE_DVD: {
- if (!gst_default_registry_check_feature_version ("dvdreadsrc", 0, 10, 0)) {
- GST_DEBUG ("Missing dvdreadsrc");
- res = BVW_CAN_PLAY_MISSING_PLUGINS;
- } else if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
- !gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
- GST_DEBUG ("flupsdemux not new enough for DVD playback");
- res = BVW_CAN_PLAY_MISSING_PLUGINS;
- } else {
- res = BVW_CAN_PLAY_SUCCESS;
- }
- break;
- }
- case MEDIA_TYPE_DVB: {
- gchar *filename;
-
- /* FIXME: change to 0,10,6 once gst-plugins-bad 0.10.6 has been released */
- if (!gst_default_registry_check_feature_version ("dvbbasebin", 0, 10, 0) ||
- !gst_default_registry_check_feature_version ("mpegtsparse", 0, 10, 0) ||
- !gst_default_registry_check_feature_version ("dvbsrc", 0, 10, 0)) {
- GST_DEBUG ("Missing one or all of: dvbsrc, dvbbasebin, mpegtsparse");
- res = BVW_CAN_PLAY_MISSING_PLUGINS;
- break;
- }
- if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
- !gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
- GST_DEBUG ("flupsdemux not new enough for DVB playback");
- res = BVW_CAN_PLAY_MISSING_PLUGINS;
- break;
- }
- filename = bacon_video_widget_get_channels_file ();
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- res = BVW_CAN_PLAY_SUCCESS;
- } else {
- GST_DEBUG ("no channels file '%s'", filename);
- res = BVW_CAN_PLAY_MISSING_CHANNELS;
- }
- g_free(filename);
- break;
+ if (g_file_test (filename, G_FILE_TEST_IS_REGULAR) == FALSE) {
+ g_free (filename);
+ filename = g_build_filename (g_get_home_dir (), ".xine", "channels.conf", NULL);
}
- case MEDIA_TYPE_CDDA:
- default:
- res = BVW_CAN_PLAY_UNSUPPORTED;
- break;
}
- GST_DEBUG ("type=%d, can_play=%d", type, res);
- return res;
+ return filename;
}
static char
@@ -4042,9 +3984,113 @@
return adapter_type;
}
+static gchar **
+bacon_video_widget_get_dvd_mrls (const char *device)
+{
+ GstFormat fmt;
+ GstElement *element;
+ gint64 num_titles, i;
+ GPtrArray *array;
+
+ element = gst_element_factory_make ("dvdreadsrc", "test_dvdsrc");
+ if (element == NULL)
+ return NULL;
+ /* We need to get the format after instantiating dvdreadsrc, as
+ * the nick is registered in that class init */
+ fmt = gst_format_get_by_nick ("title");
+ g_object_set (element, "device", device, NULL);
+ if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
+ GST_DEBUG ("Couldn't change the state to PAUSED");
+ gst_object_unref (element);
+ return NULL;
+ }
+ if (gst_element_query_duration (element, &fmt, &num_titles) == FALSE) {
+ GST_DEBUG ("Couldn't query the \"duration\" (number of titles)");
+ gst_element_set_state (element, GST_STATE_NULL);
+ gst_object_unref (element);
+ return NULL;
+ }
+
+ fmt = GST_FORMAT_TIME;
+ array = g_ptr_array_new ();
+ for (i = 1 ; i <= num_titles; i++) {
+ gint64 len;
+
+ /* Reset to NULL, change the title, and go back to PAUSED */
+ if (gst_element_set_state (element, GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) {
+ GST_DEBUG ("Couldn't set state to NULL for title %"G_GINT64_FORMAT, i);
+ break;
+ }
+ g_object_set (element, "title", i, NULL);
+ if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
+ GST_DEBUG ("Couldn't set state for title %"G_GINT64_FORMAT, i);
+ break;
+ }
+
+ if (gst_element_query_duration (element, &fmt, &len) == FALSE) {
+ GST_DEBUG ("Couldnt' query duration for title %"G_GINT64_FORMAT, i);
+ break;
+ }
+ /* If it's less than 30 seconds long, we kick it out */
+ if (len >= (30 * GST_SECOND)) {
+ g_ptr_array_add (array, g_strdup_printf ("dvd://%"G_GINT64_FORMAT, i));
+ GST_DEBUG ("URI: dvd://%d (time: %" GST_TIME_FORMAT ")",
+ (gint) i, GST_TIME_ARGS (len));
+ }
+ }
+
+ gst_element_set_state (element, GST_STATE_NULL);
+ gst_object_unref (element);
+ if (array->len >= 1)
+ g_ptr_array_add (array, NULL);
+ return (char **) g_ptr_array_free (array, FALSE);
+}
+
+static gchar **
+bacon_video_widget_get_dvb_mrls (const char *device)
+{
+ gchar* filename;
+ gchar* contents;
+ GPtrArray *array;
+ gchar adapter_type;
+
+ adapter_type = bacon_video_widget_dvb_get_adapter_type (device);
+ filename = bacon_video_widget_get_channels_file ();
+
+ if (g_file_get_contents (filename, &contents, NULL, NULL) != FALSE) {
+ gchar **lines, *line;
+ guint i;
+
+ lines = g_strsplit (contents, "\n", 0);
+ array = g_ptr_array_new ();
+
+ for (i = 0; lines[i] != NULL; i++) {
+ line = lines[i];
+
+ if (line[0] != '#') {
+ gchar** fields = g_strsplit(line, ":", 0);
+ if ((g_strv_length (fields) == 13 && adapter_type == 'T') ||
+ (g_strv_length (fields) == 8 && adapter_type == 'S') ||
+ (g_strv_length (fields) == 9 && adapter_type == 'C')) {
+ g_ptr_array_add (array, g_strdup_printf("dvb://%s", fields[0]));
+ }
+ g_strfreev(fields);
+ }
+ }
+ g_strfreev(lines);
+ } else {
+ return NULL;
+ }
+ if (array->len >= 1)
+ g_ptr_array_add (array, NULL);
+ return (char **) g_ptr_array_free (array, FALSE);
+}
+
gchar **
-bacon_video_widget_get_mrls (BaconVideoWidget * bvw, TotemDiscMediaType type,
- const char *device)
+bacon_video_widget_get_mrls (BaconVideoWidget * bvw,
+ TotemDiscMediaType type,
+ const char *device,
+ GError **error)
{
gchar **mrls;
@@ -4055,121 +4101,86 @@
GST_DEBUG ("type = %d", type);
GST_DEBUG ("device = %s", GST_STR_NULL (device));
- g_free (bvw->priv->media_device);
- bvw->priv->media_device = g_strdup (device);
-
switch (type) {
case MEDIA_TYPE_VCD: {
- gchar *uri[] = { NULL, NULL };
- uri[0] = g_strdup_printf ("vcd://%s", device);
- mrls = g_strdupv (uri);
- g_free (uri[0]);
+ gchar *uri[] = { NULL, NULL };
+ uri[0] = g_strdup_printf ("vcd://%s", device);
+ mrls = g_strdupv (uri);
+ g_free (uri[0]);
+ break;
+ }
+ case MEDIA_TYPE_DVD: {
+ if (!gst_default_registry_check_feature_version ("dvdreadsrc", 0, 10, 0)) {
+ GST_DEBUG ("Missing dvdreadsrc");
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
+ return NULL;
+ } else if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
+ !gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
+ GST_DEBUG ("flupsdemux not new enough for DVD playback");
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
+ return NULL;
+ } else {
+ mrls = bacon_video_widget_get_dvd_mrls (device);
+ }
break;
}
+ case MEDIA_TYPE_DVB: {
+ gchar *filename;
- case MEDIA_TYPE_DVD: {
- GstFormat fmt;
- GstElement *element;
- gint64 num_titles, i;
- GPtrArray *array;
-
- element = gst_element_factory_make ("dvdreadsrc", "test_dvdsrc");
- if (element == NULL)
- return NULL;
- /* We need to get the format after instantiating dvdreadsrc, as
- * the nick is registered in that class init */
- fmt = gst_format_get_by_nick ("title");
- g_object_set (element, "device", device, NULL);
- if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
- GST_DEBUG ("Couldn't change the state to PAUSED");
- gst_object_unref (element);
+ if (!gst_default_registry_check_feature_version ("dvbbasebin", 0, 10, 6) ||
+ !gst_default_registry_check_feature_version ("mpegtsparse", 0, 10, 6) ||
+ !gst_default_registry_check_feature_version ("dvbsrc", 0, 10, 6)) {
+ GST_DEBUG ("Missing one or all of: dvbsrc, dvbbasebin, mpegtsparse");
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
return NULL;
}
- if (gst_element_query_duration (element, &fmt, &num_titles) == FALSE) {
- GST_DEBUG ("Couldn't query the \"duration\" (number of titles)");
- gst_element_set_state (element, GST_STATE_NULL);
- gst_object_unref (element);
+ if (gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 0) &&
+ !gst_default_registry_check_feature_version ("flupsdemux", 0, 10, 15)) {
+ GST_DEBUG ("flupsdemux not new enough for DVB playback");
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
return NULL;
}
- fmt = GST_FORMAT_TIME;
- array = g_ptr_array_new ();
- for (i = 1 ; i <= num_titles; i++) {
- gint64 len;
-
- /* Reset to NULL, change the title, and go back to PAUSED */
- if (gst_element_set_state (element, GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) {
- GST_DEBUG ("Couldn't set state to NULL for title %"G_GINT64_FORMAT, i);
- break;
- }
- g_object_set (element, "title", i, NULL);
- if (gst_element_set_state (element, GST_STATE_PAUSED) != GST_STATE_CHANGE_SUCCESS) {
- GST_DEBUG ("Couldn't set state for title %"G_GINT64_FORMAT, i);
- break;
- }
-
- if (gst_element_query_duration (element, &fmt, &len) == FALSE) {
- GST_DEBUG ("Couldnt' query duration for title %"G_GINT64_FORMAT, i);
- break;
- }
- /* If it's less than 30 seconds long, we kick it out */
- if (len >= (30 * GST_SECOND)) {
- g_ptr_array_add (array, g_strdup_printf ("dvd://%"G_GINT64_FORMAT, i));
- GST_DEBUG ("URI: dvd://%d (time: %" GST_TIME_FORMAT ")",
- (gint) i, GST_TIME_ARGS (len));
- }
+ filename = g_strdup_printf ("/dev/dvb/adapter%s/frontend0", device);
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_free (filename);
+ g_set_error (error, BVW_ERROR, BVW_ERROR_INVALID_DEVICE,
+ "XXX Do not use XXX");
+ return NULL;
}
+ g_free (filename);
- gst_element_set_state (element, GST_STATE_NULL);
- gst_object_unref (element);
- if (array->len >= 1)
- g_ptr_array_add (array, NULL);
- mrls = (char **) g_ptr_array_free (array, FALSE);
- break;
- }
- case MEDIA_TYPE_DVB: {
- gchar* filename;
- gchar* contents;
- GPtrArray *array;
- gchar adapter_type;
-
- adapter_type = bacon_video_widget_dvb_get_adapter_type (device);
filename = bacon_video_widget_get_channels_file ();
-
- if (g_file_get_contents (filename, &contents, NULL, NULL) != FALSE) {
- gchar **lines, *line;
- guint i;
-
- lines = g_strsplit (contents, "\n", 0);
- array = g_ptr_array_new ();
-
- for (i = 0; lines[i] != NULL; i++) {
- line = lines[i];
-
- if (line[0] != '#') {
- gchar** fields = g_strsplit(line, ":", 0);
- if ((g_strv_length (fields) == 13 && adapter_type == 'T') ||
- (g_strv_length (fields) == 8 && adapter_type == 'S') ||
- (g_strv_length (fields) == 9 && adapter_type == 'C')) {
- g_ptr_array_add (array, g_strdup_printf("dvb://%s", fields[0]));
- }
- g_strfreev(fields);
- }
- }
- g_strfreev(lines);
+ if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ g_free (filename);
+ mrls = bacon_video_widget_get_dvb_mrls (device);
} else {
- return NULL;
+ GST_DEBUG ("no channels file '%s'", filename);
+ g_set_error (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND,
+ "XXX Do not use XXX");
+ g_free (filename);
+ return NULL;
}
- if (array->len >= 1)
- g_ptr_array_add (array, NULL);
- mrls = (char **) g_ptr_array_free (array, FALSE);
break;
}
+ case MEDIA_TYPE_CDDA:
+ g_set_error (error, BVW_ERROR, BVW_ERROR_UNVALID_LOCATION,
+ "XXX Do not use XXX");
+ return NULL;
default:
- mrls = NULL;
- break;
+ g_assert_not_reached();
}
+ if (mrls == NULL)
+ return NULL;
+
+ g_free (bvw->priv->media_device);
+ bvw->priv->media_device = g_strdup (device);
+
return mrls;
}
@@ -5464,3 +5475,6 @@
}
}
+/*
+ * vim: sw=2 ts=8 cindent noai bs=2
+ */
Modified: trunk/src/backend/bacon-video-widget-xine.c
==============================================================================
--- trunk/src/backend/bacon-video-widget-xine.c (original)
+++ trunk/src/backend/bacon-video-widget-xine.c Fri Jun 27 16:36:59 2008
@@ -1572,12 +1572,9 @@
/* Steal messages from the async queue, if there's an error,
* to use as the error message rather than the crappy errors from
* xine_open() */
- while ((data = g_async_queue_try_pop (bvw->priv->queue)) != NULL)
- {
- if (data->signal == ERROR_ASYNC || data->signal == MESSAGE_ASYNC)
- {
- if (save_data != NULL)
- {
+ while ((data = g_async_queue_try_pop (bvw->priv->queue)) != NULL) {
+ if (data->signal == ERROR_ASYNC || data->signal == MESSAGE_ASYNC) {
+ if (save_data != NULL) {
g_free (save_data->msg);
g_free (save_data);
}
@@ -1588,8 +1585,7 @@
}
}
- if (save_data != NULL)
- {
+ if (save_data != NULL) {
g_set_error (error, BVW_ERROR, save_data->num,
"%s", save_data->msg);
g_free (save_data->msg);
@@ -3419,43 +3415,6 @@
XINE_STREAM_INFO_SEEKABLE);
}
-BaconVideoWidgetCanPlayStatus
-bacon_video_widget_can_play (BaconVideoWidget *bvw, TotemDiscMediaType type)
-{
- switch (type)
- {
- case MEDIA_TYPE_DVD:
- if (bvw->priv->can_dvd != FALSE)
- return BVW_CAN_PLAY_SUCCESS;
- break;
- case MEDIA_TYPE_VCD:
- if (bvw->priv->can_vcd != FALSE)
- return BVW_CAN_PLAY_SUCCESS;
- break;
- case MEDIA_TYPE_DVB:
- if (bvw->priv->can_dvb != FALSE) {
- char *path;
-
- path = g_build_filename (g_get_home_dir (),
- ".xine",
- "channels.conf",
- NULL);
- if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
- g_free (path);
- return BVW_CAN_PLAY_MISSING_CHANNELS;
- }
- g_free (path);
- return BVW_CAN_PLAY_SUCCESS;
- }
- break;
- case MEDIA_TYPE_CDDA:
- default:
- return BVW_CAN_PLAY_UNSUPPORTED;
- }
-
- return BVW_CAN_PLAY_MISSING_PLUGINS;
-}
-
static char **
bacon_video_widget_strdupnv (const char **mrls, guint num_mrls)
{
@@ -3473,7 +3432,8 @@
char **
bacon_video_widget_get_mrls (BaconVideoWidget *bvw,
TotemDiscMediaType type,
- const char *device)
+ const char *device,
+ GError **error)
{
const char *plugin_id, *entry_name;
int num_mrls;
@@ -3484,17 +3444,63 @@
g_return_val_if_fail (bvw->priv->xine != NULL, NULL);
g_return_val_if_fail (device != NULL, NULL);
- entry_name = plugin_id = NULL;
-
- if (type == MEDIA_TYPE_DVD) {
+ switch (type) {
+ case MEDIA_TYPE_DVD:
+ if (bvw->priv->can_dvd == FALSE) {
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
+ return NULL;
+ }
plugin_id = "DVD";
entry_name = "media.dvd.device";
- } else if (type == MEDIA_TYPE_VCD) {
+ break;
+ case MEDIA_TYPE_VCD:
+ if (bvw->priv->can_vcd == FALSE) {
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
+ return NULL;
+ }
plugin_id = "VCD";
entry_name = "media.vcd.device";
- } else if (type == MEDIA_TYPE_DVB) {
+ break;
+ case MEDIA_TYPE_DVB:
+ if (bvw->priv->can_dvb == FALSE) {
+ g_set_error (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE,
+ "XXX Do not use XXX");
+ return NULL;
+ } else {
+ char *path;
+
+ path = g_strdup_printf ("/dev/dvb/adapter%s/frontend0", device);
+ if (g_file_test (path, G_FILE_TEST_EXISTS) == FALSE) {
+ g_free (path);
+ g_set_error (error, BVW_ERROR, BVW_ERROR_INVALID_DEVICE,
+ "XXX Do not use XXX");
+ return NULL;
+ }
+ g_free (path);
+
+ path = g_build_filename (g_get_home_dir (),
+ ".xine",
+ "channels.conf",
+ NULL);
+ if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
+ g_free (path);
+ g_set_error (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND,
+ "XXX Do not use XXX");
+ return NULL;
+ }
+ g_free (path);
+ }
plugin_id = "DVB";
entry_name = "media.dvb.adapter";
+ break;
+ case MEDIA_TYPE_CDDA:
+ g_set_error (error, BVW_ERROR, BVW_ERROR_UNVALID_LOCATION,
+ "XXX Do not use XXX");
+ return NULL;
+ default:
+ g_assert_not_reached ();
}
if (type != MEDIA_TYPE_DVB) {
@@ -3529,14 +3535,14 @@
} else if (type == MEDIA_TYPE_DVB) {
/* No channels.conf, and we couldn't find it */
if (g_str_has_prefix (mrls[0], "Sorry, No valid channels.conf found") != FALSE) {
+ g_set_error (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND,
+ "XXX Do not use XXX");
return NULL;
} else if (g_str_has_prefix (mrls[0], "Sorry, No DVB input device found.") != FALSE) {
- g_message ("Device is busy...");
+ g_set_error (error, BVW_ERROR, BVW_ERROR_DEVICE_BUSY,
+ "XXX Do not use XXX");
return NULL;
}
- /* The first channel can be the last channel played,
- * or a copy of the first one, ignore it */
- return bacon_video_widget_strdupnv ((const char **) mrls, num_mrls);
}
return bacon_video_widget_strdupnv ((const char **) mrls, num_mrls);
Modified: trunk/src/backend/bacon-video-widget.h
==============================================================================
--- trunk/src/backend/bacon-video-widget.h (original)
+++ trunk/src/backend/bacon-video-widget.h Fri Jun 27 16:36:59 2008
@@ -80,6 +80,7 @@
/* Devices */
BVW_ERROR_DVD_ENCRYPTED,
BVW_ERROR_INVALID_DEVICE,
+ BVW_ERROR_DEVICE_BUSY,
/* Network */
BVW_ERROR_UNKNOWN_HOST,
BVW_ERROR_NETWORK_UNREACHABLE,
@@ -171,20 +172,10 @@
int speed);
int bacon_video_widget_get_connection_speed (BaconVideoWidget *bvw);
-typedef enum {
- BVW_CAN_PLAY_SUCCESS,
- BVW_CAN_PLAY_MISSING_CHANNELS,
- BVW_CAN_PLAY_MISSING_PLUGINS,
- BVW_CAN_PLAY_UNSUPPORTED
-} BaconVideoWidgetCanPlayStatus;
-
-BaconVideoWidgetCanPlayStatus bacon_video_widget_can_play
- (BaconVideoWidget *bvw,
- TotemDiscMediaType type);
-
gchar **bacon_video_widget_get_mrls (BaconVideoWidget *bvw,
TotemDiscMediaType type,
- const char *device);
+ const char *device,
+ GError **error);
void bacon_video_widget_set_subtitle_font (BaconVideoWidget *bvw,
const char *font);
void bacon_video_widget_set_subtitle_encoding (BaconVideoWidget *bvw,
Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c (original)
+++ trunk/src/totem.c Fri Jun 27 16:36:59 2008
@@ -519,25 +519,22 @@
static gboolean
totem_action_load_media (Totem *totem, TotemDiscMediaType type, const char *device)
{
- char **mrls;
- char *msg;
+ char **mrls, *msg;
+ GError *error = NULL;
+ const char *link, *link_text, *secondary;
gboolean retval;
- BaconVideoWidgetCanPlayStatus status;
-
- status = bacon_video_widget_can_play (totem->bvw, type);
- if (status != BVW_CAN_PLAY_SUCCESS) {
- const char *link, *link_text, *secondary;
-
- switch (status) {
- case BVW_CAN_PLAY_MISSING_CHANNELS:
- g_assert (type == MEDIA_TYPE_DVB);
- link = "http://www.gnome.org/projects/totem/#dvb";
- link_text = _("More information about watching TV");
- msg = g_strdup (_("Totem is missing a channels listing to be able to tune the receiver."));
- secondary = _("Please follow the instructions provided in the link to create a channels listing.");
- break;
- case BVW_CAN_PLAY_MISSING_PLUGINS:
+ mrls = bacon_video_widget_get_mrls (totem->bvw, type, device, &error);
+ if (mrls == NULL) {
+ /* No errors? Weird */
+ if (error == NULL) {
+ msg = g_strdup_printf (_("Totem could not play this media (%s) although a plugin is present to handle it."), _(totem_cd_get_human_readable_name (type)));
+ totem_action_error (msg, _("You might want to check that a disc is present in the drive and that it is correctly configured."), totem);
+ g_free (msg);
+ return FALSE;
+ }
+ /* No plugin for the media type */
+ if (g_error_matches (error, BVW_ERROR, BVW_ERROR_NO_PLUGIN_FOR_FILE) != FALSE) {
link = "http://www.gnome.org/projects/totem/#codecs";
link_text = _("More information about media plugins");
secondary = _("Please install the necessary plugins and restart Totem to be able to play this media.");
@@ -545,29 +542,37 @@
msg = g_strdup_printf (_("Totem cannot play this type of media (%s) because it does not have the appropriate plugins to be able to read from the disc."), _(totem_cd_get_human_readable_name (type)));
else
msg = g_strdup_printf (_("Totem cannot play this type of media (%s) because you do not have the appropriate plugins to handle it."), _(totem_cd_get_human_readable_name (type)));
- break;
- case BVW_CAN_PLAY_UNSUPPORTED:
+ /* Device doesn't exist */
+ } else if (g_error_matches (error, BVW_ERROR, BVW_ERROR_INVALID_DEVICE) != FALSE) {
+ g_assert (type == MEDIA_TYPE_DVB);
+ msg = N_("Totem cannot play TV, because no TV adapters are present or they are not supported.");
+ totem_action_error (_(msg), _("Please insert a supported TV adapter."), totem);
+ return FALSE;
+ /* No channels.conf file */
+ } else if (g_error_matches (error, BVW_ERROR, BVW_ERROR_FILE_NOT_FOUND) != FALSE) {
+ g_assert (type == MEDIA_TYPE_DVB);
+ link = "http://www.gnome.org/projects/totem/#dvb";
+ link_text = _("More information about watching TV");
+ msg = g_strdup (_("Totem is missing a channels listing to be able to tune the receiver."));
+ secondary = _("Please follow the instructions provided in the link to create a channels listing.");
+ } else if (g_error_matches (error, BVW_ERROR, BVW_ERROR_DEVICE_BUSY) != FALSE) {
+ g_assert (type == MEDIA_TYPE_DVB);
+ msg = g_strdup_printf(_("Totem cannot play this type of media (%s) because the TV device is busy."), _(totem_cd_get_human_readable_name (type)));
+ totem_action_error (msg, _("Please try again later."), totem);
+ g_free (msg);
+ return FALSE;
+ /* Unsupported type (ie. CDDA) */
+ } else if (g_error_matches (error, BVW_ERROR, BVW_ERROR_UNVALID_LOCATION) != FALSE) {
msg = g_strdup_printf(_("Totem cannot play this type of media (%s) because it is not supported."), _(totem_cd_get_human_readable_name (type)));
totem_action_error (msg, _("Please insert another disc to play back."), totem);
g_free (msg);
return FALSE;
- default:
- g_assert_not_reached ();
}
-
totem_interface_error_with_link (msg, secondary, link, link_text, GTK_WINDOW (totem->win), totem);
g_free (msg);
return FALSE;
}
- mrls = bacon_video_widget_get_mrls (totem->bvw, type, device);
- if (mrls == NULL) {
- msg = g_strdup_printf (_("Totem could not play this media (%s) although a plugin is present to handle it."), _(totem_cd_get_human_readable_name (type)));
- totem_action_error (msg, _("You might want to check that a disc is present in the drive and that it is correctly configured."), totem);
- g_free (msg);
- return FALSE;
- }
-
retval = totem_action_open_files (totem, mrls);
g_strfreev (mrls);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]