diff options
Diffstat (limited to 'src')
46 files changed, 244 insertions, 419 deletions
diff --git a/src/imports/audioengine/audioengine.pro b/src/imports/audioengine/audioengine.pro index 6c4b17c1d..c00a6ec6b 100644 --- a/src/imports/audioengine/audioengine.pro +++ b/src/imports/audioengine/audioengine.pro @@ -1,7 +1,7 @@ CXX_MODULE = multimedia TARGET = declarative_audioengine TARGETPATH = QtAudioEngine -IMPORT_VERSION = 1.0 +IMPORT_VERSION = 1.1 QT += quick qml multimedia-private diff --git a/src/imports/audioengine/plugins.qmltypes b/src/imports/audioengine/plugins.qmltypes index 22fad073a..0468d839a 100644 --- a/src/imports/audioengine/plugins.qmltypes +++ b/src/imports/audioengine/plugins.qmltypes @@ -4,10 +4,10 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable QtAudioEngine 1.0' +// 'qmlplugindump -nonrelocatable QtAudioEngine 1.1' Module { - dependencies: [] + dependencies: ["QtQuick 2.0"] Component { name: "QDeclarativeAttenuationModel" prototype: "QObject" diff --git a/src/imports/audioengine/qdeclarative_attenuationmodel_p.cpp b/src/imports/audioengine/qdeclarative_attenuationmodel_p.cpp index d88bb87e8..729558cd2 100644 --- a/src/imports/audioengine/qdeclarative_attenuationmodel_p.cpp +++ b/src/imports/audioengine/qdeclarative_attenuationmodel_p.cpp @@ -85,17 +85,11 @@ void QDeclarativeAttenuationModel::setName(const QString& name) \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - AttenuationModelLinear must be defined inside \l AudioEngine or be added to it using \l{QtAudioEngine::AudioEngine::addAttenuationModel()}{AudioEngine.addAttenuationModel()} if AttenuationModelLinear is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - - Rectangle { color:"white" width: 300 @@ -220,17 +214,11 @@ qreal QDeclarativeAttenuationModelLinear::calculateGain(const QVector3D &listene \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - AttenuationModelInverse must be defined inside \l AudioEngine or be added to it using \l{QtAudioEngine::AudioEngine::addAttenuationModel()}{AudioEngine.addAttenuationModel()} if AttenuationModelInverse is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_audiocategory_p.cpp b/src/imports/audioengine/qdeclarative_audiocategory_p.cpp index f766ae515..84ba6b190 100644 --- a/src/imports/audioengine/qdeclarative_audiocategory_p.cpp +++ b/src/imports/audioengine/qdeclarative_audiocategory_p.cpp @@ -54,17 +54,12 @@ QT_USE_NAMESPACE \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - An instance of AudioCategory can be accessed through \l {QtAudioEngine::AudioEngine::categories} {AudioEngine.categories} with its unique name and must be defined inside AudioEngine or be added to it using \l{QtAudioEngine::AudioEngine::addAudioCategory()}{AudioEngine.addAudioCategory()} if AudioCategory is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_audioengine_p.cpp b/src/imports/audioengine/qdeclarative_audioengine_p.cpp index c4b4bd41b..bd309457e 100644 --- a/src/imports/audioengine/qdeclarative_audioengine_p.cpp +++ b/src/imports/audioengine/qdeclarative_audioengine_p.cpp @@ -63,12 +63,7 @@ QT_BEGIN_NAMESPACE \inherits Item \preliminary - \c AudioEngine is part of the \b{QtAudioEngine 1.0} module. - \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_audiolistener_p.cpp b/src/imports/audioengine/qdeclarative_audiolistener_p.cpp index f45010930..39a30171b 100644 --- a/src/imports/audioengine/qdeclarative_audiolistener_p.cpp +++ b/src/imports/audioengine/qdeclarative_audiolistener_p.cpp @@ -55,15 +55,10 @@ QT_USE_NAMESPACE \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - AudioListener will have only one global instance and you can either access it through the listener property of AudioEngine: \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 @@ -98,9 +93,6 @@ QT_USE_NAMESPACE or alternatively, by defining an AudioListener outside AudioEngine: \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_audiosample_p.cpp b/src/imports/audioengine/qdeclarative_audiosample_p.cpp index a8dc76279..4eccf5052 100644 --- a/src/imports/audioengine/qdeclarative_audiosample_p.cpp +++ b/src/imports/audioengine/qdeclarative_audiosample_p.cpp @@ -57,17 +57,12 @@ QT_USE_NAMESPACE \inherits Item \preliminary - \c AudioSample is part of the \b{QtAudioEngine 1.0} module. - It can be accessed through QtAudioEngine::AudioEngine::samples with its unique name and must be defined inside AudioEngine or be added to it using \l{QtAudioEngine::AudioEngine::addAudioSample()}{AudioEngine.addAudioSample()} if AudioSample is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_playvariation_p.cpp b/src/imports/audioengine/qdeclarative_playvariation_p.cpp index 9cb36c50e..36ffca668 100644 --- a/src/imports/audioengine/qdeclarative_playvariation_p.cpp +++ b/src/imports/audioengine/qdeclarative_playvariation_p.cpp @@ -59,16 +59,11 @@ QT_USE_NAMESPACE \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - PlayVariation must be defined inside a \l Sound or be added to it using \l{QtAudioEngine::Sound::addPlayVariation()}{Sound.addPlayVariation()} if PlayVariation is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { color:"white" width: 300 diff --git a/src/imports/audioengine/qdeclarative_sound_p.cpp b/src/imports/audioengine/qdeclarative_sound_p.cpp index 1c746f534..0849215be 100644 --- a/src/imports/audioengine/qdeclarative_sound_p.cpp +++ b/src/imports/audioengine/qdeclarative_sound_p.cpp @@ -165,16 +165,12 @@ void QDeclarativeSoundCone::setEngine(QDeclarativeAudioEngine *engine) \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - Sound can be accessed through QtAudioEngine::AudioEngine::sounds with its unique name and must be defined inside AudioEngine or be added to it using \l{QtAudioEngine::AudioEngine::addSound()}{AudioEngine.addSound()} if \l Sound is created dynamically. \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 Rectangle { color:"white" diff --git a/src/imports/audioengine/qdeclarative_soundinstance_p.cpp b/src/imports/audioengine/qdeclarative_soundinstance_p.cpp index 830f8ee7b..7f8c33233 100644 --- a/src/imports/audioengine/qdeclarative_soundinstance_p.cpp +++ b/src/imports/audioengine/qdeclarative_soundinstance_p.cpp @@ -58,15 +58,10 @@ QT_USE_NAMESPACE \inherits Item \preliminary - This type is part of the \b{QtAudioEngine 1.0} module. - There are two ways to create SoundInstance objects. You can obtain it by calling newInstance method of a \l Sound: \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { id:root color:"white" @@ -104,9 +99,6 @@ QT_USE_NAMESPACE easier qml bindings: \qml - import QtQuick 2.0 - import QtAudioEngine 1.0 - Rectangle { id:root color:"white" diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp index 472c01489..79d1d96ab 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp @@ -55,10 +55,7 @@ #include "qsoundeffect_pulse_p.h" -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) -#include <pulse/ext-stream-restore.h> -#endif - +#include <private/qaudiohelpers_p.h> #include <private/qmediaresourcepolicy_p.h> #include <private/qmediaresourceset_p.h> @@ -130,26 +127,9 @@ public: return m_context; } - inline pa_cvolume * calcVolume(pa_cvolume *dest, int soundEffectVolume) - { - pa_volume_t v = m_vol * soundEffectVolume / 100; - for (int i = 0; i < dest->channels; ++i) - dest->values[i] = v; - return dest; - } - - void updateStatus(const pa_cvolume& volume) - { - if (m_vol != pa_cvolume_max(&volume)) { - m_vol = pa_cvolume_max(&volume); - emit volumeChanged(); - } - } - Q_SIGNALS: void contextReady(); void contextFailed(); - void volumeChanged(); private Q_SLOTS: void onContextFailed() @@ -164,8 +144,6 @@ private Q_SLOTS: void prepare() { - m_vol = PA_VOLUME_NORM; - m_context = 0; m_mainLoop = pa_threaded_mainloop_new(); if (m_mainLoop == 0) { @@ -238,11 +216,6 @@ private: case PA_CONTEXT_SETTING_NAME: break; case PA_CONTEXT_READY: - #if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); - pa_ext_stream_restore_set_subscribe_cb(c, &stream_restore_monitor_callback, self); - pa_ext_stream_restore_subscribe(c, 1, 0, self); - #endif QMetaObject::invokeMethod(self, "contextReady", Qt::QueuedConnection); break; case PA_CONTEXT_FAILED: @@ -253,37 +226,6 @@ private: } } -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - - static void stream_restore_monitor_callback(pa_context *c, void *userdata) - { - PulseDaemon *self = reinterpret_cast<PulseDaemon*>(userdata); - pa_ext_stream_restore_read(c, &stream_restore_info_callback, self); - } - - static void stream_restore_info_callback(pa_context *c, - const pa_ext_stream_restore_info *info, - int eol, void *userdata) - { - Q_UNUSED(c) - - PulseDaemon *self = reinterpret_cast<PulseDaemon*>(userdata); - - if (!eol) { - if (QString(info->name).startsWith(QLatin1String("sink-input-by-media-role:x-maemo"))) { -#ifdef QT_PA_DEBUG - qDebug() << "x-maemo volume =(" << info->volume.values[0] * 100 / PA_VOLUME_NORM << "," - << info->volume.values[1] * 100 / PA_VOLUME_NORM << "), " - << "mute = " << info->mute; -#endif - self->updateStatus(info->volume); - } - } - } -#endif - - pa_volume_t m_vol; - bool m_prepared; pa_context *m_context; pa_threaded_mainloop *m_mainLoop; @@ -391,9 +333,6 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent): m_sample(0), m_position(0), m_resourcesAvailable(false) -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - , m_customVolume(false) -#endif { m_ref = new QSoundEffectRef(this); pa_sample_spec_init(&m_pulseSpec); @@ -544,60 +483,32 @@ void QSoundEffectPrivate::setLoopCount(int loopCount) qreal QSoundEffectPrivate::volume() const { + QReadLocker locker(&m_volumeLock); return m_volume; } void QSoundEffectPrivate::setVolume(qreal volume) { -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - m_customVolume = true; -#endif - m_volume = volume; - emit volumeChanged(); - updateVolume(); -} + QWriteLocker locker(&m_volumeLock); -void QSoundEffectPrivate::updateVolume() -{ - if (m_sinkInputId < 0) + if (qFuzzyCompare(m_volume, volume)) return; -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - if (!m_customVolume) - return; -#endif - PulseDaemonLocker locker; - pa_cvolume volume; - volume.channels = m_pulseSpec.channels; - if (pulseDaemon()->context()) - pa_operation_unref(pa_context_set_sink_input_volume(pulseDaemon()->context(), m_sinkInputId, pulseDaemon()->calcVolume(&volume, qRound(m_volume * 100)), setvolume_callback, m_ref->getRef())); - Q_ASSERT(pa_cvolume_valid(&volume)); -#ifdef QT_PA_DEBUG - qDebug() << this << "updateVolume =" << pa_cvolume_max(&volume); -#endif + + m_volume = qBound(qreal(0), volume, qreal(1)); + emit volumeChanged(); } bool QSoundEffectPrivate::isMuted() const { + QReadLocker locker(&m_volumeLock); return m_muted; } void QSoundEffectPrivate::setMuted(bool muted) { + QWriteLocker locker(&m_volumeLock); m_muted = muted; emit mutedChanged(); - updateMuted(); -} - -void QSoundEffectPrivate::updateMuted() -{ - if (m_sinkInputId < 0) - return; - PulseDaemonLocker locker; - if (pulseDaemon()->context()) - pa_operation_unref(pa_context_set_sink_input_mute(pulseDaemon()->context(), m_sinkInputId, m_muted, setmuted_callback, m_ref->getRef())); -#ifdef QT_PA_DEBUG - qDebug() << this << "updateMuted = " << m_muted; -#endif } bool QSoundEffectPrivate::isLoaded() const @@ -807,7 +718,6 @@ void QSoundEffectPrivate::unloadPulseStream() pa_stream_set_underflow_callback(m_pulseStream, 0, 0); pa_stream_disconnect(m_pulseStream); pa_stream_unref(m_pulseStream); - disconnect(pulseDaemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); disconnect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed())); m_pulseStream = 0; m_reloadCategory = false; // category will be reloaded when we connect anyway @@ -828,11 +738,8 @@ void QSoundEffectPrivate::prepare() << "actual writeBytes =" << writeBytes << "m_playQueued =" << m_playQueued; #endif - m_position = int(writeBytes); - if (pa_stream_write(m_pulseStream, reinterpret_cast<void *>(const_cast<char*>(m_sample->data().data())), writeBytes, - stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(pulseDaemon()->context()))); - } + m_position = writeToStream(m_sample->data().data(), writeBytes); + if (m_playQueued) { m_playQueued = false; setLoopsRemaining(m_loopCount); @@ -860,15 +767,13 @@ void QSoundEffectPrivate::uploadSample() } } - int writtenBytes = 0; int writableSize = int(pa_stream_writable_size(m_pulseStream)); int firstPartLength = qMin(m_sample->data().size() - m_position, writableSize); - if (pa_stream_write(m_pulseStream, reinterpret_cast<void *>(const_cast<char*>(m_sample->data().data()) + m_position), - firstPartLength, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(pulseDaemon()->context()))); - } - writtenBytes = firstPartLength; - m_position += firstPartLength; + + int writtenBytes = writeToStream(m_sample->data().data() + m_position, + firstPartLength); + + m_position += writtenBytes; if (m_position == m_sample->data().size()) { m_position = 0; if (m_runningCount > 0) @@ -877,11 +782,8 @@ void QSoundEffectPrivate::uploadSample() { while (writtenBytes < writableSize) { int writeSize = qMin(writableSize - writtenBytes, m_sample->data().size()); - if (pa_stream_write(m_pulseStream, reinterpret_cast<void *>(const_cast<char*>(m_sample->data().data())), - writeSize, stream_write_done_callback, 0, PA_SEEK_RELATIVE) != 0) { - qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", pa_strerror(pa_context_errno(pulseDaemon()->context()))); - } - writtenBytes += writeSize; + writtenBytes += writeToStream(m_sample->data().data(), writeSize); + if (writeSize < m_sample->data().size()) { m_position = writeSize; break; @@ -899,6 +801,39 @@ void QSoundEffectPrivate::uploadSample() #endif } +int QSoundEffectPrivate::writeToStream(const void *data, int size) +{ + m_volumeLock.lockForRead(); + qreal volume = m_muted ? 0 : m_volume; + m_volumeLock.unlock(); + pa_free_cb_t writeDoneCb = stream_write_done_callback; + + if (volume < 1.0f) { + // Don't use PulseAudio volume, as it might affect all other streams of the same category + // or even affect the system volume if flat volumes are enabled + void *dest = NULL; + size_t nbytes = size; + if (pa_stream_begin_write(m_pulseStream, &dest, &nbytes) < 0) { + qWarning("QSoundEffect(pulseaudio): pa_stream_begin_write, error = %s", + pa_strerror(pa_context_errno(pulseDaemon()->context()))); + return 0; + } + + size = int(nbytes); + QAudioHelperInternal::qMultiplySamples(volume, m_sample->format(), data, dest, size); + data = dest; + writeDoneCb = NULL; + } + + if (pa_stream_write(m_pulseStream, data, size, writeDoneCb, 0, PA_SEEK_RELATIVE) < 0) { + qWarning("QSoundEffect(pulseaudio): pa_stream_write, error = %s", + pa_strerror(pa_context_errno(pulseDaemon()->context()))); + return 0; + } + + return size; +} + void QSoundEffectPrivate::playSample() { #ifdef QT_PA_DEBUG @@ -945,8 +880,6 @@ void QSoundEffectPrivate::streamReady() #endif PulseDaemonLocker locker; m_sinkInputId = pa_stream_get_index(m_pulseStream); - updateMuted(); - updateVolume(); #ifdef QT_PA_DEBUG const pa_buffer_attr *realBufAttr = pa_stream_get_buffer_attr(m_pulseStream); qDebug() << this << "m_sinkInputId =" << m_sinkInputId @@ -972,7 +905,6 @@ void QSoundEffectPrivate::createPulseStream() pa_stream *stream = pa_stream_new_with_proplist(pulseDaemon()->context(), m_name.constData(), &m_pulseSpec, 0, propList); pa_proplist_free(propList); - connect(pulseDaemon(), SIGNAL(volumeChanged()), this, SLOT(updateVolume())); connect(pulseDaemon(), SIGNAL(contextFailed()), this, SLOT(contextFailed())); if (stream == 0) { @@ -1000,9 +932,7 @@ void QSoundEffectPrivate::createPulseStream() #else if (pa_stream_connect_playback(m_pulseStream, 0, 0, #endif - m_muted ? pa_stream_flags_t(PA_STREAM_START_MUTED | PA_STREAM_START_CORKED) - : pa_stream_flags_t(PA_STREAM_START_UNMUTED | PA_STREAM_START_CORKED), - 0, 0) < 0) { + PA_STREAM_START_CORKED, 0, 0) < 0) { qWarning("QSoundEffect(pulseaudio): Failed to connect stream, error = %s", pa_strerror(pa_context_errno(pulseDaemon()->context()))); } @@ -1121,46 +1051,6 @@ void QSoundEffectPrivate::stream_adjust_prebuffer_callback(pa_stream *s, int suc QMetaObject::invokeMethod(self, "streamReady", Qt::QueuedConnection); } -void QSoundEffectPrivate::setvolume_callback(pa_context *c, int success, void *userdata) -{ -#ifdef QT_PA_DEBUG - qDebug() << "setvolume_callback"; -#endif - Q_UNUSED(c); - Q_UNUSED(userdata); - QSoundEffectRef *ref = reinterpret_cast<QSoundEffectRef*>(userdata); - QSoundEffectPrivate *self = ref->soundEffect(); - ref->release(); - if (!self) - return; -#ifdef QT_PA_DEBUG - qDebug() << self << "setvolume_callback"; -#endif - if (!success) { - qWarning("QSoundEffect(pulseaudio): faild to set volume"); - } -} - -void QSoundEffectPrivate::setmuted_callback(pa_context *c, int success, void *userdata) -{ -#ifdef QT_PA_DEBUG - qDebug() << "setmuted_callback"; -#endif - Q_UNUSED(c); - Q_UNUSED(userdata); - QSoundEffectRef *ref = reinterpret_cast<QSoundEffectRef*>(userdata); - QSoundEffectPrivate *self = ref->soundEffect(); - ref->release(); - if (!self) - return; -#ifdef QT_PA_DEBUG - qDebug() << self << "setmuted_callback"; -#endif - if (!success) { - qWarning("QSoundEffect(pulseaudio): faild to set muted"); - } -} - void QSoundEffectPrivate::stream_underrun_callback(pa_stream *s, void *userdata) { Q_UNUSED(s); diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h index 259d2e046..6bf2416cf 100644 --- a/src/multimedia/audio/qsoundeffect_pulse_p.h +++ b/src/multimedia/audio/qsoundeffect_pulse_p.h @@ -56,6 +56,7 @@ #include <QtCore/qobject.h> #include <QtCore/qdatetime.h> +#include <QtCore/qreadwritelock.h> #include <qmediaplayer.h> #include <pulse/pulseaudio.h> #include "qsamplecache_p.h" @@ -117,8 +118,6 @@ private Q_SLOTS: void prepare(); void streamReady(); void emptyComplete(void *stream); - void updateVolume(); - void updateMuted(); void handleAvailabilityChanged(bool available); @@ -130,6 +129,8 @@ private: void createPulseStream(); void unloadPulseStream(); + int writeToStream(const void *data, int size); + void setPlaying(bool playing); void setStatus(QSoundEffect::Status status); void setLoopsRemaining(int loopsRemaining); @@ -142,8 +143,6 @@ private: static void stream_write_done_callback(void *p); static void stream_adjust_prebuffer_callback(pa_stream *s, int success, void *userdata); static void stream_reset_buffer_callback(pa_stream *s, int success, void *userdata); - static void setvolume_callback(pa_context *c, int success, void *userdata); - static void setmuted_callback(pa_context *c, int success, void *userdata); pa_stream *m_pulseStream; int m_sinkInputId; @@ -171,11 +170,9 @@ private: bool m_resourcesAvailable; - QMediaPlayerResourceSetInterface *m_resources; + mutable QReadWriteLock m_volumeLock; -#if defined(Q_WS_MAEMO_6) || defined(NEMO_AUDIO) - bool m_customVolume; -#endif + QMediaPlayerResourceSetInterface *m_resources; }; QT_END_NAMESPACE diff --git a/src/multimedia/doc/src/multimedia.qdoc b/src/multimedia/doc/src/multimedia.qdoc index 5849af59d..813847d88 100644 --- a/src/multimedia/doc/src/multimedia.qdoc +++ b/src/multimedia/doc/src/multimedia.qdoc @@ -177,12 +177,12 @@ what changed, and what you might need to change when porting code. \section2 QML Types The QML types are accessed by using: \code -import QtMultimedia 5.5 +import QtMultimedia 5.6 \endcode \annotatedlist multimedia_qml The following types are accessed by using \l{Qt Audio Engine QML Types}{Qt Audio Engine}: \code -import QtAudioEngine 1.0 +import QtAudioEngine 1.1 \endcode \annotatedlist multimedia_audioengine diff --git a/src/multimedia/doc/src/qtaudioengine.qdoc b/src/multimedia/doc/src/qtaudioengine.qdoc index 3b65379d3..2de2bb250 100644 --- a/src/multimedia/doc/src/qtaudioengine.qdoc +++ b/src/multimedia/doc/src/qtaudioengine.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! -\qmlmodule QtAudioEngine 1.0 +\qmlmodule QtAudioEngine 1.1 \title Qt Audio Engine QML Types \ingroup qmlmodules \brief Provides QML types for 3D positional audio playback and content management. @@ -37,7 +37,7 @@ Engine provides types for 3D positional audio playback and content management. The QML types can be imported into your application using the following import statement in your .qml file: \code -import QtAudioEngine 1.0 +import QtAudioEngine 1.1 \endcode \section1 Qt Audio Engine Features diff --git a/src/multimedia/doc/src/qtmultimedia-index.qdoc b/src/multimedia/doc/src/qtmultimedia-index.qdoc index e51ec97e0..989b8886e 100644 --- a/src/multimedia/doc/src/qtmultimedia-index.qdoc +++ b/src/multimedia/doc/src/qtmultimedia-index.qdoc @@ -54,7 +54,7 @@ import statement in your \c {.qml} file. \code - import QtMultimedia 5.5 + import QtMultimedia 5.6 \endcode If you intend to use the C++ classes in your application, include the C++ diff --git a/src/multimedia/doc/src/qtmultimedia5.qdoc b/src/multimedia/doc/src/qtmultimedia5.qdoc index 0d3e087a0..21854ae7c 100644 --- a/src/multimedia/doc/src/qtmultimedia5.qdoc +++ b/src/multimedia/doc/src/qtmultimedia5.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! -\qmlmodule QtMultimedia 5.5 +\qmlmodule QtMultimedia 5.6 \title Qt Multimedia QML Types \ingroup qmlmodules \brief Provides QML types for multimedia support. @@ -42,7 +42,7 @@ The QML types for \l{Qt Multimedia} support the basic use cases such as: The QML types can be imported into your application using the following import statement in your .qml file: \code -import QtMultimedia 5.5 +import QtMultimedia 5.6 \endcode \section1 QML types diff --git a/src/plugins/alsa/qalsaaudiodeviceinfo.cpp b/src/plugins/alsa/qalsaaudiodeviceinfo.cpp index 5e7aaa3d0..0342ca546 100644 --- a/src/plugins/alsa/qalsaaudiodeviceinfo.cpp +++ b/src/plugins/alsa/qalsaaudiodeviceinfo.cpp @@ -147,7 +147,7 @@ bool QAlsaAudioDeviceInfo::open() QList<QByteArray> devices = availableDevices(mode); if(dev.compare(QLatin1String("default")) == 0) { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 if (devices.size() > 0) dev = QLatin1String(devices.first().constData()); else @@ -156,7 +156,7 @@ bool QAlsaAudioDeviceInfo::open() dev = QLatin1String("hw:0,0"); #endif } else { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 dev = device; #else int idx = 0; @@ -200,7 +200,7 @@ bool QAlsaAudioDeviceInfo::testSettings(const QAudioFormat& format) const snd_pcm_hw_params_t *params; QString dev; -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 dev = device; if (dev.compare(QLatin1String("default")) == 0) { QList<QByteArray> devices = availableDevices(QAudio::AudioOutput); @@ -341,7 +341,7 @@ QList<QByteArray> QAlsaAudioDeviceInfo::availableDevices(QAudio::Mode mode) QList<QByteArray> devices; QByteArray filter; -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 // Create a list of all current audio devices that support mode void **hints, **n; char *name, *descr, *io; diff --git a/src/plugins/alsa/qalsaaudioinput.cpp b/src/plugins/alsa/qalsaaudioinput.cpp index bdf190cd3..5f83631ab 100644 --- a/src/plugins/alsa/qalsaaudioinput.cpp +++ b/src/plugins/alsa/qalsaaudioinput.cpp @@ -309,7 +309,7 @@ bool QAlsaAudioInput::open() QString dev = QString(QLatin1String(m_device.constData())); QList<QByteArray> devices = QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioInput); if(dev.compare(QLatin1String("default")) == 0) { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 if (devices.size() > 0) dev = QLatin1String(devices.first()); else @@ -318,7 +318,7 @@ bool QAlsaAudioInput::open() dev = QLatin1String("hw:0,0"); #endif } else { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 dev = QLatin1String(m_device); #else int idx = 0; diff --git a/src/plugins/alsa/qalsaaudiooutput.cpp b/src/plugins/alsa/qalsaaudiooutput.cpp index 9fee690b5..df050ecd7 100644 --- a/src/plugins/alsa/qalsaaudiooutput.cpp +++ b/src/plugins/alsa/qalsaaudiooutput.cpp @@ -312,7 +312,7 @@ bool QAlsaAudioOutput::open() QString dev = QString(QLatin1String(m_device.constData())); QList<QByteArray> devices = QAlsaAudioDeviceInfo::availableDevices(QAudio::AudioOutput); if(dev.compare(QLatin1String("default")) == 0) { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 if (devices.size() > 0) dev = QLatin1String(devices.first()); else @@ -321,7 +321,7 @@ bool QAlsaAudioOutput::open() dev = QLatin1String("hw:0,0"); #endif } else { -#if (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 0 || SND_LIB_SUBMINOR >= 14)) +#if SND_LIB_VERSION >= 0x1000e // 1.0.14 dev = QLatin1String(m_device); #else int idx = 0; diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 9df08012a..7a26afd10 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -848,8 +848,6 @@ HRESULT EVRCustomPresenter::OnClockStart(MFTIME, LONGLONG clockStartOffset) return hr; } - startSurface(); - // Now try to get new output samples from the mixer. processOutputLoop(); @@ -897,8 +895,6 @@ HRESULT EVRCustomPresenter::OnClockStop(MFTIME) cancelFrameStep(); } - stopSurface(); - return S_OK; } @@ -1406,6 +1402,7 @@ HRESULT EVRCustomPresenter::setMediaType(IMFMediaType *mediaType) // Clearing the media type is allowed in any state (including shutdown). if (!mediaType) { + stopSurface(); qt_evr_safe_release(&m_mediaType); releaseResources(); return S_OK; @@ -1466,6 +1463,8 @@ HRESULT EVRCustomPresenter::setMediaType(IMFMediaType *mediaType) m_mediaType = mediaType; m_mediaType->AddRef(); + startSurface(); + done: if (FAILED(hr)) releaseResources(); @@ -1879,18 +1878,19 @@ float EVRCustomPresenter::getMaxRate(bool thin) bool EVRCustomPresenter::event(QEvent *e) { - if (e->type() == StartSurface) { + switch (int(e->type())) { + case StartSurface: startSurface(); return true; - } else if (e->type() == StopSurface) { + case StopSurface: stopSurface(); return true; - } else if (e->type() == PresentSample) { - PresentSampleEvent *ev = static_cast<PresentSampleEvent *>(e); - presentSample(ev->sample()); + case PresentSample: + presentSample(static_cast<PresentSampleEvent *>(e)->sample()); return true; + default: + break; } - return QObject::event(e); } diff --git a/src/plugins/common/evr/evrdefs.h b/src/plugins/common/evr/evrdefs.h index f939d01a0..f898209b8 100644 --- a/src/plugins/common/evr/evrdefs.h +++ b/src/plugins/common/evr/evrdefs.h @@ -41,12 +41,12 @@ #define EVRDEFS_H #include <d3d9.h> -#include <Evr9.h> +#include <evr9.h> #include <evr.h> #include <dxva2api.h> #include <mfapi.h> #include <mfidl.h> -#include <Mferror.h> +#include <mferror.h> extern const CLSID clsid_EnhancedVideoRenderer; extern const GUID mr_VIDEO_RENDER_SERVICE; diff --git a/src/plugins/directshow/directshow.pro b/src/plugins/directshow/directshow.pro index 280b52619..117b02ade 100644 --- a/src/plugins/directshow/directshow.pro +++ b/src/plugins/directshow/directshow.pro @@ -13,7 +13,7 @@ SOURCES += dsserviceplugin.cpp mingw: DEFINES += NO_DSHOW_STRSAFE !config_wmf: include(player/player.pri) -include(camera/camera.pri) +!wince: include(camera/camera.pri) OTHER_FILES += \ directshow.json \ diff --git a/src/plugins/directshow/dsserviceplugin.cpp b/src/plugins/directshow/dsserviceplugin.cpp index 73d9f4eb1..6f31ce7e2 100644 --- a/src/plugins/directshow/dsserviceplugin.cpp +++ b/src/plugins/directshow/dsserviceplugin.cpp @@ -37,14 +37,16 @@ ** ****************************************************************************/ +#include <dshow.h> + #include <QtCore/qstring.h> #include <QtCore/qdebug.h> #include <QtCore/QFile> #include "dsserviceplugin.h" -#include "dsvideodevicecontrol.h" #ifdef QMEDIA_DIRECTSHOW_CAMERA +#include "dsvideodevicecontrol.h" #include <dshow.h> #include "dscameraservice.h" #endif diff --git a/src/plugins/directshow/player/directshowglobal.h b/src/plugins/directshow/player/directshowglobal.h index 1f9466269..f7890c52b 100644 --- a/src/plugins/directshow/player/directshowglobal.h +++ b/src/plugins/directshow/player/directshowglobal.h @@ -40,10 +40,10 @@ #ifndef DIRECTSHOWGLOBAL_H #define DIRECTSHOWGLOBAL_H -#include <QtCore/qglobal.h> - #include <dshow.h> +#include <QtCore/qglobal.h> + template <typename T> T *com_cast(IUnknown *unknown, const IID &iid) { T *iface = 0; @@ -118,6 +118,7 @@ DECLARE_INTERFACE_(IFileSourceFilter ,IUnknown) #ifndef __IAMOpenProgress_INTERFACE_DEFINED__ #define __IAMOpenProgress_INTERFACE_DEFINED__ +#undef INTERFACE #define INTERFACE IAMOpenProgress DECLARE_INTERFACE_(IAMOpenProgress ,IUnknown) { diff --git a/src/plugins/directshow/player/directshowioreader.h b/src/plugins/directshow/player/directshowioreader.h index 2e8656059..deb5d5327 100644 --- a/src/plugins/directshow/player/directshowioreader.h +++ b/src/plugins/directshow/player/directshowioreader.h @@ -40,12 +40,12 @@ #ifndef DIRECTSHOWIOREADER_H #define DIRECTSHOWIOREADER_H +#include <dshow.h> + #include <QtCore/qmutex.h> #include <QtCore/qobject.h> #include <QtCore/qwaitcondition.h> -#include <dshow.h> - QT_BEGIN_NAMESPACE class QIODevice; QT_END_NAMESPACE diff --git a/src/plugins/directshow/player/directshowmediatype.cpp b/src/plugins/directshow/player/directshowmediatype.cpp index cbe1753ae..984979c6e 100644 --- a/src/plugins/directshow/player/directshowmediatype.cpp +++ b/src/plugins/directshow/player/directshowmediatype.cpp @@ -198,9 +198,11 @@ QVideoSurfaceFormat::Direction DirectShowMediaType::scanLineDirection(QVideoFram case QVideoFrame::Format_BGR24: case QVideoFrame::Format_RGB565: case QVideoFrame::Format_RGB555: +#ifndef Q_OS_WINCE return bmiHeader.biHeight < 0 ? QVideoSurfaceFormat::TopToBottom : QVideoSurfaceFormat::BottomToTop; +#endif default: return QVideoSurfaceFormat::TopToBottom; } diff --git a/src/plugins/directshow/player/directshowmediatype.h b/src/plugins/directshow/player/directshowmediatype.h index 136fefaea..cf5ac73aa 100644 --- a/src/plugins/directshow/player/directshowmediatype.h +++ b/src/plugins/directshow/player/directshowmediatype.h @@ -40,9 +40,10 @@ #ifndef DIRECTSHOWMEDIATYPE_H #define DIRECTSHOWMEDIATYPE_H +#include <dshow.h> + #include <qvideosurfaceformat.h> -#include <dshow.h> #include <dvdmedia.h> class DirectShowMediaType : public AM_MEDIA_TYPE diff --git a/src/plugins/directshow/player/directshowmediatypelist.h b/src/plugins/directshow/player/directshowmediatypelist.h index 0579dada7..c6dac0e9b 100644 --- a/src/plugins/directshow/player/directshowmediatypelist.h +++ b/src/plugins/directshow/player/directshowmediatypelist.h @@ -40,10 +40,10 @@ #ifndef DIRECTSHOWMEDIATYPELIST_H #define DIRECTSHOWMEDIATYPELIST_H -#include <QtCore/qvector.h> - #include <dshow.h> +#include <QtCore/qvector.h> + class DirectShowMediaTypeList : public IUnknown { public: diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.cpp b/src/plugins/directshow/player/directshowmetadatacontrol.cpp index 8e4f5a766..6a88d76a9 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.cpp +++ b/src/plugins/directshow/player/directshowmetadatacontrol.cpp @@ -37,13 +37,20 @@ ** ****************************************************************************/ +#include <dshow.h> +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + #include <QtMultimedia/qmediametadata.h> #include <QtCore/qcoreapplication.h> #include <QSize> #include <qdatetime.h> #include <qimage.h> -#include <dshow.h> #include <initguid.h> #include <qnetwork.h> diff --git a/src/plugins/directshow/player/directshowmetadatacontrol.h b/src/plugins/directshow/player/directshowmetadatacontrol.h index e871bdb14..b42b48c67 100644 --- a/src/plugins/directshow/player/directshowmetadatacontrol.h +++ b/src/plugins/directshow/player/directshowmetadatacontrol.h @@ -40,6 +40,8 @@ #ifndef DIRECTSHOWMETADATACONTROL_H #define DIRECTSHOWMETADATACONTROL_H +#include <dshow.h> + #include <qmetadatareadercontrol.h> #include "directshowglobal.h" diff --git a/src/plugins/directshow/player/directshowpinenum.h b/src/plugins/directshow/player/directshowpinenum.h index c95f23d68..8859f49a5 100644 --- a/src/plugins/directshow/player/directshowpinenum.h +++ b/src/plugins/directshow/player/directshowpinenum.h @@ -40,9 +40,10 @@ #ifndef DIRECTSHOWPINENUM_H #define DIRECTSHOWPINENUM_H +#include <dshow.h> + #include <QtCore/qlist.h> -#include <dshow.h> class DirectShowPinEnum : public IEnumPins { diff --git a/src/plugins/directshow/player/directshowplayercontrol.cpp b/src/plugins/directshow/player/directshowplayercontrol.cpp index 490add322..d4fd0c8be 100644 --- a/src/plugins/directshow/player/directshowplayercontrol.cpp +++ b/src/plugins/directshow/player/directshowplayercontrol.cpp @@ -37,6 +37,8 @@ ** ****************************************************************************/ +#include <dshow.h> + #include "directshowplayercontrol.h" #include "directshowplayerservice.h" diff --git a/src/plugins/directshow/player/directshowplayercontrol.h b/src/plugins/directshow/player/directshowplayercontrol.h index 295f6527b..184951544 100644 --- a/src/plugins/directshow/player/directshowplayercontrol.h +++ b/src/plugins/directshow/player/directshowplayercontrol.h @@ -40,6 +40,8 @@ #ifndef DIRECTSHOWPLAYERCONTROL_H #define DIRECTSHOWPLAYERCONTROL_H +#include <dshow.h> + #include "qmediacontent.h" #include "qmediaplayercontrol.h" diff --git a/src/plugins/directshow/player/directshowplayerservice.cpp b/src/plugins/directshow/player/directshowplayerservice.cpp index 74b37a2a2..7c2cd8a9a 100644 --- a/src/plugins/directshow/player/directshowplayerservice.cpp +++ b/src/plugins/directshow/player/directshowplayerservice.cpp @@ -37,14 +37,25 @@ ** ****************************************************************************/ +#include <dshow.h> +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + #include "directshowplayerservice.h" +#ifndef Q_OS_WINCE #include "directshowaudioendpointcontrol.h" -#include "directshowiosource.h" #include "directshowmetadatacontrol.h" +#include "vmr9videowindowcontrol.h" +#endif +#include "directshowiosource.h" #include "directshowplayercontrol.h" #include "directshowvideorenderercontrol.h" -#include "vmr9videowindowcontrol.h" + #ifdef HAVE_EVR #include "directshowevrvideowindowcontrol.h" @@ -85,10 +96,14 @@ private: DirectShowPlayerService::DirectShowPlayerService(QObject *parent) : QMediaService(parent) , m_playerControl(0) +#ifndef Q_OS_WINCE , m_metaDataControl(0) +#endif , m_videoRendererControl(0) +#ifndef Q_OS_WINCE , m_videoWindowControl(0) , m_audioEndpointControl(0) +#endif , m_taskThread(0) , m_loop(qt_directShowEventLoop()) , m_pendingTasks(0) @@ -112,8 +127,10 @@ DirectShowPlayerService::DirectShowPlayerService(QObject *parent) , m_dontCacheNextSeekResult(false) { m_playerControl = new DirectShowPlayerControl(this); +#ifndef Q_OS_WINCE m_metaDataControl = new DirectShowMetaDataControl(this); m_audioEndpointControl = new DirectShowAudioEndpointControl(this); +#endif m_taskThread = new DirectShowPlayerServiceThread(this); m_taskThread->start(); @@ -144,10 +161,14 @@ DirectShowPlayerService::~DirectShowPlayerService() } delete m_playerControl; +#ifndef Q_OS_WINCE delete m_audioEndpointControl; delete m_metaDataControl; +#endif delete m_videoRendererControl; +#ifndef Q_OS_WINCE delete m_videoWindowControl; +#endif ::CloseHandle(m_taskHandle); } @@ -156,12 +177,18 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name) { if (qstrcmp(name, QMediaPlayerControl_iid) == 0) { return m_playerControl; +#ifndef Q_OS_WINCE } else if (qstrcmp(name, QAudioOutputSelectorControl_iid) == 0) { return m_audioEndpointControl; } else if (qstrcmp(name, QMetaDataReaderControl_iid) == 0) { return m_metaDataControl; +#endif } else if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - if (!m_videoRendererControl && !m_videoWindowControl) { + if (!m_videoRendererControl +#ifndef Q_OS_WINCE + && !m_videoWindowControl +#endif + ){ m_videoRendererControl = new DirectShowVideoRendererControl(m_loop); connect(m_videoRendererControl, SIGNAL(filterChanged()), @@ -169,6 +196,7 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name) return m_videoRendererControl; } +#ifndef Q_OS_WINCE } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { if (!m_videoRendererControl && !m_videoWindowControl) { IBaseFilter *filter; @@ -191,6 +219,7 @@ QMediaControl *DirectShowPlayerService::requestControl(const char *name) return m_videoWindowControl; } +#endif } return 0; } @@ -206,12 +235,14 @@ void DirectShowPlayerService::releaseControl(QMediaControl *control) delete m_videoRendererControl; m_videoRendererControl = 0; +#ifndef Q_OS_WINCE } else if (control == m_videoWindowControl) { setVideoOutput(0); delete m_videoWindowControl; m_videoWindowControl = 0; +#endif } } @@ -237,7 +268,9 @@ void DirectShowPlayerService::load(const QMediaContent &media, QIODevice *stream m_seekable = false; m_atEnd = false; m_dontCacheNextSeekResult = false; +#ifndef Q_OS_WINCE m_metaDataControl->reset(); +#endif if (m_resources.isEmpty() && !stream) { m_pendingTasks = 0; @@ -1141,7 +1174,9 @@ void DirectShowPlayerService::customEvent(QEvent *event) QMutexLocker locker(&m_mutex); m_playerControl->updateMediaInfo(m_duration, m_streamTypes, m_seekable); +#ifndef Q_OS_WINCE m_metaDataControl->updateMetadata(m_graph, m_source, m_url.toString()); +#endif updateStatus(); } else if (event->type() == QEvent::Type(Error)) { diff --git a/src/plugins/directshow/player/directshowplayerservice.h b/src/plugins/directshow/player/directshowplayerservice.h index 8eaa2db8d..9419a8a99 100644 --- a/src/plugins/directshow/player/directshowplayerservice.h +++ b/src/plugins/directshow/player/directshowplayerservice.h @@ -40,6 +40,8 @@ #ifndef DIRECTSHOWPLAYERSERVICE_H #define DIRECTSHOWPLAYERSERVICE_H +#include <dshow.h> + #include "qmediaplayer.h" #include "qmediaresource.h" #include "qmediaservice.h" @@ -174,10 +176,14 @@ private: }; DirectShowPlayerControl *m_playerControl; +#ifndef Q_OS_WINCE DirectShowMetaDataControl *m_metaDataControl; +#endif DirectShowVideoRendererControl *m_videoRendererControl; +#ifndef Q_OS_WINCE QVideoWindowControl *m_videoWindowControl; DirectShowAudioEndpointControl *m_audioEndpointControl; +#endif QThread *m_taskThread; DirectShowEventLoop *m_loop; diff --git a/src/plugins/directshow/player/directshowsamplescheduler.h b/src/plugins/directshow/player/directshowsamplescheduler.h index cce418ab7..1670d23ed 100644 --- a/src/plugins/directshow/player/directshowsamplescheduler.h +++ b/src/plugins/directshow/player/directshowsamplescheduler.h @@ -40,12 +40,12 @@ #ifndef DIRECTSHOWSAMPLESCHEDULER_H #define DIRECTSHOWSAMPLESCHEDULER_H +#include <dshow.h> + #include <QtCore/qmutex.h> #include <QtCore/qobject.h> #include <QtCore/qsemaphore.h> -#include <dshow.h> - class DirectShowTimedSample; class DirectShowSampleScheduler : public QObject, public IMemInputPin diff --git a/src/plugins/directshow/player/directshowvideorenderercontrol.h b/src/plugins/directshow/player/directshowvideorenderercontrol.h index 5082e6bd7..17dd4705b 100644 --- a/src/plugins/directshow/player/directshowvideorenderercontrol.h +++ b/src/plugins/directshow/player/directshowvideorenderercontrol.h @@ -40,10 +40,10 @@ #ifndef DIRECTSHOWVIDEORENDERERCONTROL_H #define DIRECTSHOWVIDEORENDERERCONTROL_H -#include "qvideorenderercontrol.h" - #include <dshow.h> +#include "qvideorenderercontrol.h" + class DirectShowEventLoop; QT_USE_NAMESPACE diff --git a/src/plugins/directshow/player/mediasamplevideobuffer.h b/src/plugins/directshow/player/mediasamplevideobuffer.h index cf4142972..6ec1470c5 100644 --- a/src/plugins/directshow/player/mediasamplevideobuffer.h +++ b/src/plugins/directshow/player/mediasamplevideobuffer.h @@ -40,10 +40,10 @@ #ifndef MEDIASAMPLEVIDEOBUFFER_H #define MEDIASAMPLEVIDEOBUFFER_H -#include <qabstractvideobuffer.h> - #include <dshow.h> +#include <qabstractvideobuffer.h> + class MediaSampleVideoBuffer : public QAbstractVideoBuffer { public: diff --git a/src/plugins/directshow/player/player.pri b/src/plugins/directshow/player/player.pri index 5ecb912b2..c5fb8442a 100644 --- a/src/plugins/directshow/player/player.pri +++ b/src/plugins/directshow/player/player.pri @@ -1,45 +1,53 @@ INCLUDEPATH += $$PWD -LIBS += -lstrmiids -ldmoguids -luuid -lmsdmo -lole32 -loleaut32 -lgdi32 +LIBS += -lstrmiids -ldmoguids -luuid -lole32 -loleaut32 +!wince: LIBS += -lmsdmo -lgdi32 + qtHaveModule(widgets): QT += widgets DEFINES += QMEDIA_DIRECTSHOW_PLAYER HEADERS += \ - $$PWD/directshowaudioendpointcontrol.h \ $$PWD/directshoweventloop.h \ $$PWD/directshowglobal.h \ $$PWD/directshowioreader.h \ $$PWD/directshowiosource.h \ $$PWD/directshowmediatype.h \ $$PWD/directshowmediatypelist.h \ - $$PWD/directshowmetadatacontrol.h \ $$PWD/directshowpinenum.h \ $$PWD/directshowplayercontrol.h \ $$PWD/directshowplayerservice.h \ $$PWD/directshowsamplescheduler.h \ $$PWD/directshowvideorenderercontrol.h \ $$PWD/mediasamplevideobuffer.h \ - $$PWD/videosurfacefilter.h \ - $$PWD/vmr9videowindowcontrol.h + $$PWD/videosurfacefilter.h SOURCES += \ - $$PWD/directshowaudioendpointcontrol.cpp \ $$PWD/directshoweventloop.cpp \ $$PWD/directshowioreader.cpp \ $$PWD/directshowiosource.cpp \ $$PWD/directshowmediatype.cpp \ $$PWD/directshowmediatypelist.cpp \ - $$PWD/directshowmetadatacontrol.cpp \ $$PWD/directshowpinenum.cpp \ $$PWD/directshowplayercontrol.cpp \ $$PWD/directshowplayerservice.cpp \ $$PWD/directshowsamplescheduler.cpp \ $$PWD/directshowvideorenderercontrol.cpp \ $$PWD/mediasamplevideobuffer.cpp \ - $$PWD/videosurfacefilter.cpp \ + $$PWD/videosurfacefilter.cpp + +!wince { +HEADERS += \ + $$PWD/directshowaudioendpointcontrol.h \ + $$PWD/directshowmetadatacontrol.h \ + $$PWD/vmr9videowindowcontrol.h + +SOURCES += \ + $$PWD/directshowaudioendpointcontrol.cpp \ + $$PWD/directshowmetadatacontrol.cpp \ $$PWD/vmr9videowindowcontrol.cpp +} config_evr { DEFINES += HAVE_EVR diff --git a/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/src/plugins/pulseaudio/qaudioinput_pulse.cpp index ebf6f0a4b..050731071 100644 --- a/src/plugins/pulseaudio/qaudioinput_pulse.cpp +++ b/src/plugins/pulseaudio/qaudioinput_pulse.cpp @@ -40,6 +40,7 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qdebug.h> #include <QtCore/qmath.h> +#include <private/qaudiohelpers_p.h> #include "qaudioinput_pulse.h" #include "qaudiodeviceinfo_pulse.h" @@ -124,39 +125,12 @@ static void inputStreamSuccessCallback(pa_stream *stream, int success, void *use pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); } -void QPulseAudioInput::sourceInfoCallback(pa_context *context, const pa_source_info *i, int eol, void *userdata) -{ - Q_UNUSED(context); - Q_UNUSED(eol); - - Q_ASSERT(userdata); - if (i) { - QPulseAudioInput *that = reinterpret_cast<QPulseAudioInput*>(userdata); - that->m_volume = pa_sw_volume_to_linear(pa_cvolume_avg(&i->volume)); - } -} - -void QPulseAudioInput::inputVolumeCallback(pa_context *context, int success, void *userdata) -{ - Q_UNUSED(success); - - if (!success) - qWarning() << "QAudioInput: failed to set input volume"; - - QPulseAudioInput *that = reinterpret_cast<QPulseAudioInput*>(userdata); - - // Regardless of success or failure, we update the volume property - if (that->m_stream) - pa_context_get_source_info_by_index(context, pa_stream_get_device_index(that->m_stream), sourceInfoCallback, userdata); -} - QPulseAudioInput::QPulseAudioInput(const QByteArray &device) : m_totalTimeValue(0) , m_audioSource(0) , m_errorState(QAudio::NoError) , m_deviceState(QAudio::StoppedState) , m_volume(qreal(1.0f)) - , m_customVolumeRequired(false) , m_pullMode(true) , m_opened(false) , m_bytesAvailable(0) @@ -362,9 +336,6 @@ bool QPulseAudioInput::open() if (actualBufferAttr->tlength != (uint32_t)-1) m_bufferSize = actualBufferAttr->tlength; - if (m_customVolumeRequired) - setPulseVolume(); - pulseEngine->unlock(); connect(pulseEngine, &QPulseAudioEngine::contextFailed, this, &QPulseAudioInput::onPulseContextFailed); @@ -413,32 +384,6 @@ void QPulseAudioInput::close() m_opened = false; } -/* Call this with the stream opened and the mainloop locked */ -void QPulseAudioInput::setPulseVolume() -{ - QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); - Q_ASSERT(pulseEngine->context() != 0); - - pa_cvolume cvolume; - - if (qFuzzyCompare(m_volume, 0.0)) { - pa_cvolume_mute(&cvolume, m_spec.channels); - } else { - pa_cvolume_set(&cvolume, m_spec.channels, pa_sw_volume_from_linear(m_volume)); - } - - pa_operation *op = pa_context_set_source_volume_by_index(pulseEngine->context(), - pa_stream_get_device_index(m_stream), - &cvolume, - inputVolumeCallback, - this); - - if (op == NULL) - qWarning() << "QAudioInput: Failed to set volume"; - else - pa_operation_unref(op); -} - int QPulseAudioInput::checkBytesReady() { if (m_deviceState != QAudio::ActiveState && m_deviceState != QAudio::IdleState) { @@ -500,7 +445,9 @@ qint64 QPulseAudioInput::read(char *data, qint64 len) qint64 actualLength = 0; if (m_pullMode) { - actualLength = m_audioSource->write(static_cast<const char *>(audioBuffer), readLength); + QByteArray adjusted(readLength, Qt::Uninitialized); + applyVolume(audioBuffer, adjusted.data(), readLength); + actualLength = m_audioSource->write(adjusted); if (actualLength < qint64(readLength)) { pulseEngine->unlock(); @@ -512,7 +459,7 @@ qint64 QPulseAudioInput::read(char *data, qint64 len) } } else { actualLength = qMin(static_cast<int>(len - readBytes), static_cast<int>(readLength)); - memcpy(data + readBytes, audioBuffer, actualLength); + applyVolume(audioBuffer, data + readBytes, actualLength); } #ifdef DEBUG_PULSE @@ -523,7 +470,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len) #ifdef DEBUG_PULSE qDebug() << "QPulseAudioInput::read -- appending " << readLength - actualLength << " bytes of data to temp buffer"; #endif - m_tempBuffer.append(static_cast<const char *>(audioBuffer) + actualLength, readLength - actualLength); + int diff = readLength - actualLength; + int oldSize = m_tempBuffer.size(); + m_tempBuffer.resize(m_tempBuffer.size() + diff); + applyVolume(static_cast<const char *>(audioBuffer) + actualLength, m_tempBuffer.data() + oldSize, diff); QMetaObject::invokeMethod(this, "userFeed", Qt::QueuedConnection); } @@ -550,6 +500,14 @@ qint64 QPulseAudioInput::read(char *data, qint64 len) return readBytes; } +void QPulseAudioInput::applyVolume(const void *src, void *dest, int len) +{ + if (m_volume < 1.f) + QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len); + else + memcpy(dest, src, len); +} + void QPulseAudioInput::resume() { if (m_deviceState == QAudio::SuspendedState || m_deviceState == QAudio::IdleState) { @@ -573,30 +531,17 @@ void QPulseAudioInput::resume() void QPulseAudioInput::setVolume(qreal vol) { - if (vol >= 0.0 && vol <= 1.0) { - QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); - pulseEngine->lock(); - m_customVolumeRequired = true; - if (!qFuzzyCompare(m_volume, vol)) { - m_volume = vol; - if (m_opened) { - setPulseVolume(); - } - } - pulseEngine->unlock(); - } + if (qFuzzyCompare(m_volume, vol)) + return; + + m_volume = qBound(qreal(0), vol, qreal(1)); } qreal QPulseAudioInput::volume() const { - QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); - pulseEngine->lock(); - qreal vol = m_volume; - pulseEngine->unlock(); - return vol; + return m_volume; } - void QPulseAudioInput::setBufferSize(int value) { m_bufferSize = value; diff --git a/src/plugins/pulseaudio/qaudioinput_pulse.h b/src/plugins/pulseaudio/qaudioinput_pulse.h index c04cd1299..32a2c031c 100644 --- a/src/plugins/pulseaudio/qaudioinput_pulse.h +++ b/src/plugins/pulseaudio/qaudioinput_pulse.h @@ -106,8 +106,6 @@ public: QAudio::Error m_errorState; QAudio::State m_deviceState; qreal m_volume; - bool m_customVolumeRequired; - pa_cvolume m_chVolume; private slots: void userFeed(); @@ -118,13 +116,11 @@ private: void setState(QAudio::State state); void setError(QAudio::Error error); + void applyVolume(const void *src, void *dest, int len); + int checkBytesReady(); bool open(); void close(); - void setPulseVolume(); - - static void sourceInfoCallback(pa_context *c, const pa_source_info *i, int eol, void *userdata); - static void inputVolumeCallback(pa_context *context, int success, void *userdata); bool m_pullMode; bool m_opened; diff --git a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp index f905e69ee..0c7dc270a 100644 --- a/src/plugins/pulseaudio/qaudiooutput_pulse.cpp +++ b/src/plugins/pulseaudio/qaudiooutput_pulse.cpp @@ -40,6 +40,7 @@ #include <QtCore/qcoreapplication.h> #include <QtCore/qdebug.h> #include <QtCore/qmath.h> +#include <private/qaudiohelpers_p.h> #include "qaudiooutput_pulse.h" #include "qaudiodeviceinfo_pulse.h" @@ -168,7 +169,6 @@ QPulseAudioOutput::QPulseAudioOutput(const QByteArray &device) , m_audioBuffer(0) , m_resuming(false) , m_volume(1.0) - , m_customVolumeRequired(false) { connect(m_tickTimer, SIGNAL(timeout()), SLOT(userFeed())); } @@ -318,27 +318,6 @@ bool QPulseAudioOutput::open() pa_stream_set_overflow_callback(m_stream, outputStreamOverflowCallback, this); pa_stream_set_latency_update_callback(m_stream, outputStreamLatencyCallback, this); - pa_volume_t paVolume; - - /* streams without a custom volume set are expected to already have a - * sensible volume set by Pulse, so we don't set it explicitly. - * - * explicit setting also breaks volume handling on sailfish, where each - * stream's volume is set separately inside pulseaudio, with the - * exception of streams that already have a volume set (i.e. if we set - * it here, we'd ignore system volume). - */ - if (m_customVolumeRequired) { - if (qFuzzyCompare(m_volume, 0.0)) { - paVolume = PA_VOLUME_MUTED; - m_volume = 0.0; - } else { - paVolume = qFloor(m_volume * PA_VOLUME_NORM + 0.5); - } - - pa_cvolume_set(&m_chVolume, m_spec.channels, paVolume); - } - if (m_bufferSize <= 0 && m_category == LOW_LATENCY_CATEGORY_NAME) { m_bufferSize = bytesPerSecond * LowLatencyBufferSizeMs / qint64(1000); } @@ -350,7 +329,7 @@ bool QPulseAudioOutput::open() requestedBuffer.prebuf = (uint32_t)-1; requestedBuffer.tlength = m_bufferSize; - if (pa_stream_connect_playback(m_stream, m_device.data(), (m_bufferSize > 0) ? &requestedBuffer : NULL, (pa_stream_flags_t)0, m_customVolumeRequired ? &m_chVolume : NULL, NULL) < 0) { + if (pa_stream_connect_playback(m_stream, m_device.data(), (m_bufferSize > 0) ? &requestedBuffer : NULL, (pa_stream_flags_t)0, NULL, NULL) < 0) { qWarning() << "pa_stream_connect_playback() failed!"; pa_stream_unref(m_stream); m_stream = 0; @@ -497,8 +476,33 @@ qint64 QPulseAudioOutput::write(const char *data, qint64 len) QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); pulseEngine->lock(); + len = qMin(len, static_cast<qint64>(pa_stream_writable_size(m_stream))); - pa_stream_write(m_stream, data, len, 0, 0, PA_SEEK_RELATIVE); + + if (m_volume < 1.0f) { + // Don't use PulseAudio volume, as it might affect all other streams of the same category + // or even affect the system volume if flat volumes are enabled + void *dest = NULL; + size_t nbytes = len; + if (pa_stream_begin_write(m_stream, &dest, &nbytes) < 0) { + qWarning("QAudioOutput(pulseaudio): pa_stream_begin_write, error = %s", + pa_strerror(pa_context_errno(pulseEngine->context()))); + setError(QAudio::IOError); + return 0; + } + + len = int(nbytes); + QAudioHelperInternal::qMultiplySamples(m_volume, m_format, data, dest, len); + data = reinterpret_cast<char *>(dest); + } + + if (pa_stream_write(m_stream, data, len, NULL, 0, PA_SEEK_RELATIVE) < 0) { + qWarning("QAudioOutput(pulseaudio): pa_stream_write, error = %s", + pa_strerror(pa_context_errno(pulseEngine->context()))); + setError(QAudio::IOError); + return 0; + } + pulseEngine->unlock(); m_totalTimeValue += len; @@ -670,34 +674,10 @@ qint64 PulseOutputPrivate::writeData(const char *data, qint64 len) void QPulseAudioOutput::setVolume(qreal vol) { - if (vol >= 0.0 && vol <= 1.0) { - if (!qFuzzyCompare(m_volume, vol)) { - m_customVolumeRequired = true; - m_volume = vol; - if (m_opened) { - QPulseAudioEngine *pulseEngine = QPulseAudioEngine::instance(); - pulseEngine->lock(); - pa_volume_t paVolume; - if (qFuzzyCompare(vol, 0.0)) { - pa_cvolume_mute(&m_chVolume, m_spec.channels); - m_volume = 0.0; - } else { - paVolume = qFloor(m_volume * PA_VOLUME_NORM + 0.5); - pa_cvolume_set(&m_chVolume, m_spec.channels, paVolume); - } - pa_operation *op = pa_context_set_sink_input_volume(pulseEngine->context(), - pa_stream_get_index(m_stream), - &m_chVolume, - NULL, - NULL); - if (op == NULL) - qWarning()<<"QAudioOutput: Failed to set volume"; - else - pa_operation_unref(op); - pulseEngine->unlock(); - } - } - } + if (qFuzzyCompare(m_volume, vol)) + return; + + m_volume = qBound(qreal(0), vol, qreal(1)); } qreal QPulseAudioOutput::volume() const diff --git a/src/plugins/pulseaudio/qaudiooutput_pulse.h b/src/plugins/pulseaudio/qaudiooutput_pulse.h index a628c6bae..58f175e18 100644 --- a/src/plugins/pulseaudio/qaudiooutput_pulse.h +++ b/src/plugins/pulseaudio/qaudiooutput_pulse.h @@ -141,8 +141,6 @@ private: QString m_category; qreal m_volume; - bool m_customVolumeRequired; - pa_cvolume m_chVolume; pa_sample_spec m_spec; }; diff --git a/src/plugins/qnx/common/windowgrabber.cpp b/src/plugins/qnx/common/windowgrabber.cpp index 19cd73f03..5f42096fb 100644 --- a/src/plugins/qnx/common/windowgrabber.cpp +++ b/src/plugins/qnx/common/windowgrabber.cpp @@ -282,7 +282,8 @@ bool WindowGrabber::handleScreenEvent(screen_event_t screen_event) return false; } - if (m_windowId == idString) { + // Grab windows that have a non-empty ID string and a matching window id to grab + if (idString[0] != '\0' && m_windowId == idString) { m_window = window; start(); } diff --git a/src/plugins/wmf/player/mfaudioendpointcontrol.cpp b/src/plugins/wmf/player/mfaudioendpointcontrol.cpp index 054f5c12b..3b86c52b7 100644 --- a/src/plugins/wmf/player/mfaudioendpointcontrol.cpp +++ b/src/plugins/wmf/player/mfaudioendpointcontrol.cpp @@ -40,6 +40,8 @@ #include "QtCore/qdebug.h" #include "mfaudioendpointcontrol.h" +#include <mmdeviceapi.h> + MFAudioEndpointControl::MFAudioEndpointControl(QObject *parent) : QAudioOutputSelectorControl(parent) , m_currentActivate(0) diff --git a/src/plugins/wmf/player/mfaudioendpointcontrol.h b/src/plugins/wmf/player/mfaudioendpointcontrol.h index 770ed1386..a439c31a5 100644 --- a/src/plugins/wmf/player/mfaudioendpointcontrol.h +++ b/src/plugins/wmf/player/mfaudioendpointcontrol.h @@ -42,7 +42,6 @@ #include <mfapi.h> #include <mfidl.h> -#include <mmdeviceapi.h> #include "qaudiooutputselectorcontrol.h" |