summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-03-17 12:21:16 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-24 10:19:52 +0000
commitf785c7ecc87435f64a218f9e1a48d35262ec0fb5 (patch)
tree24daa562c95ac06b574bb4863fef481d18a44d88
parentc2728179ddd42793319988cc3e6014ee1971c1cf (diff)
Resolves: tdf#96989 videos playback at maximum possible volume
On systems with flat-volumes then setting the volume directly on the playbin to 100% results in resetting the global volume to the maximum possible volume. We expect to set as % of the current system volume. Putting an intermediate volume object into the pipeline does the more expected thing. Change-Id: I911d6fffba0983e4fd7b455e820959a96115de34 (cherry picked from commit d4b48e0de7f817c0d4607382724778acf191f9f8) Reviewed-on: https://gerrit.libreoffice.org/23326 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--avmedia/source/gstreamer/gstplayer.cxx28
-rw-r--r--avmedia/source/gstreamer/gstplayer.hxx1
2 files changed, 23 insertions, 6 deletions
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx
index 310cf9bb7eeb..8631e6a43bb8 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -282,6 +282,7 @@ Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
GstPlayer_BASE( m_aMutex ),
mxMgr( rxMgr ),
mpPlaybin( nullptr ),
+ mpVolumeControl( nullptr ),
#if defined(ENABLE_GTKSINK)
mpGtkWidget( nullptr ),
#endif
@@ -355,6 +356,7 @@ void SAL_CALL Player::disposing()
g_object_unref( G_OBJECT( mpPlaybin ) );
mpPlaybin = nullptr;
+ mpVolumeControl = nullptr;
}
if( mpXOverlay ) {
@@ -597,6 +599,20 @@ void Player::preparePlaybin( const OUString& rURL, GstElement *pSink )
}
mpPlaybin = gst_element_factory_make( "playbin", nullptr );
+
+ //tdf#96989 on systems with flat-volumes setting the volume directly on the
+ //playbin to 100% results in setting the global volums to 100% of the
+ //maximum. We expect to set as % of the current volume.
+ 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));
+ g_object_set(G_OBJECT(mpPlaybin), "audio-sink", pAudioOutput, nullptr);
+
if( pSink != nullptr ) // used for getting preferred size etc.
{
g_object_set( G_OBJECT( mpPlaybin ), "video-sink", pSink, nullptr );
@@ -796,7 +812,7 @@ void SAL_CALL Player::setMute( sal_Bool bSet )
nVolume = 0.0;
}
- g_object_set( G_OBJECT( mpPlaybin ), "volume", nVolume, nullptr );
+ g_object_set( G_OBJECT( mpVolumeControl ), "volume", nVolume, nullptr );
mbMuted = bSet;
}
@@ -824,10 +840,10 @@ void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
SAL_INFO( "avmedia.gstreamer", AVVERSION "set volume: " << nVolumeDB << " gst volume: " << mnUnmutedVolume );
// change volume
- if( !mbMuted && mpPlaybin )
- {
- g_object_set( G_OBJECT( mpPlaybin ), "volume", (gdouble) mnUnmutedVolume, nullptr );
- }
+ if( !mbMuted && mpPlaybin )
+ {
+ g_object_set( G_OBJECT( mpVolumeControl ), "volume", mnUnmutedVolume, nullptr );
+ }
}
@@ -842,7 +858,7 @@ sal_Int16 SAL_CALL Player::getVolumeDB()
if( mpPlaybin ) {
double nGstVolume = 0.0;
- g_object_get( G_OBJECT( mpPlaybin ), "volume", &nGstVolume, nullptr );
+ g_object_get( G_OBJECT( mpVolumeControl ), "volume", &nGstVolume, nullptr );
nVolumeDB = (sal_Int16) ( 20.0*log10 ( nGstVolume ) );
}
diff --git a/avmedia/source/gstreamer/gstplayer.hxx b/avmedia/source/gstreamer/gstplayer.hxx
index ffc513362655..9c8b3e6d7b1e 100644
--- a/avmedia/source/gstreamer/gstplayer.hxx
+++ b/avmedia/source/gstreamer/gstplayer.hxx
@@ -87,6 +87,7 @@ protected:
// Add elements and pipeline here
GstElement* mpPlaybin; // the playbin is also a pipeline
+ GstElement* mpVolumeControl; // the playbin is also a pipeline
#if defined(ENABLE_GTKSINK)
GtkWidget* mpGtkWidget;
#endif