From f1f79e13f6eab651e82ac0fc16b68bd60863643c Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 25 Nov 2004 20:46:55 +0000 Subject: [PATCH] gst/playback/gstplaybin.c: Don't reference all sinks, but only the video- and audiosinks. Original commit message from CVS: * gst/playback/gstplaybin.c: (gen_video_element), (gen_audio_element), (setup_sinks), (gst_play_bin_change_state): Don't reference all sinks, but only the video- and audiosinks. The vis. element should be disposed when we're done with it. We don't have any reason to keep it around. This fixes warnings when reusing playbin for playing multiple audio files with vis. enabled. Also release audio device on pause - idea stolen from Rhythmbox. --- ChangeLog | 11 +++++++++++ gst/playback/gstplaybin.c | 22 +++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d5c216649..4fec728099 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-11-25 Ronald S. Bultje + + * gst/playback/gstplaybin.c: (gen_video_element), + (gen_audio_element), (setup_sinks), (gst_play_bin_change_state): + Don't reference all sinks, but only the video- and audiosinks. + The vis. element should be disposed when we're done with it. + We don't have any reason to keep it around. This fixes warnings + when reusing playbin for playing multiple audio files with + vis. enabled. Also release audio device on pause - idea stolen + from Rhythmbox. + 2004-11-25 Ronald S. Bultje * ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push), diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index 865631c21d..343cac97c6 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -387,6 +387,10 @@ gen_video_element (GstPlayBin * play_bin) done: play_bin->seekables = g_list_append (play_bin->seekables, sink); + /* since we're gonna add it to a bin but don't want to lose it, + * we keep a reference. */ + gst_object_ref (GST_OBJECT (element)); + return element; } @@ -455,6 +459,10 @@ gen_audio_element (GstPlayBin * play_bin) done: play_bin->seekables = g_list_prepend (play_bin->seekables, sink); + /* since we're gonna add it to a bin but don't want to lose it, + * we keep a reference. */ + gst_object_ref (GST_OBJECT (element)); + return element; } @@ -695,7 +703,6 @@ setup_sinks (GstPlayBaseBin * play_base_bin) /* we found a sink for this stream, now try to install it */ if (sink != NULL) { - gst_object_ref (GST_OBJECT (sink)); gst_bin_add (GST_BIN (play_bin), sink); GST_DEBUG ("Adding sink with state %d (parent: %d, peer: %d)\n", GST_STATE (sink), GST_STATE (play_bin), @@ -743,19 +750,16 @@ gst_play_bin_change_state (GstElement * element) return ret; switch (transition) { - case GST_STATE_NULL_TO_READY: - break; - case GST_STATE_READY_TO_PAUSED: - break; - case GST_STATE_PAUSED_TO_PLAYING: - break; case GST_STATE_PLAYING_TO_PAUSED: + /* Set audio sink state to NULL to release the sound device, + * but only if we own it (else we might be in chain-transition). */ + if (GST_STATE (play_bin->audio_sink) == GST_STATE_PAUSED) { + gst_element_set_state (play_bin->audio_sink, GST_STATE_NULL); + } break; case GST_STATE_PAUSED_TO_READY: remove_sinks (play_bin); break; - case GST_STATE_READY_TO_NULL: - break; default: break; }