- Revision
- 154970
- Author
- calva...@igalia.com
- Date
- 2013-09-03 00:16:02 -0700 (Tue, 03 Sep 2013)
Log Message
[GStreamer] Video player sets system volume to 100%
https://bugs.webkit.org/show_bug.cgi?id=118974
Reviewed by Philippe Normand.
In order to preserve the system volume we need to keep track of
the volume being initialized in the HTMLMediaElement and then just
setting the volume to the sink when initializing the pipeline if
that volume was changed before.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialized
attribute to false.
(WebCore::HTMLMediaElement::setVolume): Set the attribute to true
when volume is changed.
(WebCore::HTMLMediaElement::updateVolume): Set the volume only if
volume was initialized.
(WebCore::HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired):
Platform volume configuration is required only if volume was not
initialized before.
* html/HTMLMediaElement.h: Added attribute and interface method.
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerPlatformVolumeConfigurationRequired):
Declared and added default implementation for the interface method.
(WebCore::MediaPlayer::platformVolumeConfigurationRequired):
Asked the client, meaning the HTMLMediaElement if the platform
volume configuration is required.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::mediaPlayerPrivateVolumeChangedCallback): Added log.
(WebCore::MediaPlayerPrivateGStreamerBase::setVolume): Added log.
(WebCore::MediaPlayerPrivateGStreamerBase::setStreamVolumeElement):
Set the volume only if not platform volume is required and added log.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154969 => 154970)
--- trunk/Source/WebCore/ChangeLog 2013-09-03 06:06:49 UTC (rev 154969)
+++ trunk/Source/WebCore/ChangeLog 2013-09-03 07:16:02 UTC (rev 154970)
@@ -1,3 +1,38 @@
+2013-09-03 Xabier Rodriguez Calvar <calva...@igalia.com>
+
+ [GStreamer] Video player sets system volume to 100%
+ https://bugs.webkit.org/show_bug.cgi?id=118974
+
+ Reviewed by Philippe Normand.
+
+ In order to preserve the system volume we need to keep track of
+ the volume being initialized in the HTMLMediaElement and then just
+ setting the volume to the sink when initializing the pipeline if
+ that volume was changed before.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement): Initialized
+ attribute to false.
+ (WebCore::HTMLMediaElement::setVolume): Set the attribute to true
+ when volume is changed.
+ (WebCore::HTMLMediaElement::updateVolume): Set the volume only if
+ volume was initialized.
+ (WebCore::HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired):
+ Platform volume configuration is required only if volume was not
+ initialized before.
+ * html/HTMLMediaElement.h: Added attribute and interface method.
+ * platform/graphics/MediaPlayer.h:
+ (WebCore::MediaPlayerClient::mediaPlayerPlatformVolumeConfigurationRequired):
+ Declared and added default implementation for the interface method.
+ (WebCore::MediaPlayer::platformVolumeConfigurationRequired):
+ Asked the client, meaning the HTMLMediaElement if the platform
+ volume configuration is required.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ (WebCore::mediaPlayerPrivateVolumeChangedCallback): Added log.
+ (WebCore::MediaPlayerPrivateGStreamerBase::setVolume): Added log.
+ (WebCore::MediaPlayerPrivateGStreamerBase::setStreamVolumeElement):
+ Set the volume only if not platform volume is required and added log.
+
2013-09-02 Darin Adler <da...@apple.com>
* inspector/InspectorProfilerAgent.cpp:
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (154969 => 154970)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-09-03 06:06:49 UTC (rev 154969)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-09-03 07:16:02 UTC (rev 154970)
@@ -267,6 +267,7 @@
, m_readyState(HAVE_NOTHING)
, m_readyStateMaximum(HAVE_NOTHING)
, m_volume(1.0f)
+ , m_volumeInitialized(false)
, m_lastSeekTime(0)
, m_previousProgressTime(numeric_limits<double>::max())
, m_clockTimeAtLastUpdateEvent(0)
@@ -2708,6 +2709,7 @@
if (m_volume != vol) {
m_volume = vol;
+ m_volumeInitialized = true;
updateVolume();
scheduleEvent(eventNames().volumechangeEvent);
}
@@ -3978,7 +3980,8 @@
}
m_player->setMuted(shouldMute);
- m_player->setVolume(m_volume * volumeMultiplier);
+ if (m_volumeInitialized)
+ m_player->setVolume(m_volume * volumeMultiplier);
}
if (hasMediaControls())
@@ -5081,6 +5084,11 @@
play();
}
+bool HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired() const
+{
+ return !m_volumeInitialized;
+}
+
bool HTMLMediaElement::mediaPlayerIsPaused() const
{
return paused();
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (154969 => 154970)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2013-09-03 06:06:49 UTC (rev 154969)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2013-09-03 07:16:02 UTC (rev 154970)
@@ -507,6 +507,7 @@
virtual void mediaPlayerSetSize(const IntSize&) OVERRIDE;
virtual void mediaPlayerPause() OVERRIDE;
virtual void mediaPlayerPlay() OVERRIDE;
+ virtual bool mediaPlayerPlatformVolumeConfigurationRequired() const OVERRIDE;
virtual bool mediaPlayerIsPaused() const OVERRIDE;
virtual bool mediaPlayerIsLooping() const OVERRIDE;
virtual HostWindow* mediaPlayerHostWindow() OVERRIDE;
@@ -638,6 +639,7 @@
RefPtr<MediaError> m_error;
double m_volume;
+ bool m_volumeInitialized;
double m_lastSeekTime;
unsigned m_previousProgress;
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (154969 => 154970)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2013-09-03 06:06:49 UTC (rev 154969)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2013-09-03 07:16:02 UTC (rev 154970)
@@ -214,6 +214,7 @@
virtual void mediaPlayerSetSize(const IntSize&) { }
virtual void mediaPlayerPause() { }
virtual void mediaPlayerPlay() { }
+ virtual bool mediaPlayerPlatformVolumeConfigurationRequired() const { return false; }
virtual bool mediaPlayerIsPaused() const { return true; }
virtual bool mediaPlayerIsLooping() const { return false; }
virtual HostWindow* mediaPlayerHostWindow() { return 0; }
@@ -329,6 +330,7 @@
double volume() const;
void setVolume(double);
+ bool platformVolumeConfigurationRequired() const { return m_mediaPlayerClient->mediaPlayerPlatformVolumeConfigurationRequired(); }
bool muted() const;
void setMuted(bool);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (154969 => 154970)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2013-09-03 06:06:49 UTC (rev 154969)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2013-09-03 07:16:02 UTC (rev 154970)
@@ -76,6 +76,7 @@
static void mediaPlayerPrivateVolumeChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamerBase* player)
{
// This is called when m_volumeElement receives the notify::volume signal.
+ LOG_MEDIA_MESSAGE("Volume changed to: %f", player->volume());
player->volumeChanged();
}
@@ -234,6 +235,7 @@
if (!m_volumeElement)
return;
+ LOG_MEDIA_MESSAGE("Setting volume: %f", volume);
gst_stream_volume_set_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC, static_cast<double>(volume));
}
@@ -618,8 +620,17 @@
ASSERT(!m_volumeElement);
m_volumeElement = volume;
- g_object_set(m_volumeElement.get(), "mute", m_player->muted(), "volume", m_player->volume(), NULL);
+ // We don't set the initial volume because we trust the sink to keep it for us. See
+ // https://bugs.webkit.org/show_bug.cgi?id=118974 for more information.
+ if (!m_player->platformVolumeConfigurationRequired()) {
+ LOG_MEDIA_MESSAGE("Setting stream volume to %f", m_player->volume());
+ g_object_set(m_volumeElement.get(), "volume", m_player->volume(), NULL);
+ } else
+ LOG_MEDIA_MESSAGE("Not setting stream volume, trusting system one");
+ LOG_MEDIA_MESSAGE("Setting stream muted %d", m_player->muted());
+ g_object_set(m_volumeElement.get(), "mute", m_player->muted(), NULL);
+
m_volumeSignalHandler = g_signal_connect(m_volumeElement.get(), "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this);
m_muteSignalHandler = g_signal_connect(m_volumeElement.get(), "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this);
}