Skip to content

Commit

Permalink
Merge pull request mixxxdj#13551 from daschuer/gh13544
Browse files Browse the repository at this point in the history
Auto DJ: Add new random tracks if one track does not exists
  • Loading branch information
Swiftb0y authored Dec 2, 2024
2 parents 073acce + 709376d commit 400e8ed
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,20 +902,23 @@ TrackPointer AutoDJProcessor::getNextTrackFromQueue() {
}

while (true) {
TrackPointer nextTrack = m_pAutoDJTableModel->getTrack(
m_pAutoDJTableModel->index(0, 0));
TrackPointer pNextTrack = m_pAutoDJTableModel->getTrack(
m_pAutoDJTableModel->index(0, 0));

if (nextTrack) {
if (nextTrack->getFileInfo().checkFileExists()) {
return nextTrack;
if (pNextTrack) {
if (pNextTrack->getFileInfo().checkFileExists()) {
return pNextTrack;
} else {
// Remove missing song from auto DJ playlist.
// Remove missing track from auto DJ playlist.
qWarning() << "Auto DJ: Skip missing track" << pNextTrack->getLocation();
m_pAutoDJTableModel->removeTrack(
m_pAutoDJTableModel->index(0, 0));
// Don't "Requeue" missing tracks to avoid andless loops
maybeFillRandomTracks();
}
} else {
// We're out of tracks. Return the null TrackPointer.
return nextTrack;
return pNextTrack;
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/sources/soundsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ QString SoundSource::getTypeFromFile(const QFileInfo& fileInfo) {
// type, using the generic type application/octet-stream as a fallback.
// This might also occur for missing files as seen on Qt 5.12.
if (!mimeType.isValid() || mimeType.isDefault()) {
qInfo() << "Unable to detect MIME type from file" << fileInfo.filePath();
if (fileInfo.exists()) {
qInfo() << "Unable to detect MIME type from file" << fileInfo.filePath();
} else {
qInfo() << "Unable to detect MIME type from not existing file" << fileInfo.filePath();
}
mimeType = QMimeDatabase().mimeTypeForFile(
fileInfo, QMimeDatabase::MatchExtension);
if (!mimeType.isValid() || mimeType.isDefault()) {
Expand Down
7 changes: 7 additions & 0 deletions src/sources/soundsourceproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,13 @@ SoundSourceProxy::UpdateTrackFromSourceResult SoundSourceProxy::updateTrackFromS
mixxx::TrackMetadata trackMetadata =
m_pTrack->getMetadata(&sourceSyncStatus);

if (sourceSyncStatus == mixxx::TrackRecord::SourceSyncStatus::Undefined) {
kLogger.warning()
<< "Unable to update track from missing or inaccessible file"
<< getUrl().toString();
return UpdateTrackFromSourceResult::NotUpdated;
}

// Save for later to replace the unreliable and imprecise audio
// properties imported from file tags (see below).
const auto preciseStreamInfo = trackMetadata.getStreamInfo();
Expand Down
6 changes: 6 additions & 0 deletions src/track/trackrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ TrackRecord::SourceSyncStatus TrackRecord::checkSourceSyncStatus(
// 37 don't have a synchronization time stamp.
return SourceSyncStatus::Unknown;
}
if (!fileInfo.exists()) {
kLogger.warning()
<< "Failed to obtain synchronization time stamp for not existing file"
<< mixxx::FileInfo(fileInfo);
return SourceSyncStatus::Undefined;
}
const QDateTime fileSourceSynchronizedAt =
MetadataSource::getFileSynchronizedAt(fileInfo.toQFile());
if (!fileSourceSynchronizedAt.isValid()) {
Expand Down

0 comments on commit 400e8ed

Please sign in to comment.