Commit 7facf3b4 authored by Johannes Zarl-Zierl's avatar Johannes Zarl-Zierl
Browse files

Implement bidirectional audio mute propagation for Phonon

According to the docs, this *should* work. Yet, clicking the mute button
for KPhotoAlbum's audio stream does not cause the
Phonon::AudioOutput::muteChanged signal to fire.
parent 1752f08d
Pipeline #194645 failed with stage
in 12 minutes and 1 second
...@@ -72,9 +72,11 @@ void Viewer::PhononDisplay::setup() ...@@ -72,9 +72,11 @@ void Viewer::PhononDisplay::setup()
connect(m_mediaObject, &Phonon::MediaObject::stateChanged, this, &PhononDisplay::phononStateChanged); connect(m_mediaObject, &Phonon::MediaObject::stateChanged, this, &PhononDisplay::phononStateChanged);
connect(m_mediaObject, &Phonon::MediaObject::tick, m_videoToolBar, &VideoToolBar::setPosition); connect(m_mediaObject, &Phonon::MediaObject::tick, m_videoToolBar, &VideoToolBar::setPosition);
connect(m_videoToolBar, &VideoToolBar::positionChanged, m_mediaObject, &Phonon::MediaObject::seek); connect(m_videoToolBar, &VideoToolBar::positionChanged, m_mediaObject, &Phonon::MediaObject::seek);
connect(m_videoToolBar, &VideoToolBar::muted, m_audioDevice, &Phonon::AudioOutput::setMuted); // use proxy slots to avoid a signal-loop between the VideoToolBar and the Phonon::AudioOutput
connect(m_videoToolBar, &VideoToolBar::volumeChanged, this, &PhononDisplay::changeVolume); connect(m_videoToolBar, &VideoToolBar::volumeChanged, this, &PhononDisplay::changeVolume);
connect(m_audioDevice, &Phonon::AudioOutput::volumeChanged, this, &PhononDisplay::updateVolume); connect(m_audioDevice, &Phonon::AudioOutput::volumeChanged, this, &PhononDisplay::updateVolume);
connect(m_videoToolBar, &VideoToolBar::muted, this, &PhononDisplay::setMuted);
connect(m_audioDevice, &Phonon::AudioOutput::mutedChanged, this, &PhononDisplay::updateMuteState);
} }
bool Viewer::PhononDisplay::setImageImpl(DB::ImageInfoPtr info, bool /*forward*/) bool Viewer::PhononDisplay::setImageImpl(DB::ImageInfoPtr info, bool /*forward*/)
...@@ -188,6 +190,12 @@ void Viewer::PhononDisplay::updateVolume(qreal newVolumeVolt) ...@@ -188,6 +190,12 @@ void Viewer::PhononDisplay::updateVolume(qreal newVolumeVolt)
m_videoToolBar->setVolume(qPow(newVolumeVolt, VOLTAGE_TO_LOUDNESS_EXPONENT) * 100.0); m_videoToolBar->setVolume(qPow(newVolumeVolt, VOLTAGE_TO_LOUDNESS_EXPONENT) * 100.0);
} }
void Viewer::PhononDisplay::updateMuteState(bool mute)
{
const QSignalBlocker blocker { m_videoToolBar };
m_videoToolBar->setMuted(mute);
}
void Viewer::PhononDisplay::setVideoWidgetSize() void Viewer::PhononDisplay::setVideoWidgetSize()
{ {
if (!m_mediaObject) if (!m_mediaObject)
...@@ -213,7 +221,6 @@ void Viewer::PhononDisplay::setVideoWidgetSize() ...@@ -213,7 +221,6 @@ void Viewer::PhononDisplay::setVideoWidgetSize()
m_videoToolBar->move(0, height() - m_videoToolBar->sizeHint().height()); m_videoToolBar->move(0, height() - m_videoToolBar->sizeHint().height());
m_videoToolBar->resize(width(), m_videoToolBar->sizeHint().height()); m_videoToolBar->resize(width(), m_videoToolBar->sizeHint().height());
m_videoToolBar->setRange(0, m_mediaObject->totalTime()); m_videoToolBar->setRange(0, m_mediaObject->totalTime());
updateVolume(m_audioDevice->volume());
} }
void Viewer::PhononDisplay::rotate(const DB::ImageInfoPtr & /*info*/) void Viewer::PhononDisplay::rotate(const DB::ImageInfoPtr & /*info*/)
...@@ -227,6 +234,12 @@ void Viewer::PhononDisplay::changeVolume(int newVolumePercent) ...@@ -227,6 +234,12 @@ void Viewer::PhononDisplay::changeVolume(int newVolumePercent)
m_audioDevice->setVolume(qPow(newVolumePercent / 100.0, LOUDNESS_TO_VOLTAGE_EXPONENT)); m_audioDevice->setVolume(qPow(newVolumePercent / 100.0, LOUDNESS_TO_VOLTAGE_EXPONENT));
} }
void Viewer::PhononDisplay::setMuted(bool mute)
{
QSignalBlocker blocker { m_audioDevice };
m_audioDevice->setMuted(mute);
}
void Viewer::PhononDisplay::relativeSeek(int msec) void Viewer::PhononDisplay::relativeSeek(int msec)
{ {
m_mediaObject->seek(m_mediaObject->currentTime() + msec); m_mediaObject->seek(m_mediaObject->currentTime() + msec);
......
...@@ -46,10 +46,12 @@ public slots: ...@@ -46,10 +46,12 @@ public slots:
void restart() override; void restart() override;
void rotate(const DB::ImageInfoPtr &info) override; void rotate(const DB::ImageInfoPtr &info) override;
void changeVolume(int newVolumePercent); void changeVolume(int newVolumePercent);
void setMuted(bool mute);
private slots: private slots:
void phononStateChanged(Phonon::State, Phonon::State); void phononStateChanged(Phonon::State, Phonon::State);
void updateVolume(qreal newVolumeVolt); void updateVolume(qreal newVolumeVolt);
void updateMuteState(bool mute);
protected: protected:
void resize(double factor); void resize(double factor);
......
Supports Markdown
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