Workaround for a qtmultimedia backend issue

Qt multimedia with the ffmpeg backend suddenly started sending
LoadedMedia signals in the PlayingState, even though that should not be
a valid combination according to the docs.  This is messing up the
AudioManager.
This commit is contained in:
Bart De Vries 2024-04-25 13:44:31 +02:00
parent fa2fd6e3af
commit e9111eb011
No known key found for this signature in database
GPG Key ID: 7285665DA6E2D42B
2 changed files with 9 additions and 2 deletions

View File

@ -699,8 +699,15 @@ void AudioManager::checkForPendingSeek()
qCDebug(kastsAudio) << "Seek pending?" << d->m_pendingSeek;
qCDebug(kastsAudio) << "Current position" << position;
// FIXME: the LoadedMedia+PlayingState test is a workaround for a broken
// qtmultimedia backend; LoadedMedia should never be allowed in the
// PlayingState according to docs. Remove this when upstream is fixed.
// Check if we're supposed to skip to a new position
if (d->m_pendingSeek != -1 && d->m_player.mediaStatus() == KMediaSession::BufferedMedia && d->m_player.duration() > 0) {
if (d->m_pendingSeek != -1
&& (d->m_player.mediaStatus() == KMediaSession::BufferedMedia
|| (d->m_player.mediaStatus() == KMediaSession::LoadedMedia && d->m_player.playbackState() == KMediaSession::PlayingState))
&& d->m_player.duration() > 0) {
if (abs(d->m_pendingSeek - position) > 2000) {
qCDebug(kastsAudio) << "Position seek still pending to position" << d->m_pendingSeek;
qCDebug(kastsAudio) << "Current reported position and duration" << d->m_player.position() << d->m_player.duration();

View File

@ -321,7 +321,7 @@ KMediaSession::MediaStatus QtMediaBackendPrivate::translateMediaStatusEnum(QMedi
KMediaSession::PlaybackState QtMediaBackendPrivate::translatePlaybackStateEnum(QMediaPlayer::PlaybackState playbackStateEnum)
{
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translateMediaStatusEnum(" << playbackStateEnum << ")";
qCDebug(QtMediaBackendLog) << "QtMediaBackendPrivate::translatePlaybackStateEnum(" << playbackStateEnum << ")";
switch (playbackStateEnum) {
case QMediaPlayer::PlaybackState::StoppedState: