From 36ad248e55347b915901f2bdb31f7fd24d4130b2 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Thu, 29 Apr 2021 11:10:09 +0200 Subject: [PATCH] Do some additional checks on entry before loading in AudioManager --- src/audiomanager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/audiomanager.cpp b/src/audiomanager.cpp index 93341653..4fa56d80 100644 --- a/src/audiomanager.cpp +++ b/src/audiomanager.cpp @@ -96,7 +96,10 @@ QUrl AudioManager::source() const QMediaPlayer::Error AudioManager::error() const { if (d->m_player.error() != QMediaPlayer::NoError) { - //qDebug() << "AudioManager::error" << d->m_player.errorString(); + qDebug() << "AudioManager::error" << d->m_player.errorString(); + // Some error occured: probably best to unset the lastPlayingEntry to + // avoid a deadlock when starting up again. + DataManager::instance().setLastPlayingEntry(QStringLiteral("none")); } return d->m_player.error(); @@ -165,6 +168,7 @@ QMediaPlayer::MediaStatus AudioManager::status() const void AudioManager::setEntry(Entry* entry) { d->m_lockPositionSaving = true; + // First check if the previous track needs to be marked as read // TODO: make grace time a setting in SettingsManager if (d->m_entry) { @@ -179,7 +183,11 @@ void AudioManager::setEntry(Entry* entry) d->m_entry->setQueueStatus(false); // i.e. remove from queue TODO: make this a choice in settings } } - if (entry != nullptr) { + + //qDebug() << entry->hasEnclosure() << entry->enclosure() << entry->enclosure()->status(); + + // do some checks on the new entry to see whether it's valid and not corrupted + if (entry != nullptr && entry->hasEnclosure() && entry->enclosure() && entry->enclosure()->status() == Enclosure::Downloaded) { //qDebug() << "Going to change source"; d->m_entry = entry; Q_EMIT entryChanged(entry);