[rhythmbox] player: add an error code indicating the stream could not be found
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] player: add an error code indicating the stream could not be found
- Date: Tue, 20 Jul 2010 02:40:37 +0000 (UTC)
commit 5e6592b774a30153303b65d1789efc2b0d2e3e23
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Jul 20 12:14:07 2010 +1000
player: add an error code indicating the stream could not be found
Nothing uses this yet, but it may help in the not too distant future.
backends/gstreamer/rb-player-gst-helper.c | 25 +++++++++++++++++++++++++
backends/gstreamer/rb-player-gst-helper.h | 2 ++
backends/gstreamer/rb-player-gst-xfade.c | 8 +-------
backends/gstreamer/rb-player-gst.c | 10 ++--------
backends/rb-player.c | 1 +
backends/rb-player.h | 3 ++-
6 files changed, 33 insertions(+), 16 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-helper.c b/backends/gstreamer/rb-player-gst-helper.c
index 61ba844..73c62e2 100644
--- a/backends/gstreamer/rb-player-gst-helper.c
+++ b/backends/gstreamer/rb-player-gst-helper.c
@@ -267,6 +267,31 @@ rb_gst_process_tag_string (const GstTagList *taglist,
return TRUE;
}
+/**
+ * rb_gst_error_get_error_code:
+ * @error: error received from GStreamer
+ *
+ * Maps a GStreamer error to an #RBPlayerError error code.
+ *
+ * Return value: the #RBPlayerError value to use
+ */
+int
+rb_gst_error_get_error_code (const GError *error)
+{
+ if (error->domain == GST_RESOURCE_ERROR &&
+ (error->code == GST_RESOURCE_ERROR_NOT_FOUND ||
+ error->code == GST_RESOURCE_ERROR_OPEN_READ ||
+ error->code == GST_RESOURCE_ERROR_READ)) {
+ return RB_PLAYER_ERROR_NOT_FOUND;
+ } else if ((error->domain == GST_CORE_ERROR)
+ || (error->domain == GST_LIBRARY_ERROR)
+ || (error->domain == GST_RESOURCE_ERROR && error->code == GST_RESOURCE_ERROR_BUSY)) {
+ return RB_PLAYER_ERROR_NO_AUDIO;
+ } else {
+ return RB_PLAYER_ERROR_GENERAL;
+ }
+}
+
/* pipeline block-add/remove-unblock operations */
static RBGstPipelineOp *
diff --git a/backends/gstreamer/rb-player-gst-helper.h b/backends/gstreamer/rb-player-gst-helper.h
index 58e96ca..30f6f15 100644
--- a/backends/gstreamer/rb-player-gst-helper.h
+++ b/backends/gstreamer/rb-player-gst-helper.h
@@ -49,6 +49,8 @@ gboolean rb_gst_process_tag_string (const GstTagList *taglist,
RBMetaDataField *field,
GValue *value);
+int rb_gst_error_get_error_code (const GError *error);
+
/* tee and filter support */
GstElement * rb_gst_create_filter_bin (void);
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 0634d4c..0eb0fc3 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -1645,13 +1645,7 @@ rb_player_gst_xfade_bus_cb (GstBus *bus, GstMessage *message, RBPlayerGstXFade *
emit = FALSE;
}
- if ((error->domain == GST_CORE_ERROR)
- || (error->domain == GST_LIBRARY_ERROR)
- || (error->domain == GST_RESOURCE_ERROR && error->code == GST_RESOURCE_ERROR_BUSY)) {
- code = RB_PLAYER_ERROR_NO_AUDIO;
- } else {
- code = RB_PLAYER_ERROR_GENERAL;
- }
+ code = rb_gst_error_get_error_code (error);
if (emit) {
rb_debug ("emitting error %s for stream %s", error->message, stream->uri);
diff --git a/backends/gstreamer/rb-player-gst.c b/backends/gstreamer/rb-player-gst.c
index 671395c..d25eddc 100644
--- a/backends/gstreamer/rb-player-gst.c
+++ b/backends/gstreamer/rb-player-gst.c
@@ -477,7 +477,7 @@ bus_cb (GstBus *bus, GstMessage *message, RBPlayerGst *mp)
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR: {
char *debug;
- GError *error;
+ GError *error = NULL;
GError *sig_error = NULL;
int code;
gboolean emit = TRUE;
@@ -494,13 +494,7 @@ bus_cb (GstBus *bus, GstMessage *message, RBPlayerGst *mp)
emit = FALSE;
}
- if ((error->domain == GST_CORE_ERROR)
- || (error->domain == GST_LIBRARY_ERROR)
- || (error->domain == GST_RESOURCE_ERROR && error->code == GST_RESOURCE_ERROR_BUSY)) {
- code = RB_PLAYER_ERROR_NO_AUDIO;
- } else {
- code = RB_PLAYER_ERROR_GENERAL;
- }
+ code = rb_gst_error_get_error_code (error);
if (emit) {
if (message_from_sink (mp->priv->audio_sink, message)) {
diff --git a/backends/rb-player.c b/backends/rb-player.c
index 08a8f5f..5dcb86a 100644
--- a/backends/rb-player.c
+++ b/backends/rb-player.c
@@ -749,6 +749,7 @@ rb_player_error_get_type (void)
ENUM_ENTRY (RB_PLAYER_ERROR_NO_AUDIO, "no-audio"),
ENUM_ENTRY (RB_PLAYER_ERROR_GENERAL, "general-error"),
ENUM_ENTRY (RB_PLAYER_ERROR_INTERNAL, "internal-error"),
+ ENUM_ENTRY (RB_PLAYER_ERROR_NOT_FOUND, "not-found"),
{ 0, 0, 0 }
};
diff --git a/backends/rb-player.h b/backends/rb-player.h
index 24f001f..f82e9af 100644
--- a/backends/rb-player.h
+++ b/backends/rb-player.h
@@ -49,7 +49,8 @@ typedef enum
{
RB_PLAYER_ERROR_NO_AUDIO,
RB_PLAYER_ERROR_GENERAL,
- RB_PLAYER_ERROR_INTERNAL
+ RB_PLAYER_ERROR_INTERNAL,
+ RB_PLAYER_ERROR_NOT_FOUND
} RBPlayerError;
GType rb_player_error_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]