⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244771 in webkit


Ignore:
Timestamp:
Apr 30, 2019, 8:03:38 AM (7 years ago)
Author:
youenn@apple.com
Message:

Refactor AudioContext to register/unregister itself at construction/destruction time
https://bugs.webkit.org/show_bug.cgi?id=197383

Reviewed by Eric Carlson.

Registering/Unregistering is cheap.
Instead of registering/unregistering in initialize/uninitialize,
move this code to constructor/destructor.
No observable change of behavior.

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::AudioContext):
(WebCore::AudioContext::~AudioContext):
(WebCore::AudioContext::lazyInitialize):
(WebCore::AudioContext::uninitialize):
(WebCore::AudioContext::visibilityStateChanged):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244768 r244771  
     12019-04-30  Youenn Fablet  <youenn@apple.com>
     2
     3        Refactor AudioContext to register/unregister itself at construction/destruction time
     4        https://bugs.webkit.org/show_bug.cgi?id=197383
     5
     6        Reviewed by Eric Carlson.
     7
     8        Registering/Unregistering is cheap.
     9        Instead of registering/unregistering in initialize/uninitialize,
     10        move this code to constructor/destructor.
     11        No observable change of behavior.
     12
     13        * Modules/webaudio/AudioContext.cpp:
     14        (WebCore::AudioContext::AudioContext):
     15        (WebCore::AudioContext::~AudioContext):
     16        (WebCore::AudioContext::lazyInitialize):
     17        (WebCore::AudioContext::uninitialize):
     18        (WebCore::AudioContext::visibilityStateChanged):
     19
    1202019-04-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    221
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r243887 r244771  
    148148    // Initialize the destination node's muted state to match the page's current muted state.
    149149    pageMutedStateDidChange();
     150
     151    if (!isOfflineContext()) {
     152        document.addAudioProducer(*this);
     153        document.registerForVisibilityStateChangedCallbacks(*this);
     154    }
    150155}
    151156
     
    203208    ASSERT(m_renderingAutomaticPullNodes.isEmpty());
    204209    // FIXME: Can we assert that m_deferredFinishDerefList is empty?
     210
     211    if (!isOfflineContext() && scriptExecutionContext()) {
     212        document()->removeAudioProducer(*this);
     213        document()->unregisterForVisibilityStateChangedCallbacks(*this);
     214    }
    205215}
    206216
     
    219229
    220230        if (!isOfflineContext()) {
    221             document()->addAudioProducer(*this);
    222             document()->registerForVisibilityStateChangedCallbacks(*this);
    223 
    224231            // This starts the audio thread. The destination node's provideInput() method will now be called repeatedly to render audio.
    225232            // Each time provideInput() is called, a portion of the audio stream is rendered. Let's call this time period a "render quantum".
     
    266273
    267274    if (!isOfflineContext()) {
    268         document()->removeAudioProducer(*this);
    269         document()->unregisterForVisibilityStateChangedCallbacks(*this);
    270 
    271275        ASSERT(s_hardwareContextCount);
    272276        --s_hardwareContextCount;
     
    379383{
    380384    // Do not suspend if audio is audible.
    381     if (mediaState() == MediaProducer::IsPlayingAudio)
     385    if (mediaState() == MediaProducer::IsPlayingAudio || m_isStopScheduled)
    382386        return;
    383387
Note: See TracChangeset for help on using the changeset viewer.