From 887fc8e6e7bdd46d3f262fddec533594b6e7cb9c Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Sun, 26 Sep 2010 20:41:25 +0100 Subject: resindvdsrc: improve error messages on read erros Provide i18n-ed error messages when a read error happens, and point out that the error could be happening because the DVD is scrambled. https://bugzilla.gnome.org/show_bug.cgi?id=613633 --- ext/resindvd/resindvdsrc.c | 57 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c index 590fde630..0eda62a02 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -857,6 +857,25 @@ update_title_info (resinDvdSrc * src) } } +/* we don't cache the result on purpose */ +static gboolean +rsn_descrambler_available (void) +{ + GModule *module; + gpointer sym; + gsize res; + + module = g_module_open ("libdvdcss", 0); + if (module != NULL) { + res = g_module_symbol (module, "dvdcss_open", &sym); + g_module_close (module); + } else { + res = FALSE; + } + + return res; +} + static GstFlowReturn rsn_dvdsrc_step (resinDvdSrc * src, gboolean have_dvd_lock) { @@ -1092,19 +1111,35 @@ rsn_dvdsrc_step (resinDvdSrc * src, gboolean have_dvd_lock) } return ret; + +/* ERRORS */ read_error: - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), - ("Failed to read next DVD block. Error: %s", - dvdnav_err_to_string (src->dvdnav))); - return GST_FLOW_ERROR; + { + if (!rsn_descrambler_available ()) { + GST_ELEMENT_ERROR (src, RESOURCE, READ, + (_("Could not read DVD. This may be because the DVD is encrypted " + "and a DVD decryption library is not installed.")), + ("Failed to read next DVD block. Error: %s", + dvdnav_err_to_string (src->dvdnav))); + } else { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (_("Could not read DVD.")), + ("Failed to read next DVD block. Error: %s", + dvdnav_err_to_string (src->dvdnav))); + } + return GST_FLOW_ERROR; + } internal_error: - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), - ("Internal error processing DVD commands. Error: %s", - dvdnav_err_to_string (src->dvdnav))); - return GST_FLOW_ERROR; + { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (_("Could not read DVD.")), + ("Internal error processing DVD commands. Error: %s", + dvdnav_err_to_string (src->dvdnav))); + return GST_FLOW_ERROR; + } branching: - g_mutex_unlock (src->branch_lock); - return GST_FLOW_WRONG_STATE; + { + g_mutex_unlock (src->branch_lock); + return GST_FLOW_WRONG_STATE; + } } /* Send app a bus message that the available commands have changed */ @@ -2334,7 +2369,7 @@ rsn_dvdsrc_src_event (GstBaseSrc * basesrc, GstEvent * event) GST_LOG_OBJECT (src, "handling seek event"); gst_event_parse_seek (event, NULL, NULL, &flags, NULL, NULL, NULL, NULL); - src->flushing_seek = !!(flags & GST_SEEK_FLAG_FLUSH); + src->flushing_seek = ! !(flags & GST_SEEK_FLAG_FLUSH); GST_DEBUG_OBJECT (src, "%s seek event", src->flushing_seek ? "flushing" : "non-flushing"); -- cgit v1.2.3