Exemplo n.º 1
0
void AudioContext::resume(Promise&& promise)
{
    if (isOfflineContext()) {
        promise.reject(INVALID_STATE_ERR);
        return;
    }

    if (m_state == State::Running) {
        promise.resolve(nullptr);
        return;
    }

    if (m_state == State::Closed || !m_destinationNode) {
        promise.reject(0);
        return;
    }

    addReaction(State::Running, WTFMove(promise));

    if (!willBeginPlayback())
        return;

    lazyInitialize();

    RefPtr<AudioContext> strongThis(this);
    m_destinationNode->resume([strongThis] {
        strongThis->setState(State::Running);
    });
}
Exemplo n.º 2
0
void AudioContext::suspend(Promise&& promise)
{
    if (isOfflineContext()) {
        promise.reject(INVALID_STATE_ERR);
        return;
    }

    if (m_state == State::Suspended) {
        promise.resolve(nullptr);
        return;
    }

    if (m_state == State::Closed || m_state == State::Interrupted || !m_destinationNode) {
        promise.reject(0);
        return;
    }

    addReaction(State::Suspended, WTFMove(promise));

    if (!willPausePlayback())
        return;

    lazyInitialize();

    RefPtr<AudioContext> strongThis(this);
    m_destinationNode->suspend([strongThis] {
        strongThis->setState(State::Suspended);
    });
}
Exemplo n.º 3
0
void AudioContext::isPlayingAudioDidChange()
{
    // Make sure to call Document::updateIsPlayingMedia() on the main thread, since
    // we could be on the audio I/O thread here and the call into WebCore could block.
    RefPtr<AudioContext> strongThis(this);
    callOnMainThread([strongThis] {
        if (strongThis->document())
            strongThis->document()->updateIsPlayingMedia();
    });
}
Exemplo n.º 4
0
	result AccessProviderImpl::Spread(const Call& call)
	{
		CoreMutexLock locker(CommonImpl< IAccessProvider >::GetLock());

		// Prevent destruction of this object during spreading event.
		IAccessProviderPtr strongThis( CommonImpl< IAccessProvider >::GetSelf() );

		// Walk through the entire list of access points and spread the event.
		for ( AccessPoints_::iterator iter = accessPoints_.begin() ; accessPoints_.end() != iter ; ++iter )
		{
			(*iter).second->Spread(call);
		}

		return _S_OK;
	}
Exemplo n.º 5
0
void AudioContext::suspendPlayback()
{
    if (!m_destinationNode || m_state == State::Closed)
        return;

    if (m_state == State::Suspended) {
        if (m_mediaSession->state() == PlatformMediaSession::Interrupted)
            setState(State::Interrupted);
        return;
    }

    lazyInitialize();

    RefPtr<AudioContext> strongThis(this);
    m_destinationNode->suspend([strongThis] {
        bool interrupted = strongThis->m_mediaSession->state() == PlatformMediaSession::Interrupted;
        strongThis->setState(interrupted ? State::Interrupted : State::Suspended);
    });
}
Exemplo n.º 6
0
void AudioContext::scheduleNodeDeletion()
{
    bool isGood = m_isInitialized && isGraphOwner();
    ASSERT(isGood);
    if (!isGood)
        return;

    // Make sure to call deleteMarkedNodes() on main thread.    
    if (m_nodesMarkedForDeletion.size() && !m_isDeletionScheduled) {
        m_nodesToDelete.appendVector(m_nodesMarkedForDeletion);
        m_nodesMarkedForDeletion.clear();

        m_isDeletionScheduled = true;

        RefPtr<AudioContext> strongThis(this);
        callOnMainThread([strongThis] {
            strongThis->deleteMarkedNodes();
        });
    }
}
Exemplo n.º 7
0
void AudioContext::mayResumePlayback(bool shouldResume)
{
    if (!m_destinationNode || m_state == State::Closed || m_state == State::Running)
        return;

    if (!shouldResume) {
        setState(State::Suspended);
        return;
    }

    if (!willBeginPlayback())
        return;

    lazyInitialize();

    RefPtr<AudioContext> strongThis(this);
    m_destinationNode->resume([strongThis] {
        strongThis->setState(State::Running);
    });
}
Exemplo n.º 8
0
void AudioContext::close(Promise&& promise)
{
    if (isOfflineContext()) {
        promise.reject(INVALID_STATE_ERR);
        return;
    }

    if (m_state == State::Closed || !m_destinationNode) {
        promise.resolve(nullptr);
        return;
    }

    addReaction(State::Closed, WTFMove(promise));

    lazyInitialize();

    RefPtr<AudioContext> strongThis(this);
    m_destinationNode->close([strongThis] {
        strongThis->setState(State::Closed);
        strongThis->uninitialize();
    });
}