Error handling is inside and works :)

Original commit message from CVS:
Error handling is inside and works :)
Mutexes have been removed. That should fix UI responsiveness problems on query_length. Please heavily test to check if they were really needed.
Some fixes in GClosures
This commit is contained in:
Julien Moutte 2003-05-30 22:36:19 +00:00
parent 596e80a64d
commit 2c32dd6f5a
3 changed files with 22 additions and 118 deletions

View file

@ -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
*
@ -63,7 +63,7 @@ struct _GstPlaySignal
} info;
struct {
GstElement* element;
gchar* error;
char* error;
} error;
} signal_data;
};
@ -219,22 +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);
g_message ("getting length from audio sink");
}
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;
@ -352,6 +345,8 @@ gst_play_idle_signal (GstPlay *play)
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:
@ -428,24 +423,10 @@ 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 ( GstElement *object,
GstElement *orig,
gchar *error,
char *error,
GstPlay* play)
{
GstPlaySignal *signal;
@ -453,7 +434,7 @@ callback_pipeline_error ( GstElement *object,
signal = g_new0(GstPlaySignal, 1);
signal->signal_id = PIPELINE_ERROR;
signal->signal_data.error.element = orig;
signal->signal_data.error.error = error;
signal->signal_data.error.error = g_strdup(error);
gst_object_ref (GST_OBJECT(orig));
@ -547,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
@ -611,7 +590,7 @@ gst_play_class_init (GstPlayClass *klass)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstPlayClass, pipeline_error),
NULL, NULL,
gst_marshal_VOID__OBJECT_PARAM,
gst_marshal_VOID__OBJECT_STRING,
G_TYPE_NONE, 2,
G_TYPE_OBJECT, G_TYPE_STRING);
@ -701,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,

View file

@ -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,25 +136,25 @@ struct _GstPlayClass
GObjectClass parent_class;
/* signals */
void (*information) ( GstPlay* play,
void (*information) (GstPlay* play,
GstObject* element,
GParamSpec *param);
void (*pipeline_error) ( GstPlay* play,
void (*pipeline_error) (GstPlay* play,
GstElement* element,
gchar *error);
void (*state_changed) ( GstPlay* play,
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);
};

View file

@ -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");