summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst/play/play.old.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/gst/play/play.old.c')
-rw-r--r--gst-libs/gst/play/play.old.c87
1 files changed, 50 insertions, 37 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,