[Libreoffice-commits] core.git: avmedia/source

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 12 23:49:07 UTC 2019


 avmedia/source/gstreamer/gstplayer.cxx |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 5e6af47dc87a55fea595c952ea3e59c93d0620db
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 01:47:48 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>

diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 63c88b712424..f88addd0cfef 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -580,11 +580,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.
@@ -759,7 +766,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 )
@@ -791,7 +798,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 );
     }
@@ -804,7 +811,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