void QSoundEffectPrivate::setSource(const QUrl &url)
{
#ifdef QT_QAUDIO_DEBUG
    qDebug() << this << "setSource current=" << d->m_url << ", to=" << url;
#endif
    Q_ASSERT(d->m_url != url);

    stop();

    d->m_url = url;

    d->m_sampleReady = false;

    if (url.isEmpty()) {
        setStatus(QSoundEffect::Null);
        return;
    }

    if (!url.isValid()) {
        setStatus(QSoundEffect::Error);
        return;
    }

    if (d->m_sample) {
        if (!d->m_sampleReady) {
            disconnect(d->m_sample, SIGNAL(error()), d, SLOT(decoderError()));
            disconnect(d->m_sample, SIGNAL(ready()), d, SLOT(sampleReady()));
        }
        d->m_sample->release();
        d->m_sample = 0;
    }

    setStatus(QSoundEffect::Loading);
    d->m_sample = sampleCache()->requestSample(url);
    connect(d->m_sample, SIGNAL(error()), d, SLOT(decoderError()));
    connect(d->m_sample, SIGNAL(ready()), d, SLOT(sampleReady()));

    switch (d->m_sample->state()) {
    case QSample::Ready:
        d->sampleReady();
        break;
    case QSample::Error:
        d->decoderError();
        break;
    default:
        break;
    }
}
VideoSurfaceFilter::VideoSurfaceFilter(
        QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent)
    : QObject(parent)
    , m_ref(1)
    , m_state(State_Stopped)
    , m_surface(surface)
    , m_loop(loop)
    , m_graph(0)
    , m_peerPin(0)
    , m_bytesPerLine(0)
    , m_startResult(S_OK)
    , m_pinId(QString::fromLatin1("reference"))
    , m_sampleScheduler(static_cast<IPin *>(this))
{
    connect(surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged()));
    connect(&m_sampleScheduler, SIGNAL(sampleReady()), this, SLOT(sampleReady()));
}
void PrivateSoundSource::decoderError()
{
    qWarning("QSoundEffect(qaudio): Error decoding source");
    disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
    disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError()));
    m_playing = false;
    soundeffect->setStatus(QSoundEffect::Error);
}
void SpectrumAnalyser::sampleLoaded(const FrequencySpectrum &sample)
{
    Q_ASSERT(Idle != m_state);
    if (Busy == m_state)
    {
        emit sampleReady(sample);
    }
    m_state = Idle;
}
Example #5
0
bool DirectShowSampleScheduler::event(QEvent *event)
{
    if (event->type() == QEvent::UpdateRequest) {
        emit sampleReady();

        return true;
    } else {
        return QObject::event(event);
    }
}
Example #6
0
bool DirectShowSampleScheduler::event(QEvent *event)
{
    if (event->type() == QEvent::WinEventAct) {
        QObject::event(event);

        emit sampleReady();

        return true;
    } else {
        return QWinEventNotifier::event(event);
    }
}
void PrivateSoundSource::sampleReady()
{
    if (m_status == QSoundEffect::Error)
        return;

#ifdef QT_QAUDIO_DEBUG
    qDebug() << this << "sampleReady "<<m_playing;
#endif
    disconnect(m_sample, SIGNAL(error()), this, SLOT(decoderError()));
    disconnect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
    if (!m_audioOutput) {
        m_audioOutput = new QAudioOutput(m_sample->format());
        connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State)));
        if (!m_muted)
            m_audioOutput->setVolume(m_volume/100.0f);
        else
            m_audioOutput->setVolume(0);
    }
    m_sampleReady = true;
    soundeffect->setStatus(QSoundEffect::Ready);

    if (m_playing)
        m_audioOutput->start(this);
}