summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-06-12 00:54:04 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2019-06-13 04:26:46 +0200
commit142696e71e15db3c112796c43630bdfa6c634fa0 (patch)
tree2a88cf827acad4fa165ce7a987f961aedd5c4aa8
parenttdf#125517 Qt5 implement a minimal Qt5ObjectWindow (diff)
downloadcore-142696e71e15db3c112796c43630bdfa6c634fa0.tar.gz
core-142696e71e15db3c112796c43630bdfa6c634fa0.zip
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@fbihome.de> (cherry picked from commit 5e6af47dc87a55fea595c952ea3e59c93d0620db) Reviewed-on: https://gerrit.libreoffice.org/73919
-rw-r--r--avmedia/source/gstreamer/gstplayer.cxx24
1 files changed, 16 insertions, 8 deletions
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 );