diff options
Diffstat (limited to 'Source')
4 files changed, 25 insertions, 2 deletions
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp index 395aabe80..6d5d6ee72 100644 --- a/Source/WebCore/html/HTMLMediaElement.cpp +++ b/Source/WebCore/html/HTMLMediaElement.cpp @@ -265,6 +265,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum , 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_lastTimeUpdateEventWallTime(0) @@ -2736,6 +2737,7 @@ void HTMLMediaElement::setVolume(double vol, ExceptionCode& ec) if (m_volume != vol) { m_volume = vol; + m_volumeInitialized = true; updateVolume(); scheduleEvent(eventNames().volumechangeEvent); } @@ -4000,7 +4002,8 @@ void HTMLMediaElement::updateVolume() } m_player->setMuted(shouldMute); - m_player->setVolume(m_volume * volumeMultiplier); + if (m_volumeInitialized) + m_player->setVolume(m_volume * volumeMultiplier); } if (hasMediaControls()) @@ -5104,6 +5107,11 @@ void HTMLMediaElement::mediaPlayerPlay() play(); } +bool HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired() const +{ + return !m_volumeInitialized; +} + bool HTMLMediaElement::mediaPlayerIsPaused() const { return paused(); diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h index 66bd638b5..be8a7b1e8 100644 --- a/Source/WebCore/html/HTMLMediaElement.h +++ b/Source/WebCore/html/HTMLMediaElement.h @@ -504,6 +504,7 @@ private: 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; @@ -640,6 +641,7 @@ private: RefPtr<MediaError> m_error; double m_volume; + bool m_volumeInitialized; double m_lastSeekTime; unsigned m_previousProgress; diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h index 92734cab5..df9d2a108 100644 --- a/Source/WebCore/platform/graphics/MediaPlayer.h +++ b/Source/WebCore/platform/graphics/MediaPlayer.h @@ -213,6 +213,7 @@ public: 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; } @@ -327,6 +328,7 @@ public: double volume() const; void setVolume(double); + bool platformVolumeConfigurationRequired() const { return m_mediaPlayerClient->mediaPlayerPlatformVolumeConfigurationRequired(); } bool muted() const; void setMuted(bool); diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp index 8f6077de1..83c896c39 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp @@ -76,6 +76,7 @@ static int greatestCommonDivisor(int a, int b) 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 @@ void MediaPlayerPrivateGStreamerBase::setVolume(float volume) 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,7 +620,16 @@ void MediaPlayerPrivateGStreamerBase::setStreamVolumeElement(GstStreamVolume* vo 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); |