Commit 8175ec76 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

use a timer to delay sending mutedChanged signal to avoid Qml detecting loop

parent e8bd51b4
......@@ -35,7 +35,7 @@ public:
AudioWrapper::AudioWrapper(QObject *parent) : QObject(parent), d(new AudioWrapperPrivate)
{
connect(&d->mPlayer, &QMediaPlayer::mutedChanged, this, &AudioWrapper::mutedChanged);
connect(&d->mPlayer, &QMediaPlayer::mutedChanged, this, &AudioWrapper::playerMutedChanged);
connect(&d->mPlayer, &QMediaPlayer::volumeChanged, this, &AudioWrapper::playerVolumeChanged);
connect(&d->mPlayer, &QMediaPlayer::mediaChanged, this, &AudioWrapper::sourceChanged);
connect(&d->mPlayer, &QMediaPlayer::mediaStatusChanged, this, &AudioWrapper::statusChanged);
......@@ -149,7 +149,8 @@ void AudioWrapper::setAudioRole(QAudio::Role audioRole)
void AudioWrapper::playerStateChanged()
{
switch(d->mPlayer.state()) {
switch(d->mPlayer.state())
{
case QMediaPlayer::State::StoppedState:
Q_EMIT stopped();
break;
......@@ -167,5 +168,10 @@ void AudioWrapper::playerVolumeChanged()
QTimer::singleShot(0, [this]() {Q_EMIT volumeChanged();});
}
void AudioWrapper::playerMutedChanged()
{
QTimer::singleShot(0, [this]() {Q_EMIT mutedChanged();});
}
#include "moc_audiowrapper.cpp"
......@@ -156,6 +156,8 @@ private Q_SLOTS:
void playerVolumeChanged();
void playerMutedChanged();
private:
AudioWrapperPrivate *d = nullptr;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment