Exemple #1
0
void AudioInjector::restart() {
    // grab the AudioInjectorManager
    auto injectorManager = DependencyManager::get<AudioInjectorManager>();

    if (thread() != QThread::currentThread()) {
        QMetaObject::invokeMethod(this, "restart");

        if (!_options.localOnly) {
            // notify the AudioInjectorManager to wake up in case it's waiting for new injectors
            injectorManager->notifyInjectorReadyCondition();
        }

        return;
    }

    // reset the current send offset to zero
    _currentSendOffset = 0;

    // reset state to start sending from beginning again
    _nextFrame = 0;
    if (_frameTimer) {
        _frameTimer->invalidate();
    }
    _hasSentFirstFrame = false;

    // check our state to decide if we need extra handling for the restart request
    if (stateHas(AudioInjectorState::Finished)) {
        // we finished playing, need to reset state so we can get going again
        _hasSetup = false;
        _shouldStop = false;
        _state = AudioInjectorState::NotFinished;

        // call inject audio to start injection over again
        setupInjection();

        // inject locally
        if(injectLocally()) {

            // if not localOnly, wake the AudioInjectorManager back up if it is stuck waiting
            if (!_options.localOnly) {

                if (!injectorManager->restartFinishedInjector(this)) {
                    _state = AudioInjectorState::Finished; // we're not playing, so reset the state used by isPlaying.
                }
            }
        } else {
            _state = AudioInjectorState::Finished; // we failed to play, so we are finished again
        }
    }
}
Exemple #2
0
void AudioInjector::restart() {
    // grab the AudioInjectorManager
    auto injectorManager = DependencyManager::get<AudioInjectorManager>();
    
    if (thread() != QThread::currentThread()) {
        QMetaObject::invokeMethod(this, "restart");
        
        if (!_options.localOnly) {
            // notify the AudioInjectorManager to wake up in case it's waiting for new injectors
            injectorManager->notifyInjectorReadyCondition();
        }
        
        return;
    }
    
    // reset the current send offset to zero
    _currentSendOffset = 0;
    
    // check our state to decide if we need extra handling for the restart request
    if (_state == State::Finished) {
        // we finished playing, need to reset state so we can get going again
        _hasSetup = false;
        _shouldStop = false;
        _state = State::NotFinished;
        
        // call inject audio to start injection over again
        setupInjection();
        
        // if we're a local injector call inject locally to start injecting again
        if (_options.localOnly) {
            injectLocally();
        } else {
            // wake the AudioInjectorManager back up if it's stuck waiting
            injectorManager->restartFinishedInjector(this);
        }
    }
}