summaryrefslogtreecommitdiff
path: root/avmedia
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 01:47:48 +0200
commit5e6af47dc87a55fea595c952ea3e59c93d0620db (patch)
tree7bdfcba0807252150d8ff0e095e6b65ccc1dbf8c /avmedia
parent2dc6bdd1d5789ace0500cad90f5d2eb930888bb9 (diff)
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>
Diffstat (limited to 'avmedia')
-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 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 );