summaryrefslogtreecommitdiffstats
path: root/gst-libs
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2003-05-31 16:21:39 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2003-05-31 16:21:39 +0000
commit61996734935681c9ed213d916e3a4f1c8d8cf80c (patch)
tree398ada77dfd14c0080a788933cbf41eb3355a6e2 /gst-libs
parent1573e8c9148f05c74682c7cab0e511bf0103aa8b (diff)
downloadgst-plugins-bad-61996734935681c9ed213d916e3a4f1c8d8cf80c.tar.gz
gst-plugins-bad-61996734935681c9ed213d916e3a4f1c8d8cf80c.tar.bz2
gst-plugins-bad-61996734935681c9ed213d916e3a4f1c8d8cf80c.zip
backport of Julien's error handling this fixes #114134
Original commit message from CVS: backport of Julien's error handling this fixes #114134
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/play/play.old.c87
-rw-r--r--gst-libs/gst/play/play.old.h26
-rw-r--r--gst-libs/gst/play/playpipelines.c76
3 files changed, 66 insertions, 123 deletions
diff --git a/gst-libs/gst/play/play.old.c b/gst-libs/gst/play/play.old.c
index cf8b9531..d0f60882 100644
--- a/gst-libs/gst/play/play.old.c
+++ b/gst-libs/gst/play/play.old.c
@@ -2,7 +2,7 @@
* Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2001,2002 Wim Taymans <wtay@chello.be>
* 2002 Steve Baker <steve@stevebaker.org>
- * 2003 Julien Moutte <julien@moutte.net>
+ * 2003 Julien Moutte <julien@moutte.net>
*
* play.c: GstPlay object code
*
@@ -33,6 +33,8 @@ enum {
HAVE_XID,
HAVE_VIS_XID,
HAVE_VIDEO_SIZE,
+ PIPELINE_ERROR,
+ /* put additional signals before this comment */
LAST_SIGNAL,
};
@@ -56,9 +58,13 @@ struct _GstPlaySignal
GstElementState new_state;
} state;
struct {
- GstElement* element;
+ GstObject* object;
GParamSpec* param;
} info;
+ struct {
+ GstElement* element;
+ char* error;
+ } error;
} signal_data;
};
@@ -213,21 +219,15 @@ gst_play_get_length_callback (GstPlay *play)
GstFormat format = GST_FORMAT_TIME;
gboolean query_worked = FALSE;
- g_print("trying to get length\n");
if ( (play->audio_sink_element != NULL) &&
(GST_IS_ELEMENT (play->audio_sink_element)) ) {
- g_mutex_lock(play->audio_bin_mutex);
query_worked = gst_element_query (play->audio_sink_element, GST_QUERY_TOTAL, &format, &value);
- g_mutex_unlock(play->audio_bin_mutex);
}
else if ( (play->video_sink_element != NULL) &&
(GST_IS_ELEMENT (play->video_sink_element)) ) {
- g_mutex_lock(play->video_bin_mutex);
query_worked = gst_element_query (play->video_sink_element, GST_QUERY_TOTAL, &format, &value);
- g_mutex_unlock(play->video_bin_mutex);
}
if (query_worked){
- g_print("got length %" G_GINT64_FORMAT "\n", value);
g_signal_emit (G_OBJECT (play), gst_play_signals [STREAM_LENGTH], 0, value);
play->length_nanos = value;
return FALSE;
@@ -337,7 +337,17 @@ gst_play_idle_signal (GstPlay *play)
break;
case INFORMATION:
g_signal_emit (G_OBJECT (play), gst_play_signals[INFORMATION], 0,
- signal->signal_data.info.element, signal->signal_data.info.param);
+ signal->signal_data.info.object, signal->signal_data.info.param);
+ gst_object_unref (signal->signal_data.info.object);
+ break;
+ case PIPELINE_ERROR:
+ if (gst_element_get_state(play->pipeline) == GST_STATE_PLAYING)
+ gst_element_set_state(play->pipeline, GST_STATE_READY);
+ g_signal_emit (G_OBJECT (play), gst_play_signals[PIPELINE_ERROR], 0,
+ signal->signal_data.error.element, signal->signal_data.error.error);
+ if (signal->signal_data.error.error)
+ g_free (signal->signal_data.error.error);
+ gst_object_unref (GST_OBJECT(signal->signal_data.error.element));
break;
default:
break;
@@ -413,34 +423,29 @@ callback_video_have_size ( GstElement *element,
play->idle_add_func ((GSourceFunc) gst_play_idle_signal, play);
}
-static void
-callback_bin_pre_iterate ( GstBin *bin,
- GMutex *mutex)
-{
- g_mutex_lock(mutex);
-}
-
-static void
-callback_bin_post_iterate ( GstBin *bin,
- GMutex *mutex)
-{
- g_mutex_unlock(mutex);
-}
-
static void
-callback_pipeline_error ( GObject *object,
- GstObject *orig,
- gchar *error,
+callback_pipeline_error ( GstElement *object,
+ GstElement *orig,
+ char *error,
GstPlay* play)
{
- g_print ("Pipeline error: %s\n", error);
- if (gst_element_get_state(play->pipeline) == GST_STATE_PLAYING)
- gst_element_set_state(play->pipeline, GST_STATE_READY);
+ GstPlaySignal *signal;
+
+ signal = g_new0(GstPlaySignal, 1);
+ signal->signal_id = PIPELINE_ERROR;
+ signal->signal_data.error.element = orig;
+ signal->signal_data.error.error = g_strdup(error);
+
+ gst_object_ref (GST_OBJECT(orig));
+
+ g_async_queue_push(play->signal_queue, signal);
+
+ play->idle_add_func ((GSourceFunc) gst_play_idle_signal, play);
}
static void
-callback_pipeline_deep_notify ( GstElement *element,
- GstElement *orig,
+callback_pipeline_deep_notify ( GstObject *element,
+ GstObject *orig,
GParamSpec *param,
GstPlay* play)
{
@@ -448,8 +453,10 @@ callback_pipeline_deep_notify ( GstElement *element,
signal = g_new0(GstPlaySignal, 1);
signal->signal_id = INFORMATION;
- signal->signal_data.info.element = orig;
+ signal->signal_data.info.object = orig;
signal->signal_data.info.param = param;
+
+ gst_object_ref (orig);
g_async_queue_push(play->signal_queue, signal);
@@ -521,10 +528,8 @@ gst_play_dispose (GObject *object)
/* Removing all sources */
while (g_source_remove_by_user_data (play));
-
+
G_OBJECT_CLASS (parent_class)->dispose (object);
- g_mutex_free(play->audio_bin_mutex);
- g_mutex_free(play->video_bin_mutex);
}
static void
@@ -579,6 +584,16 @@ gst_play_class_init (GstPlayClass *klass)
G_TYPE_NONE, 2,
G_TYPE_OBJECT, G_TYPE_PARAM);
+ gst_play_signals [PIPELINE_ERROR] =
+ g_signal_new ("pipeline_error",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GstPlayClass, pipeline_error),
+ NULL, NULL,
+ gst_marshal_VOID__OBJECT_STRING,
+ G_TYPE_NONE, 2,
+ G_TYPE_OBJECT, G_TYPE_STRING);
+
gst_play_signals [STATE_CHANGE] =
g_signal_new ("state_change",
G_TYPE_FROM_CLASS (klass),
@@ -665,8 +680,6 @@ gst_play_init (GstPlay *play)
play->video_sink_element = NULL;
play->volume = NULL;
play->other_elements = g_hash_table_new(g_str_hash, g_str_equal);
- play->audio_bin_mutex = g_mutex_new();
- play->video_bin_mutex = g_mutex_new();
gst_play_set_idle_timeout_funcs( play,
gst_play_default_timeout_add,
diff --git a/gst-libs/gst/play/play.old.h b/gst-libs/gst/play/play.old.h
index 90f9a5ce..36057505 100644
--- a/gst-libs/gst/play/play.old.h
+++ b/gst-libs/gst/play/play.old.h
@@ -2,7 +2,7 @@
* Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2001,2002 Wim Taymans <wtay@chello.be>
* 2002 Steve Baker <steve@stevebaker.org>
- * 2003 Julien Moutte <julien@moutte.net>
+ * 2003 Julien Moutte <julien@moutte.net>
*
* play.h: GstPlay object code
*
@@ -117,9 +117,6 @@ struct _GstPlay
GstClock *clock;
- GMutex *audio_bin_mutex;
- GMutex *video_bin_mutex;
-
gboolean need_stream_length;
gboolean need_seek;
gint time_seconds;
@@ -139,22 +136,25 @@ struct _GstPlayClass
GObjectClass parent_class;
/* signals */
- void (*information) ( GstPlay* play,
- GstElement* element,
+ void (*information) (GstPlay* play,
+ GstObject* element,
GParamSpec *param);
- void (*state_changed) ( GstPlay* play,
+ void (*pipeline_error) (GstPlay* play,
+ GstElement* element,
+ char *error);
+ void (*state_changed) (GstPlay* play,
GstElementState old_state,
GstElementState new_state);
- void (*stream_end) ( GstPlay* play);
- void (*time_tick) ( GstPlay* play,
+ void (*stream_end) (GstPlay* play);
+ void (*time_tick) (GstPlay* play,
gint64 time_nanos);
- void (*stream_length) ( GstPlay* play,
+ void (*stream_length) (GstPlay* play,
gint64 length_nanos);
- void (*have_xid) ( GstPlay* play,
+ void (*have_xid) (GstPlay* play,
gint xid);
- void (*have_vis_xid) ( GstPlay* play,
+ void (*have_vis_xid) (GstPlay* play,
gint xid);
- void (*have_video_size) ( GstPlay* play,
+ void (*have_video_size) (GstPlay* play,
gint width,
gint height);
};
diff --git a/gst-libs/gst/play/playpipelines.c b/gst-libs/gst/play/playpipelines.c
index a357fd56..126f02eb 100644
--- a/gst-libs/gst/play/playpipelines.c
+++ b/gst-libs/gst/play/playpipelines.c
@@ -2,7 +2,7 @@
* Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2001,2002 Wim Taymans <wtay@chello.be>
* 2002 Steve Baker <steve@stevebaker.org>
- * 2003 Julien Moutte <julien@moutte.net>
+ * 2003 Julien Moutte <julien@moutte.net>
*
* playpipelines.c: Set up pipelines for playback
*
@@ -97,16 +97,6 @@ gst_play_audio_setup ( GstPlay *play,
play->audio_sink, NULL);
gst_element_link (play->volume, play->audio_sink);
-
- gst_bin_set_pre_iterate_function(
- GST_BIN (play->pipeline),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->audio_bin_mutex);
-
- gst_bin_set_post_iterate_function(
- GST_BIN (play->pipeline),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->audio_bin_mutex);
return TRUE;
}
@@ -167,16 +157,6 @@ gst_play_audiot_setup ( GstPlay *play,
gst_element_link (play->volume, play->audio_sink);
- gst_bin_set_pre_iterate_function(
- GST_BIN (play->pipeline),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->audio_bin_mutex);
-
- gst_bin_set_post_iterate_function(
- GST_BIN (play->pipeline),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->audio_bin_mutex);
-
return TRUE;
}
@@ -323,16 +303,6 @@ gst_play_audioht_setup ( GstPlay *play,
gst_bin_add (GST_BIN (play->pipeline), audio_thread);
- gst_bin_set_pre_iterate_function(
- GST_BIN (audio_thread),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->audio_bin_mutex);
-
- gst_bin_set_post_iterate_function(
- GST_BIN (audio_thread),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->audio_bin_mutex);
-
return TRUE;
}
@@ -481,16 +451,6 @@ gst_play_video_setup ( GstPlay *play,
}
g_hash_table_insert (play->other_elements, "audio_bin", audio_bin);
- /* setting up iterate functions */
- gst_bin_set_pre_iterate_function (
- GST_BIN (audio_bin),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->audio_bin_mutex);
- gst_bin_set_post_iterate_function (
- GST_BIN (audio_bin),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->audio_bin_mutex);
-
/* adding all that stuff to bin */
gst_bin_add_many (
GST_BIN (audio_bin), audio_queue, play->volume,
@@ -545,16 +505,6 @@ gst_play_video_setup ( GstPlay *play,
gst_element_link_many (video_queue, colorspace,
play->video_sink, NULL);
- /* setting up iterate functions */
- gst_bin_set_pre_iterate_function (
- GST_BIN (video_bin),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->video_bin_mutex);
- gst_bin_set_post_iterate_function (
- GST_BIN (video_bin),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->video_bin_mutex);
-
gst_element_add_ghost_pad (
video_bin, gst_element_get_pad (video_queue, "sink"),
"sink");
@@ -823,17 +773,7 @@ gst_play_video_vis_setup ( GstPlay *play,
gst_element_add_ghost_pad ( play->audio_sink,
gst_element_get_pad (audio_queue, "sink"),
"sink");
-
- /* setting up iterate functions */
- gst_bin_set_pre_iterate_function (
- GST_BIN (play->audio_sink),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->audio_bin_mutex);
- gst_bin_set_post_iterate_function (
- GST_BIN (play->audio_sink),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->audio_bin_mutex);
-
+
/* Creating video part of the visualisation bin
{ queue ! (visualisation) ! colorspace ! (videosink) }
*/
@@ -937,17 +877,7 @@ gst_play_video_vis_setup ( GstPlay *play,
gst_element_link_many (video_queue, colorspace,
play->video_sink, NULL);
-
- /* setting up iterate functions */
- gst_bin_set_pre_iterate_function (
- GST_BIN (video_bin),
- (GstBinPrePostIterateFunction) callback_bin_pre_iterate,
- play->video_bin_mutex);
- gst_bin_set_post_iterate_function (
- GST_BIN (video_bin),
- (GstBinPrePostIterateFunction) callback_bin_post_iterate,
- play->video_bin_mutex);
-
+
gst_element_add_ghost_pad (
video_bin, gst_element_get_pad (video_queue, "sink"),
"sink");