diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-08 19:55:53 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-03-08 19:55:53 (GMT) |
commit | f1a6ef2898322b44be739be43d45d17ebbf90919 (patch) | |
tree | 5e84dd02f0260309c101e07e9be10bd8ad361f4d | |
parent | 1866cb339a53893792e4c3b894510feb7744324f (diff) | |
parent | 1f46c72e313f1e223e7abb81dea48f4f5f68ebf7 (diff) | |
download | Qt-f1a6ef2898322b44be739be43d45d17ebbf90919.zip Qt-f1a6ef2898322b44be739be43d45d17ebbf90919.tar.gz Qt-f1a6ef2898322b44be739be43d45d17ebbf90919.tar.bz2 |
Merge remote branch 'origin/4.7' into 4.7
Conflicts:
src/src.pro
-rw-r--r-- | demos/mainwindow/mainwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/egl/qegl_x11.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qmime_win.cpp | 2 | ||||
-rw-r--r-- | src/multimedia/effects/effects.pri | 4 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect.cpp | 89 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_p.h | 18 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_pulse_p.cpp | 177 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_pulse_p.h | 37 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_qmedia_p.cpp | 99 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_qmedia_p.h | 32 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_qsound_p.cpp | 154 | ||||
-rw-r--r-- | src/multimedia/effects/qsoundeffect_qsound_p.h | 53 | ||||
-rw-r--r-- | src/multimedia/effects/wavedecoder_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qgl_x11egl.cpp | 1 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml | 2 |
15 files changed, 211 insertions, 475 deletions
diff --git a/demos/mainwindow/mainwindow.cpp b/demos/mainwindow/mainwindow.cpp index 32066d7..3ddb74b 100644 --- a/demos/mainwindow/mainwindow.cpp +++ b/demos/mainwindow/mainwindow.cpp @@ -329,7 +329,7 @@ void MainWindow::setupDockWidgets(const QMap<QString, QSize> &customSizeHints) BlueTitleBar *titlebar = new BlueTitleBar(swatch); swatch->setTitleBarWidget(titlebar); connect(swatch, SIGNAL(topLevelChanged(bool)), titlebar, SLOT(updateMask())); - connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask())); + connect(swatch, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)), titlebar, SLOT(updateMask()), Qt::QueuedConnection); #ifdef Q_WS_QWS QPalette pal = palette(); diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp index 8608523..53c4711 100644 --- a/src/gui/egl/qegl_x11.cpp +++ b/src/gui/egl/qegl_x11.cpp @@ -41,18 +41,19 @@ #include <QtCore/qdebug.h> -#include <private/qt_x11_p.h> +#include <QtGui/private/qt_x11_p.h> #include <QtGui/qx11info_x11.h> -#include <private/qpixmapdata_p.h> -#include <private/qpixmap_x11_p.h> +#include <QtGui/private/qpixmapdata_p.h> +#include <QtGui/private/qpixmap_x11_p.h> +#include <QtGui/private/qimagepixmapcleanuphooks_p.h> #include <QtGui/qpaintdevice.h> #include <QtGui/qpixmap.h> #include <QtGui/qwidget.h> #include <QtGui/qcolormap.h> -#include "qegl_p.h" -#include "qeglcontext_p.h" +#include "QtGui/private/qegl_p.h" +#include "QtGui/private/qeglcontext_p.h" QT_BEGIN_NAMESPACE @@ -408,6 +409,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg (EGLNativePixmapType) x11PixmapData->handle(), surfaceAttribs.properties()); x11PixmapData->gl_surface = (Qt::HANDLE)surf; + QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData); return surf; } diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp index 39633bf..2840843 100644 --- a/src/gui/kernel/qmime_win.cpp +++ b/src/gui/kernel/qmime_win.cpp @@ -952,6 +952,8 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD QDataStream s(&ba, QIODevice::WriteOnly); s.setByteOrder(QDataStream::LittleEndian);// Intel byte order #### if (cf == CF_DIB) { + if (img.format() > QImage::Format_ARGB32) + img = img.convertToFormat(QImage::Format_RGB32); if (qt_write_dib(s, img)) return setData(ba, pmedium); } else { diff --git a/src/multimedia/effects/effects.pri b/src/multimedia/effects/effects.pri index ff762e8..be2b696 100644 --- a/src/multimedia/effects/effects.pri +++ b/src/multimedia/effects/effects.pri @@ -1,7 +1,7 @@ -unix { - unix:contains(QT_CONFIG, pulseaudio) { +unix:!mac { + contains(QT_CONFIG, pulseaudio) { DEFINES += QT_MULTIMEDIA_PULSEAUDIO HEADERS += $$PWD/qsoundeffect_pulse_p.h SOURCES += $$PWD/qsoundeffect_pulse_p.cpp diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp index 2694023..f64d9ee 100644 --- a/src/multimedia/effects/qsoundeffect.cpp +++ b/src/multimedia/effects/qsoundeffect.cpp @@ -39,9 +39,6 @@ ** ****************************************************************************/ -#include "qmediacontent.h" -#include "qmediaplayer.h" - #include "qsoundeffect_p.h" #if defined(QT_MULTIMEDIA_PULSEAUDIO) @@ -103,12 +100,6 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlproperty int SoundEffect::duration - - This property holds the duration in milliseconds of the current source audio. -*/ - -/*! \qmlsignal SoundEffect::sourceChanged() This handler is called when the source has changed. @@ -132,24 +123,13 @@ QT_BEGIN_NAMESPACE This handler is called when the mute state has changed. */ -/*! - \qmlsignal SoundEffect::durationChanged() - - This handler is called when the duration has changed. -*/ QSoundEffect::QSoundEffect(QObject *parent) : - QObject(parent), - m_loopCount(1), - m_vol(100), - m_muted(false), - m_runningCount(0) + QObject(parent) { d = new QSoundEffectPrivate(this); - connect(d, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); - connect(d, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); - connect(d, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged())); - connect(d, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(repeat())); + connect(d, SIGNAL(volumeChanged()), SIGNAL(volumeChanged())); + connect(d, SIGNAL(mutedChanged()), SIGNAL(mutedChanged())); } QSoundEffect::~QSoundEffect() @@ -159,97 +139,64 @@ QSoundEffect::~QSoundEffect() QUrl QSoundEffect::source() const { - return d != 0 ? d->media().canonicalUrl() : QUrl(); + return d->source(); } void QSoundEffect::setSource(const QUrl &url) { - if (d != 0 && d->media().canonicalUrl() == url) + if (d->source() == url) return; - d->setVolume(m_vol); - d->setMuted(m_muted); - d->setMedia(url); - - if (url.isEmpty()) - return; + d->setSource(url); emit sourceChanged(); } int QSoundEffect::loopCount() const { - return m_loopCount; + return d->loopCount(); } void QSoundEffect::setLoopCount(int loopCount) { - if (m_loopCount == loopCount) + if (d->loopCount() == loopCount) return; - m_loopCount = loopCount; + d->setLoopCount(loopCount); emit loopCountChanged(); } int QSoundEffect::volume() const { - return d != 0 ? d->volume() : m_vol; + return d->volume(); } void QSoundEffect::setVolume(int volume) { - if (m_vol == volume) + if (d->volume() == volume) return; - m_vol = volume; - if (d != 0) - d->setVolume(volume); - else - emit volumeChanged(); + d->setVolume(volume); + emit volumeChanged(); } bool QSoundEffect::isMuted() const { - return d != 0 ? d->isMuted() : m_muted; + return d->isMuted(); } void QSoundEffect::setMuted(bool muted) { - if (m_muted == muted) + if (d->isMuted() == muted) return; - m_muted = muted; - if (d != 0) - d->setMuted(muted); - else - emit mutedChanged(); -} - -int QSoundEffect::duration() const -{ - return d != 0 ? d->duration() : 0; + d->setMuted(muted); + emit mutedChanged(); } void QSoundEffect::play() { - m_runningCount = 0; - - if (d != 0) - d->play(); -} - -void QSoundEffect::stop() -{ - if (d != 0) - d->stop(); -} - -void QSoundEffect::repeat() -{ - if (d->state() == QMediaPlayer::StoppedState) { - if (++m_runningCount < m_loopCount) - d->play(); - } + d->play(); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_p.h b/src/multimedia/effects/qsoundeffect_p.h index c5554bf..ec6a2f7 100644 --- a/src/multimedia/effects/qsoundeffect_p.h +++ b/src/multimedia/effects/qsoundeffect_p.h @@ -70,7 +70,6 @@ class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount NOTIFY loopCountChanged) Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(int duration READ duration NOTIFY durationChanged) public: explicit QSoundEffect(QObject *parent = 0); @@ -88,30 +87,17 @@ public: bool isMuted() const; void setMuted(bool muted); - int duration() const; - -signals: +Q_SIGNALS: void sourceChanged(); void loopCountChanged(); void volumeChanged(); void mutedChanged(); - void durationChanged(); -public slots: +public Q_SLOTS: void play(); - void stop(); - -private slots: - void repeat(); private: Q_DISABLE_COPY(QSoundEffect) - - int m_loopCount; - int m_vol; - bool m_muted; - int m_runningCount; - QSoundEffectPrivate* d; }; diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/effects/qsoundeffect_pulse_p.cpp index d99bf4b..c322722 100644 --- a/src/multimedia/effects/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/effects/qsoundeffect_pulse_p.cpp @@ -55,10 +55,6 @@ #include <QtNetwork> #include <QTime> -#include "qmediacontent.h" -#include "qmediaplayer.h" -#include "qsoundeffect_p.h" - #include "wavedecoder_p.h" #include "qsoundeffect_pulse_p.h" @@ -240,11 +236,12 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), m_muted(false), m_playQueued(false), - m_vol(100), + m_sampleLoaded(false), + m_volume(100), m_duration(0), m_dataUploaded(0), - m_state(QMediaPlayer::StoppedState), - m_status(QMediaPlayer::NoMedia), + m_loopCount(1), + m_runningCount(0), m_reply(0), m_stream(0), m_networkAccessManager(0) @@ -257,76 +254,53 @@ QSoundEffectPrivate::~QSoundEffectPrivate() unloadSample(); } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - return m_duration; + return m_source; } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - return m_vol; -} + if (url.isEmpty()) { + m_source = QUrl(); + unloadSample(); + return; + } -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} + m_source = url; -QMediaContent QSoundEffectPrivate::media() const -{ - return m_media; + if (m_networkAccessManager == 0) + m_networkAccessManager = new QNetworkAccessManager(this); + + m_stream = m_networkAccessManager->get(QNetworkRequest(m_source)); + + unloadSample(); + loadSample(); } -QMediaPlayer::State QSoundEffectPrivate::state() const +int QSoundEffectPrivate::loopCount() const { - return m_state; + return m_loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +void QSoundEffectPrivate::setLoopCount(int loopCount) { - return m_status; + m_loopCount = loopCount; } -void QSoundEffectPrivate::play() +int QSoundEffectPrivate::volume() const { - if (m_status == QMediaPlayer::LoadingMedia) { - m_playQueued = true; - return; - } - - if (m_status != QMediaPlayer::BufferedMedia || - m_state == QMediaPlayer::PlayingState) - return; - - pa_volume_t m_vol = PA_VOLUME_NORM; - - daemon()->lock(); -#if defined(Q_WS_MAEMO_5) - m_vol = PA_VOLUME_NORM/100*((daemon()->volume()+m_vol)/2); -#endif - pa_operation_unref( - pa_context_play_sample(daemon()->context(), - m_name.constData(), - 0, - m_vol, - play_callback, - this) - ); - daemon()->unlock(); - - m_playbackTime.start(); - - emit stateChanged(m_state = QMediaPlayer::PlayingState); + return m_volume; } -void QSoundEffectPrivate::stop() +void QSoundEffectPrivate::setVolume(int volume) { - emit stateChanged(m_state = QMediaPlayer::StoppedState); + m_volume = volume; } -void QSoundEffectPrivate::setVolume(int volume) +bool QSoundEffectPrivate::isMuted() const { - m_vol = volume; + return m_muted; } void QSoundEffectPrivate::setMuted(bool muted) @@ -334,34 +308,23 @@ void QSoundEffectPrivate::setMuted(bool muted) m_muted = muted; } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) +void QSoundEffectPrivate::play() { - if (media.isNull()) { - m_media = QMediaContent(); - unloadSample(); + if (!m_sampleLoaded) { + m_playQueued = true; return; } - if (m_media == media) - return; - m_media = media; - - if (m_networkAccessManager == 0) - m_networkAccessManager = new QNetworkAccessManager(this); - m_stream = m_networkAccessManager->get(QNetworkRequest(m_media.canonicalUrl())); + m_runningCount += m_loopCount; - unloadSample(); - loadSample(); - - emit mediaChanged(m_media); + playSample(); } void QSoundEffectPrivate::decoderReady() { if (m_waveDecoder->size() >= PA_SCACHE_ENTRY_SIZE_MAX) { - m_status = QMediaPlayer::InvalidMedia; - emit mediaStatusChanged(m_status); - qWarning("QtPulseAudio: attempting to load to large a sample"); + m_waveDecoder->deleteLater(); + qWarning("QSoundEffect(pulseaudio): Attempting to load to large a sample"); return; } @@ -380,52 +343,65 @@ void QSoundEffectPrivate::decoderReady() void QSoundEffectPrivate::decoderError() { - emit mediaStatusChanged(m_status = QMediaPlayer::InvalidMedia); + qWarning("QSoundEffect(pulseaudio): Error decoding source"); } void QSoundEffectPrivate::checkPlayTime() { int elapsed = m_playbackTime.elapsed(); - if (elapsed >= m_duration) { - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } - else + if (elapsed < m_duration) startTimer(m_duration - elapsed); } void QSoundEffectPrivate::loadSample() { + m_sampleLoaded = false; + m_dataUploaded = 0; m_waveDecoder = new WaveDecoder(m_stream); connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); - - m_status = QMediaPlayer::LoadingMedia; - emit mediaStatusChanged(m_status); } void QSoundEffectPrivate::unloadSample() { - if (m_status != QMediaPlayer::BufferedMedia) + if (!m_sampleLoaded) return; - m_status = QMediaPlayer::NoMedia; - daemon()->lock(); pa_context_remove_sample(daemon()->context(), m_name.constData(), NULL, NULL); daemon()->unlock(); m_duration = 0; m_dataUploaded = 0; + m_sampleLoaded = false; +} + +void QSoundEffectPrivate::playSample() +{ + pa_volume_t volume = PA_VOLUME_NORM; + + daemon()->lock(); +#ifdef Q_WS_MAEMO_5 + volume = PA_VOLUME_NORM / 100 * ((daemon()->volume() + m_volume) / 2); +#endif + pa_operation_unref( + pa_context_play_sample(daemon()->context(), + m_name.constData(), + 0, + volume, + play_callback, + this) + ); + daemon()->unlock(); + + m_playbackTime.start(); } void QSoundEffectPrivate::timerEvent(QTimerEvent *event) { - if (m_state == QMediaPlayer::PlayingState) { - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } + if (m_runningCount > 0) + playSample(); killTimer(event->timerId()); } @@ -456,15 +432,11 @@ void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, voi pa_stream_finish_upload(s); self->m_duration = self->m_waveDecoder->duration(); - emit self->durationChanged(self->m_duration); - - self->m_status = QMediaPlayer::BufferedMedia; - emit self->mediaStatusChanged(self->m_status); self->m_waveDecoder->deleteLater(); - if (!self->m_media.isNull()) - self->m_stream->deleteLater(); + self->m_stream->deleteLater(); + self->m_sampleLoaded = true; if (self->m_playQueued) { self->m_playQueued = false; QMetaObject::invokeMethod(self, "play"); @@ -474,8 +446,6 @@ void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, voi void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) { - QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - switch (pa_stream_get_state(s)) { case PA_STREAM_CREATING: case PA_STREAM_READY: @@ -484,8 +454,7 @@ void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata) case PA_STREAM_FAILED: default: - self->m_status = QMediaPlayer::InvalidMedia; - emit self->mediaStatusChanged(self->m_status); + qWarning("QSoundEffect(pulseaudio): Error in pulse audio stream"); break; } } @@ -496,14 +465,10 @@ void QSoundEffectPrivate::play_callback(pa_context *c, int success, void *userda QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata); - if (success == 1) + if (success == 1) { + self->m_runningCount--; QMetaObject::invokeMethod(self, "checkPlayTime", Qt::QueuedConnection); - else { - self->m_state = QMediaPlayer::StoppedState; - emit self->stateChanged(self->m_state); } } QT_END_NAMESPACE - - diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.h b/src/multimedia/effects/qsoundeffect_pulse_p.h index 247f8a3..3aed018 100644 --- a/src/multimedia/effects/qsoundeffect_pulse_p.h +++ b/src/multimedia/effects/qsoundeffect_pulse_p.h @@ -77,30 +77,23 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); - -private slots: + void volumeChanged(); + void mutedChanged(); + +private Q_SLOTS: void decoderReady(); void decoderError(); void checkPlayTime(); @@ -108,6 +101,7 @@ private slots: private: void loadSample(); void unloadSample(); + void playSample(); void timerEvent(QTimerEvent *event); @@ -117,14 +111,15 @@ private: bool m_muted; bool m_playQueued; - int m_vol; + bool m_sampleLoaded; + int m_volume; int m_duration; int m_dataUploaded; + int m_loopCount; + int m_runningCount; + QUrl m_source; QTime m_playbackTime; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; QByteArray m_name; - QMediaContent m_media; QNetworkReply *m_reply; WaveDecoder *m_waveDecoder; QIODevice *m_stream; diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp index 48fb257..43ba22f 100644 --- a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp @@ -50,117 +50,84 @@ // We mean it. // -#include <QtCore/qcoreapplication.h> +#include "qsoundeffect_qmedia_p.h" -#include "qmediacontent.h" -#include "qmediaplayer.h" +#include <QtCore/qcoreapplication.h> -#include "qsoundeffect_p.h" -#include "qsoundeffect_qmedia_p.h" +#include <QtMultimedia/qmediacontent.h> +#include <QtMultimedia/qmediaplayer.h> QT_BEGIN_NAMESPACE QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), - m_muted(false), - m_vol(100), + m_loopCount(1), + m_runningCount(0), m_player(0) { + m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); + connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged())); + connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged())); + connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State))); } QSoundEffectPrivate::~QSoundEffectPrivate() { - if (m_player) delete m_player; } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - if (m_player) return m_player->duration(); - - return 0; + return m_player->media().canonicalUrl(); } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - if (m_player) return m_player->volume(); - - return m_vol; + m_player->setMedia(url); } -bool QSoundEffectPrivate::isMuted() const -{ - if (m_player) return m_player->isMuted(); - - return m_muted; -} - -QMediaContent QSoundEffectPrivate::media() const +int QSoundEffectPrivate::loopCount() const { - if (m_player) return m_player->media(); - - return QMediaContent(); + return m_loopCount; } -QMediaPlayer::State QSoundEffectPrivate::state() const +void QSoundEffectPrivate::setLoopCount(int loopCount) { - if (m_player) return m_player->state(); - - return QMediaPlayer::StoppedState; + m_loopCount = loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +int QSoundEffectPrivate::volume() const { - if (m_player) return m_player->mediaStatus(); - - return QMediaPlayer::UnknownMediaStatus; + return m_player->volume(); } -void QSoundEffectPrivate::play() +void QSoundEffectPrivate::setVolume(int volume) { - if (m_player && !m_player->isMuted()) - m_player->play(); + m_player->setVolume(volume); } -void QSoundEffectPrivate::stop() +bool QSoundEffectPrivate::isMuted() const { - if (m_player) - m_player->stop(); + return m_player->isMuted(); } -void QSoundEffectPrivate::setVolume(int volume) +void QSoundEffectPrivate::setMuted(bool muted) { - m_vol = volume; - - if (m_player) - m_player->setVolume(volume); + m_player->setMuted(muted); } -void QSoundEffectPrivate::setMuted(bool muted) +void QSoundEffectPrivate::play() { - m_muted = muted; - - if (m_player) - m_player->setMuted(muted); + m_runningCount += m_loopCount; + m_player->play(); } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) +void QSoundEffectPrivate::stateChanged(QMediaPlayer::State state) { - if (media.isNull()) - return; - - if (m_player == 0) { - m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency); - m_player->setVolume(m_vol); - m_player->setMuted(m_muted); - - connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged(int))); - connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); - connect(m_player, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SIGNAL(stateChanged(QMediaPlayer::State))); + if (state == QMediaPlayer::StoppedState) { + if (--m_runningCount > 0) + m_player->play(); } - - m_player->setMedia(media.canonicalUrl()); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.h b/src/multimedia/effects/qsoundeffect_qmedia_p.h index 8267f79..6ad9d79 100644 --- a/src/multimedia/effects/qsoundeffect_qmedia_p.h +++ b/src/multimedia/effects/qsoundeffect_qmedia_p.h @@ -57,14 +57,12 @@ #include <QtCore/qobject.h> #include <QtCore/qurl.h> #include <QtMultimedia/qmediaplayer.h> -#include "qsoundeffect_p.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class WaveDecoder; class QSoundEffectPrivate : public QObject { @@ -73,32 +71,28 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); + void volumeChanged(); + void mutedChanged(); + +private Q_SLOTS: + void stateChanged(QMediaPlayer::State); private: - bool m_muted; - int m_vol; + int m_loopCount; + int m_runningCount; QMediaPlayer *m_player; }; diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.cpp b/src/multimedia/effects/qsoundeffect_qsound_p.cpp index df160a9..ff30f67 100644 --- a/src/multimedia/effects/qsoundeffect_qsound_p.cpp +++ b/src/multimedia/effects/qsoundeffect_qsound_p.cpp @@ -50,102 +50,72 @@ // We mean it. // +#include "qsoundeffect_qsound_p.h" + #include <QtCore/qcoreapplication.h> -#include <QtCore/qtimer.h> -#include <QtCore/qfile.h> #include <QtGui/qsound.h> -#include <QtMultimedia/qaudioformat.h> -#include <QDebug> -#include "qmediacontent.h" -#include "qmediaplayer.h" -#include "qsoundeffect_p.h" - -#include "wavedecoder_p.h" - -#include "qsoundeffect_qsound_p.h" QT_BEGIN_NAMESPACE QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): QObject(parent), - m_queued(false), m_muted(false), - m_state(QMediaPlayer::StoppedState), - m_status(QMediaPlayer::NoMedia), - m_file(0), + m_loopCount(1), + m_volume(100), m_sound(0) { - m_timer = new QTimer(this); - connect(m_timer,SIGNAL(timeout()),SLOT(checkPlayTime())); - m_media = QMediaContent(); } QSoundEffectPrivate::~QSoundEffectPrivate() { - if (m_sound) delete m_sound; - if (m_waveDecoder) delete m_waveDecoder; - m_file->close(); } -qint64 QSoundEffectPrivate::duration() const +QUrl QSoundEffectPrivate::source() const { - if (m_waveDecoder) - return m_waveDecoder->size(); - - return 0; + return m_source; } -int QSoundEffectPrivate::volume() const +void QSoundEffectPrivate::setSource(const QUrl &url) { - return 100; -} + if (url.isEmpty() || url.scheme() != QLatin1String("file")) { + m_source = QUrl(); + return; + } -bool QSoundEffectPrivate::isMuted() const -{ - return m_muted; -} + if (m_sound != 0) + delete m_sound; -QMediaContent QSoundEffectPrivate::media() const -{ - return m_media; + m_source = url; + m_sound = new QSound(m_source.toLocalFile(), this); + m_sound->setLoops(m_loopCount); } -QMediaPlayer::State QSoundEffectPrivate::state() const +int QSoundEffectPrivate::loopCount() const { - return m_state; + return m_loopCount; } -QMediaPlayer::MediaStatus QSoundEffectPrivate::mediaStatus() const +void QSoundEffectPrivate::setLoopCount(int lc) { - return m_status; + m_loopCount = lc; + if (m_sound) + m_sound->setLoops(lc); } -void QSoundEffectPrivate::play() +int QSoundEffectPrivate::volume() const { - if (m_sound && !m_muted) { - m_queued = false; - m_timer->start(20); - m_playbackTime.start(); - m_sound->play(); - emit stateChanged(m_state = QMediaPlayer::PlayingState); - } else if (m_status == QMediaPlayer::LoadingMedia) - m_queued = true; + return m_volume; } -void QSoundEffectPrivate::stop() +void QSoundEffectPrivate::setVolume(int v) { - m_timer->stop(); - - if (m_sound) { - m_sound->stop(); - emit stateChanged(m_state = QMediaPlayer::StoppedState); - } + m_volume = v; } -void QSoundEffectPrivate::setVolume(int volume) +bool QSoundEffectPrivate::isMuted() const { - Q_UNUSED(volume) + return m_muted; } void QSoundEffectPrivate::setMuted(bool muted) @@ -153,73 +123,9 @@ void QSoundEffectPrivate::setMuted(bool muted) m_muted = muted; } -void QSoundEffectPrivate::setMedia(const QMediaContent &media) -{ - m_queued = false; - - if (media.isNull() || media.canonicalUrl().scheme() != QLatin1String("file")) { - m_media = QMediaContent(); - return; - } - if (m_media == media) - return; - - m_media = media; - m_file = new QFile(m_media.canonicalUrl().toLocalFile()); - m_file->open(QIODevice::ReadOnly|QIODevice::Unbuffered); - - unloadSample(); - loadSample(); - - emit mediaChanged(m_media); -} - -void QSoundEffectPrivate::decoderReady() -{ - m_file->close(); - m_sound = new QSound(m_media.canonicalUrl().toLocalFile()); - emit mediaStatusChanged(m_status = QMediaPlayer::LoadedMedia); - - if (m_queued) - play(); -} - -void QSoundEffectPrivate::decoderError() -{ - m_file->close(); - emit mediaStatusChanged(m_status = QMediaPlayer::InvalidMedia); -} - -void QSoundEffectPrivate::checkPlayTime() -{ - if (m_sound->isFinished()) { - m_timer->stop(); - m_state = QMediaPlayer::StoppedState; - emit stateChanged(m_state); - } -} - -void QSoundEffectPrivate::loadSample() -{ - m_waveDecoder = new WaveDecoder(m_file); - connect(m_waveDecoder, SIGNAL(formatKnown()), SLOT(decoderReady())); - connect(m_waveDecoder, SIGNAL(invalidFormat()), SLOT(decoderError())); - - m_status = QMediaPlayer::LoadingMedia; - emit mediaStatusChanged(m_status); -} - -void QSoundEffectPrivate::unloadSample() +void QSoundEffectPrivate::play() { - if (m_sound == 0) - return; - - m_status = QMediaPlayer::NoMedia; - - if (m_sound) - delete m_sound; - - m_sound = 0; + m_sound->play(); } QT_END_NAMESPACE diff --git a/src/multimedia/effects/qsoundeffect_qsound_p.h b/src/multimedia/effects/qsoundeffect_qsound_p.h index 45c0888..6fb3cfa 100644 --- a/src/multimedia/effects/qsoundeffect_qsound_p.h +++ b/src/multimedia/effects/qsoundeffect_qsound_p.h @@ -55,20 +55,14 @@ #include <QtCore/qobject.h> -#include <QtCore/qdatetime.h> -#include <QtMultimedia/qmediaplayer.h> - -#include "qsoundeffect_p.h" +#include <QtCore/qurl.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QTimer; class QSound; -class QFile; -class WaveDecoder; class QSoundEffectPrivate : public QObject { @@ -77,49 +71,28 @@ public: explicit QSoundEffectPrivate(QObject* parent); ~QSoundEffectPrivate(); - qint64 duration() const; + QUrl source() const; + void setSource(const QUrl &url); + int loopCount() const; + void setLoopCount(int loopCount); int volume() const; + void setVolume(int volume); bool isMuted() const; - QMediaContent media() const; - QMediaPlayer::State state() const; - QMediaPlayer::MediaStatus mediaStatus() const; + void setMuted(bool muted); public Q_SLOTS: void play(); - void stop(); - void setVolume(int volume); - void setMuted(bool muted); - void setMedia(const QMediaContent &media); Q_SIGNALS: - void mediaChanged(const QMediaContent &media); - void mediaStatusChanged(QMediaPlayer::MediaStatus status); - void stateChanged(QMediaPlayer::State newState); - void durationChanged(qint64 duration); - void volumeChanged(int volume); - void mutedChanged(bool muted); - void error(QMediaPlayer::Error error); - -private slots: - void decoderReady(); - void decoderError(); - void checkPlayTime(); + void volumeChanged(); + void mutedChanged(); private: - void loadSample(); - void unloadSample(); - - bool m_queued; - bool m_muted; - QTime m_playbackTime; - QMediaPlayer::State m_state; - QMediaPlayer::MediaStatus m_status; - QFile *m_file; - QByteArray m_name; - QMediaContent m_media; - WaveDecoder *m_waveDecoder; + bool m_muted; + int m_loopCount; + int m_volume; QSound *m_sound; - QTimer *m_timer; + QUrl m_source; }; QT_END_NAMESPACE diff --git a/src/multimedia/effects/wavedecoder_p.h b/src/multimedia/effects/wavedecoder_p.h index fa1f77e..c1892bb 100644 --- a/src/multimedia/effects/wavedecoder_p.h +++ b/src/multimedia/effects/wavedecoder_p.h @@ -77,11 +77,11 @@ public: bool isSequential() const; qint64 bytesAvailable() const; -signals: +Q_SIGNALS: void formatKnown(); void invalidFormat(); -private slots: +private Q_SLOTS: void handleData(); private: diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 5ffecc5..fdcc412 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -42,7 +42,6 @@ #include "qgl.h" #include <private/qt_x11_p.h> #include <private/qpixmap_x11_p.h> -#include <private/qimagepixmapcleanuphooks_p.h> #include <private/qgl_p.h> #include <private/qpaintengine_opengl_p.h> #include "qgl_egl_p.h" diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml index 3f00e68..408ad87 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml @@ -10,7 +10,7 @@ Rectangle { width: 100; height: 100 color: Qt.rgba(1,0,0) Behavior on x { - NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} + NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} } } |