audio – Qt 5.12.8 QMediaPlayer::setMuted / setVolume latency
I’m experiencing non-deterministic latency when calling setMuted(bool) or setVolume(qreal) on QMediaPlayer (Qt 5.12.8, but 5.15 may still be affected).
After the call returns, the audible state / loudness does not change immediately; it can take anywhere from a few tens to a few hundred milliseconds before the user actually hears the difference.
For a responsive media-player this is unacceptable.
Looking at the Qt source, both methods finally reach
void QGstreamerPlayerSession::setMuted(bool muted)
{
if (m_muted == muted) return;
m_muted = muted;
if (m_volumeElement) // this is the playbin’s volume element
g_object_set(G_OBJECT(m_volumeElement), "mute", m_muted, nullptr);
emit mutedStateChanged(m_muted);
}
The g_object_set call is asynchronous: it merely posts a message to the GStreamer pipeline and returns immediately.
If the pipeline is blocked inside a queue or a sink buffer, the new mute/volume value will not be applied until that buffer is drained, producing the perceived delay.
Has anyone found a reliable way to force the change to become effective in the very next audio fragment, or at least to bound the worst-case latency?
Read more here: Source link
