Changeset 175526 in webkit


Ignore:
Timestamp:
Nov 4, 2014 1:29:13 AM (9 years ago)
Author:
Philippe Normand
Message:

[LEAK] [GStreamer] Removing video element will not free assigned memory
https://bugs.webkit.org/show_bug.cgi?id=46560

Reviewed by Eric Carlson.

Moved the ::extraMemoryCost() implementation to the
MediaPlayerPivateInterface base class. This default implementation
is now shared between the various MediaPlayerPrivate backends,
excepted the AVF MediaSource player which still reports no extra
memory cost.

  • platform/graphics/MediaPlayerPrivate.h:

(WebCore::MediaPlayerPrivateInterface::totalBytes): Make
totalBytes() part of the MediaPlayerPrivate interface.
(WebCore::MediaPlayerPrivateInterface::extraMemoryCost): Default
implementation.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::extraMemoryCost): Deleted.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175525 r175526  
     12014-11-03  Philippe Normand  <pnormand@igalia.com>
     2
     3        [LEAK] [GStreamer] Removing video element will not free assigned memory
     4        https://bugs.webkit.org/show_bug.cgi?id=46560
     5
     6        Reviewed by Eric Carlson.
     7
     8        Moved the ::extraMemoryCost() implementation to the
     9        MediaPlayerPivateInterface base class. This default implementation
     10        is now shared between the various MediaPlayerPrivate backends,
     11        excepted the AVF MediaSource player which still reports no extra
     12        memory cost.
     13
     14        * platform/graphics/MediaPlayerPrivate.h:
     15        (WebCore::MediaPlayerPrivateInterface::totalBytes): Make
     16        totalBytes() part of the MediaPlayerPrivate interface.
     17        (WebCore::MediaPlayerPrivateInterface::extraMemoryCost): Default
     18        implementation.
     19        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     20        (WebCore::MediaPlayerPrivateAVFoundation::extraMemoryCost): Deleted.
     21        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     22        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     23
    1242014-11-04  Nikos Andronikos  <nikos.andronikos-webkit@cisra.canon.com.au>
    225
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r175400 r175526  
    126126    virtual std::unique_ptr<PlatformTimeRanges> buffered() const { return PlatformTimeRanges::create(); }
    127127
    128     virtual unsigned totalBytes() const { return 0; }
     128    virtual unsigned long long totalBytes() const { return 0; }
    129129    virtual bool didLoadingProgress() const { return false; }
    130130
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r173931 r175526  
    131131    virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0;
    132132
     133    virtual unsigned long long totalBytes() const { return 0; }
    133134    virtual bool didLoadingProgress() const = 0;
    134135
     
    241242    virtual String languageOfPrimaryAudioTrack() const { return emptyString(); }
    242243
    243     virtual size_t extraMemoryCost() const { return 0; }
    244    
     244    virtual size_t extraMemoryCost() const
     245    {
     246        MediaTime duration = this->durationMediaTime();
     247        if (!duration)
     248            return 0;
     249
     250        unsigned long long extra = totalBytes() * buffered()->totalDuration().toDouble() / duration.toDouble();
     251        return static_cast<unsigned>(extra);
     252    }
     253
    245254    virtual unsigned long long fileSize() const { return 0; }
    246255
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r174563 r175526  
    946946}
    947947
    948 size_t MediaPlayerPrivateAVFoundation::extraMemoryCost() const
    949 {
    950     MediaTime duration = this->durationMediaTime();
    951     if (!duration)
    952         return 0;
    953 
    954     unsigned long long extra = totalBytes() * buffered()->totalDuration().toDouble() / duration.toDouble();
    955     return static_cast<unsigned>(extra);
    956 }
    957 
    958948void MediaPlayerPrivateAVFoundation::clearTextTracks()
    959949{
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r173318 r175526  
    293293    virtual String engineDescription() const { return "AVFoundation"; }
    294294
    295     virtual size_t extraMemoryCost() const override;
    296 
    297295    virtual void trackModeChanged() override;
    298296#if ENABLE(AVF_CAPTIONS)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r174563 r175526  
    211211    , m_hasVideo(false)
    212212    , m_hasAudio(false)
    213     , m_totalBytes(-1)
     213    , m_totalBytes(0)
    214214    , m_preservesPitch(false)
    215215    , m_requestedState(GST_STATE_VOID_PENDING)
     
    12281228}
    12291229
    1230 unsigned MediaPlayerPrivateGStreamer::totalBytes() const
     1230unsigned long long MediaPlayerPrivateGStreamer::totalBytes() const
    12311231{
    12321232    if (m_errorOccured)
    12331233        return 0;
    12341234
    1235     if (m_totalBytes != -1)
     1235    if (m_totalBytes)
    12361236        return m_totalBytes;
    12371237
     
    12431243    if (gst_element_query_duration(m_source.get(), fmt, &length)) {
    12441244        INFO_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
    1245         m_totalBytes = static_cast<unsigned>(length);
     1245        m_totalBytes = static_cast<unsigned long long>(length);
    12461246        m_isStreaming = !length;
    12471247        return m_totalBytes;
     
    12781278
    12791279    INFO_MEDIA_MESSAGE("totalBytes %" G_GINT64_FORMAT, length);
    1280     m_totalBytes = static_cast<unsigned>(length);
     1280    m_totalBytes = static_cast<unsigned long long>(length);
    12811281    m_isStreaming = !length;
    12821282    return m_totalBytes;
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r174632 r175526  
    9393    float maxTimeSeekable() const;
    9494    bool didLoadingProgress() const;
    95     unsigned totalBytes() const;
     95    unsigned long long totalBytes() const;
    9696    float maxTimeLoaded() const;
    9797
     
    208208    GThreadSafeMainLoopSource m_videoCapsTimerHandler;
    209209    GThreadSafeMainLoopSource m_readyTimerHandler;
    210     mutable long m_totalBytes;
     210    mutable unsigned long long m_totalBytes;
    211211    URL m_url;
    212212    bool m_preservesPitch;
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h

    r174106 r175526  
    119119    MediaTime maxMediaTimeSeekable() const;
    120120    bool didLoadingProgress() const;
    121     unsigned totalBytes() const;
     121    unsigned long long totalBytes() const;
    122122   
    123123    void setVisible(bool);
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r175131 r175526  
    872872}
    873873
    874 unsigned MediaPlayerPrivateQTKit::totalBytes() const
     874unsigned long long MediaPlayerPrivateQTKit::totalBytes() const
    875875{
    876876    if (!metaDataAvailable())
    877877        return 0;
    878     return [[m_qtMovie.get() attributeForKey:QTMovieDataSizeAttribute] intValue];
     878    return [[m_qtMovie.get() attributeForKey:QTMovieDataSizeAttribute] longLongValue];
    879879}
    880880
Note: See TracChangeset for help on using the changeset viewer.