summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.cpp13
-rw-r--r--src/multimedia/audio/qsoundeffect_pulse_p.h5
2 files changed, 11 insertions, 7 deletions
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.cpp b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
index bf647ea..a86f228 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.cpp
@@ -535,31 +535,34 @@ void QSoundEffectPrivate::setLoopCount(int loopCount)
qreal QSoundEffectPrivate::volume() const
{
- QReadLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
return m_volume;
}
void QSoundEffectPrivate::setVolume(qreal volume)
{
- QWriteLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
if (qFuzzyCompare(m_volume, volume))
return;
m_volume = qBound(qreal(0), volume, qreal(1));
+ locker.unlock();
emit volumeChanged();
}
bool QSoundEffectPrivate::isMuted() const
{
- QReadLocker locker(&m_volumeLock);
+ QMutexLocker locker(&m_volumeLock);
return m_muted;
}
void QSoundEffectPrivate::setMuted(bool muted)
{
- QWriteLocker locker(&m_volumeLock);
+ m_volumeLock.lock();
m_muted = muted;
+ m_volumeLock.unlock();
+
emit mutedChanged();
}
@@ -884,7 +887,7 @@ int QSoundEffectPrivate::writeToStream(const void *data, int size)
if (size < 1)
return 0;
- m_volumeLock.lockForRead();
+ m_volumeLock.lock();
qreal volume = m_muted ? 0 : m_volume;
m_volumeLock.unlock();
pa_free_cb_t writeDoneCb = stream_write_done_callback;
diff --git a/src/multimedia/audio/qsoundeffect_pulse_p.h b/src/multimedia/audio/qsoundeffect_pulse_p.h
index 7be88c5..268a993 100644
--- a/src/multimedia/audio/qsoundeffect_pulse_p.h
+++ b/src/multimedia/audio/qsoundeffect_pulse_p.h
@@ -56,7 +56,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qdatetime.h>
-#include <QtCore/qreadwritelock.h>
+#include <QtCore/qmutex.h>
#include <qmediaplayer.h>
#include <pulse/pulseaudio.h>
#include "qsamplecache_p.h"
@@ -175,7 +175,8 @@ private:
bool m_resourcesAvailable;
- mutable QReadWriteLock m_volumeLock;
+ // Protects volume while PuseAudio is accessing it
+ mutable QMutex m_volumeLock;
QMediaPlayerResourceSetInterface *m_resources;
};