Changeset 154970 in webkit


Ignore:
Timestamp:
Sep 3, 2013 12:16:02 AM (11 years ago)
Author:
calvaris@igalia.com
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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r154968 r154970  
     12013-09-03  Xabier Rodriguez Calvar  <calvaris@igalia.com>
     2
     3        [GStreamer] Video player sets system volume to 100%
     4        https://bugs.webkit.org/show_bug.cgi?id=118974
     5
     6        Reviewed by Philippe Normand.
     7
     8        In order to preserve the system volume we need to keep track of
     9        the volume being initialized in the HTMLMediaElement and then just
     10        setting the volume to the sink when initializing the pipeline if
     11        that volume was changed before.
     12
     13        * html/HTMLMediaElement.cpp:
     14        (WebCore::HTMLMediaElement::HTMLMediaElement): Initialized
     15        attribute to false.
     16        (WebCore::HTMLMediaElement::setVolume): Set the attribute to true
     17        when volume is changed.
     18        (WebCore::HTMLMediaElement::updateVolume): Set the volume only if
     19        volume was initialized.
     20        (WebCore::HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired):
     21        Platform volume configuration is required only if volume was not
     22        initialized before.
     23        * html/HTMLMediaElement.h: Added attribute and interface method.
     24        * platform/graphics/MediaPlayer.h:
     25        (WebCore::MediaPlayerClient::mediaPlayerPlatformVolumeConfigurationRequired):
     26        Declared and added default implementation for the interface method.
     27        (WebCore::MediaPlayer::platformVolumeConfigurationRequired):
     28        Asked the client, meaning the HTMLMediaElement if the platform
     29        volume configuration is required.
     30        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     31        (WebCore::mediaPlayerPrivateVolumeChangedCallback): Added log.
     32        (WebCore::MediaPlayerPrivateGStreamerBase::setVolume): Added log.
     33        (WebCore::MediaPlayerPrivateGStreamerBase::setStreamVolumeElement):
     34        Set the volume only if not platform volume is required and added log.
     35
    1362013-09-02  Darin Adler  <darin@apple.com>
    237
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r154962 r154970  
    268268    , m_readyStateMaximum(HAVE_NOTHING)
    269269    , m_volume(1.0f)
     270    , m_volumeInitialized(false)
    270271    , m_lastSeekTime(0)
    271272    , m_previousProgressTime(numeric_limits<double>::max())
     
    27092710    if (m_volume != vol) {
    27102711        m_volume = vol;
     2712        m_volumeInitialized = true;
    27112713        updateVolume();
    27122714        scheduleEvent(eventNames().volumechangeEvent);
     
    39793981
    39803982        m_player->setMuted(shouldMute);
    3981         m_player->setVolume(m_volume * volumeMultiplier);
     3983        if (m_volumeInitialized)
     3984            m_player->setVolume(m_volume * volumeMultiplier);
    39823985    }
    39833986
     
    50825085}
    50835086
     5087bool HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired() const
     5088{
     5089    return !m_volumeInitialized;
     5090}
     5091
    50845092bool HTMLMediaElement::mediaPlayerIsPaused() const
    50855093{
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r154559 r154970  
    508508    virtual void mediaPlayerPause() OVERRIDE;
    509509    virtual void mediaPlayerPlay() OVERRIDE;
     510    virtual bool mediaPlayerPlatformVolumeConfigurationRequired() const OVERRIDE;
    510511    virtual bool mediaPlayerIsPaused() const OVERRIDE;
    511512    virtual bool mediaPlayerIsLooping() const OVERRIDE;
     
    639640
    640641    double m_volume;
     642    bool m_volumeInitialized;
    641643    double m_lastSeekTime;
    642644   
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r154921 r154970  
    215215    virtual void mediaPlayerPause() { }
    216216    virtual void mediaPlayerPlay() { }
     217    virtual bool mediaPlayerPlatformVolumeConfigurationRequired() const { return false; }
    217218    virtual bool mediaPlayerIsPaused() const { return true; }
    218219    virtual bool mediaPlayerIsLooping() const { return false; }
     
    330331    double volume() const;
    331332    void setVolume(double);
     333    bool platformVolumeConfigurationRequired() const { return m_mediaPlayerClient->mediaPlayerPlatformVolumeConfigurationRequired(); }
    332334
    333335    bool muted() const;
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r154088 r154970  
    7777{
    7878    // This is called when m_volumeElement receives the notify::volume signal.
     79    LOG_MEDIA_MESSAGE("Volume changed to: %f", player->volume());
    7980    player->volumeChanged();
    8081}
     
    235236        return;
    236237
     238    LOG_MEDIA_MESSAGE("Setting volume: %f", volume);
    237239    gst_stream_volume_set_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC, static_cast<double>(volume));
    238240}
     
    619621    m_volumeElement = volume;
    620622
    621     g_object_set(m_volumeElement.get(), "mute", m_player->muted(), "volume", m_player->volume(), NULL);
     623    // We don't set the initial volume because we trust the sink to keep it for us. See
     624    // https://bugs.webkit.org/show_bug.cgi?id=118974 for more information.
     625    if (!m_player->platformVolumeConfigurationRequired()) {
     626        LOG_MEDIA_MESSAGE("Setting stream volume to %f", m_player->volume());
     627        g_object_set(m_volumeElement.get(), "volume", m_player->volume(), NULL);
     628    } else
     629        LOG_MEDIA_MESSAGE("Not setting stream volume, trusting system one");
     630
     631    LOG_MEDIA_MESSAGE("Setting stream muted %d",  m_player->muted());
     632    g_object_set(m_volumeElement.get(), "mute", m_player->muted(), NULL);
    622633
    623634    m_volumeSignalHandler = g_signal_connect(m_volumeElement.get(), "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this);
Note: See TracChangeset for help on using the changeset viewer.