diff --git a/ChangeLog b/ChangeLog index 1b792e36fd..3f4776ef66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-05-05 Sebastian Dröge + + * gst/playback/gstplaybasebin.c: (set_audio_mute), + (set_active_source): + * gst/playback/gstplaybasebin.h: + * gst/playback/gstplaybin.c: (gst_play_bin_class_init), + (playbin_set_audio_mute): + Allow setting -1 as current-audio to mute the current audio stream, + similar to what is done for subtitles. Fixes bug #342294. + 2008-05-05 Edward Hervey * gst-libs/gst/pbutils/descriptions.c: (formats): diff --git a/gst/playback/gstplaybasebin.c b/gst/playback/gstplaybasebin.c index b09c550bda..58de4c598c 100644 --- a/gst/playback/gstplaybasebin.c +++ b/gst/playback/gstplaybasebin.c @@ -2400,6 +2400,17 @@ set_subtitles_visible (GstPlayBaseBin * play_base_bin, gboolean visible) klass->set_subtitles_visible (play_base_bin, visible); } +static void +set_audio_mute (GstPlayBaseBin * play_base_bin, gboolean mute) +{ + GstPlayBaseBinClass *klass = GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin); + + /* we use a vfunc for this since we don't have a reference to the + * textoverlay element, but playbin does */ + if (klass != NULL && klass->set_audio_mute != NULL) + klass->set_audio_mute (play_base_bin, mute); +} + /* * Caller has group-lock held. */ @@ -2432,6 +2443,13 @@ set_active_source (GstPlayBaseBin * play_base_bin, set_subtitles_visible (play_base_bin, visible); if (!visible) return; + } else if (type == GST_STREAM_TYPE_AUDIO) { + gboolean mute = (source_num == -1); + + set_audio_mute (play_base_bin, mute); + + if (mute) + return; } sel = group->type[type - 1].selector; diff --git a/gst/playback/gstplaybasebin.h b/gst/playback/gstplaybasebin.h index 0767a9ac64..256ba66a17 100644 --- a/gst/playback/gstplaybasebin.h +++ b/gst/playback/gstplaybasebin.h @@ -113,6 +113,8 @@ struct _GstPlayBaseBinClass { void (*set_subtitles_visible) (GstPlayBaseBin *play_base_bin, gboolean visible); + void (*set_audio_mute) (GstPlayBaseBin *play_base_bin, + gboolean mute); }; GType gst_play_base_bin_get_type (void); diff --git a/gst/playback/gstplaybin.c b/gst/playback/gstplaybin.c index 156d3cbde2..90f9d3eaef 100644 --- a/gst/playback/gstplaybin.c +++ b/gst/playback/gstplaybin.c @@ -326,6 +326,8 @@ static gboolean setup_sinks (GstPlayBaseBin * play_base_bin, static void remove_sinks (GstPlayBin * play_bin); static void playbin_set_subtitles_visible (GstPlayBaseBin * play_base_bin, gboolean visible); +static void playbin_set_audio_mute (GstPlayBaseBin * play_base_bin, + gboolean mute); static void gst_play_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * spec); @@ -431,6 +433,7 @@ gst_play_bin_class_init (GstPlayBinClass * klass) playbasebin_klass->setup_output_pads = setup_sinks; playbasebin_klass->set_subtitles_visible = playbin_set_subtitles_visible; + playbasebin_klass->set_audio_mute = playbin_set_audio_mute; } static void @@ -1642,6 +1645,16 @@ playbin_set_subtitles_visible (GstPlayBaseBin * play_base_bin, gboolean visible) } } +static void +playbin_set_audio_mute (GstPlayBaseBin * play_base_bin, gboolean mute) +{ + GstPlayBin *playbin = GST_PLAY_BIN (play_base_bin); + + if (playbin->volume_element) { + g_object_set (G_OBJECT (playbin->volume_element), "mute", mute, NULL); + } +} + /* Send an event to our sinks until one of them works; don't then send to the * remaining sinks (unlike GstBin) */