[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - avmedia/source
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 13 02:27:17 UTC 2019
avmedia/source/gstreamer/gstplayer.cxx | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
New commits:
commit 142696e71e15db3c112796c43630bdfa6c634fa0
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Wed Jun 12 00:54:04 2019 +0200
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Thu Jun 13 04:26:46 2019 +0200
tdf#125821 don't crash on missing gstreamer plugins
If GStreamer can't auto-detect an audio sink via "autoaudiosink",
it'll return a nullptr. If the volume plugin is missing, then this
currently also results in a crash.
So check the gst_element_factory_make results before using the
objects and change some wrong mpPlaybin checks to the right
mpVolumeControl ones.
This works for me without any audio and volume plugins. Since we
are linked against libgstaudio, I assume the bin is always there.
Change-Id: Ide526363d810ea48d0a62539c0a435553783e34a
Reviewed-on: https://gerrit.libreoffice.org/73848
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
(cherry picked from commit 5e6af47dc87a55fea595c952ea3e59c93d0620db)
Reviewed-on: https://gerrit.libreoffice.org/73919
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index b2e5382353f9..250f924f5096 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -665,11 +665,18 @@ void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
mpVolumeControl = gst_element_factory_make( "volume", nullptr );
GstElement *pAudioSink = gst_element_factory_make( "autoaudiosink", nullptr );
GstElement* pAudioOutput = gst_bin_new("audio-output-bin");
- gst_bin_add_many(GST_BIN(pAudioOutput), mpVolumeControl, pAudioSink, nullptr);
- gst_element_link(mpVolumeControl, pAudioSink);
- GstPad *pPad = gst_element_get_static_pad(mpVolumeControl, "sink");
- gst_element_add_pad(GST_ELEMENT(pAudioOutput), gst_ghost_pad_new("sink", pPad));
- gst_object_unref(GST_OBJECT(pPad));
+ assert(pAudioOutput);
+ if (pAudioSink)
+ gst_bin_add(GST_BIN(pAudioOutput), pAudioSink);
+ if (mpVolumeControl)
+ {
+ gst_bin_add(GST_BIN(pAudioOutput), mpVolumeControl);
+ if (pAudioSink)
+ gst_element_link(mpVolumeControl, pAudioSink);
+ GstPad *pPad = gst_element_get_static_pad(mpVolumeControl, "sink");
+ gst_element_add_pad(GST_ELEMENT(pAudioOutput), gst_ghost_pad_new("sink", pPad));
+ gst_object_unref(GST_OBJECT(pPad));
+ }
g_object_set(G_OBJECT(mpPlaybin), "audio-sink", pAudioOutput, nullptr);
if( pSink != nullptr ) // used for getting preferred size etc.
@@ -848,7 +855,7 @@ void SAL_CALL Player::setMute( sal_Bool bSet )
SAL_INFO( "avmedia.gstreamer", AVVERSION "set mute: " << bSet << " muted: " << mbMuted << " unmuted volume: " << mnUnmutedVolume );
// change the volume to 0 or the unmuted volume
- if( mpPlaybin && mbMuted != bool(bSet) )
+ if (mpVolumeControl && mbMuted != bool(bSet))
{
double nVolume = mnUnmutedVolume;
if( bSet )
@@ -880,7 +887,7 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
SAL_INFO( "avmedia.gstreamer", AVVERSION "set volume: " << nVolumeDB << " gst volume: " << mnUnmutedVolume );
// change volume
- if( !mbMuted && mpPlaybin )
+ if (mpVolumeControl && !mbMuted)
{
g_object_set( G_OBJECT( mpVolumeControl ), "volume", mnUnmutedVolume, nullptr );
}
@@ -893,7 +900,8 @@ sal_Int16 SAL_CALL Player::getVolumeDB()
sal_Int16 nVolumeDB(0);
- if( mpPlaybin ) {
+ if (mpVolumeControl)
+ {
double nGstVolume = 0.0;
g_object_get( G_OBJECT( mpVolumeControl ), "volume", &nGstVolume, nullptr );
More information about the Libreoffice-commits
mailing list