CollectionBackend/CollectionWatcher: add HasSongsWithMissingLoudnessCharacteristics
logic
Exactly identical to the "missing fingerprint" logic, just for the two new fields being added.
This commit is contained in:
parent
0ea81b13b9
commit
f905676b1c
@ -434,6 +434,29 @@ SongList CollectionBackend::SongsWithMissingFingerprint(const int id) {
|
||||
|
||||
}
|
||||
|
||||
SongList CollectionBackend::SongsWithMissingLoudnessCharacteristics(const int id) {
|
||||
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
SqlQuery q(db);
|
||||
q.prepare(QString("SELECT ROWID, " + Song::kColumnSpec + " FROM %1 WHERE directory_id = :directory_id AND unavailable = 0 AND (ebur128_integrated_loudness_lufs IS NULL OR ebur128_loudness_range_lu IS NULL)").arg(songs_table_));
|
||||
q.BindValue(":directory_id", id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return SongList();
|
||||
}
|
||||
|
||||
SongList ret;
|
||||
while (q.next()) {
|
||||
Song song(source_);
|
||||
song.InitFromQuery(q, true);
|
||||
ret << song;
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id) {
|
||||
|
||||
// Take a song and update its path
|
||||
|
@ -95,6 +95,7 @@ class CollectionBackendInterface : public QObject {
|
||||
|
||||
virtual SongList FindSongsInDirectory(const int id) = 0;
|
||||
virtual SongList SongsWithMissingFingerprint(const int id) = 0;
|
||||
virtual SongList SongsWithMissingLoudnessCharacteristics(const int id) = 0;
|
||||
virtual CollectionSubdirectoryList SubdirsInDirectory(const int id) = 0;
|
||||
virtual CollectionDirectoryList GetAllDirectories() = 0;
|
||||
virtual void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) = 0;
|
||||
@ -166,6 +167,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
|
||||
SongList FindSongsInDirectory(const int id) override;
|
||||
SongList SongsWithMissingFingerprint(const int id) override;
|
||||
SongList SongsWithMissingLoudnessCharacteristics(const int id) override;
|
||||
CollectionSubdirectoryList SubdirsInDirectory(const int id) override;
|
||||
CollectionDirectoryList GetAllDirectories() override;
|
||||
void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) override;
|
||||
|
@ -195,6 +195,7 @@ CollectionWatcher::ScanTransaction::ScanTransaction(CollectionWatcher *watcher,
|
||||
watcher_(watcher),
|
||||
cached_songs_dirty_(true),
|
||||
cached_songs_missing_fingerprint_dirty_(true),
|
||||
cached_songs_missing_loudness_characteristics_dirty_(true),
|
||||
known_subdirs_dirty_(true) {
|
||||
|
||||
QString description;
|
||||
@ -329,6 +330,21 @@ bool CollectionWatcher::ScanTransaction::HasSongsWithMissingFingerprint(const QS
|
||||
|
||||
}
|
||||
|
||||
bool CollectionWatcher::ScanTransaction::HasSongsWithMissingLoudnessCharacteristics(const QString &path) {
|
||||
|
||||
if (cached_songs_missing_loudness_characteristics_dirty_) {
|
||||
const SongList songs = watcher_->backend_->SongsWithMissingLoudnessCharacteristics(dir_);
|
||||
for (const Song &song : songs) {
|
||||
const QString p = song.url().toLocalFile().section('/', 0, -2);
|
||||
cached_songs_missing_loudness_characteristics_.insert(p, song);
|
||||
}
|
||||
cached_songs_missing_loudness_characteristics_dirty_ = false;
|
||||
}
|
||||
|
||||
return cached_songs_missing_loudness_characteristics_.contains(path);
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::ScanTransaction::SetKnownSubdirs(const CollectionSubdirectoryList &subdirs) {
|
||||
|
||||
known_subdirs_ = subdirs;
|
||||
|
@ -102,6 +102,7 @@ class CollectionWatcher : public QObject {
|
||||
|
||||
SongList FindSongsInSubdirectory(const QString &path);
|
||||
bool HasSongsWithMissingFingerprint(const QString &path);
|
||||
bool HasSongsWithMissingLoudnessCharacteristics(const QString &path);
|
||||
bool HasSeenSubdir(const QString &path);
|
||||
void SetKnownSubdirs(const CollectionSubdirectoryList &subdirs);
|
||||
CollectionSubdirectoryList GetImmediateSubdirs(const QString &path);
|
||||
@ -156,6 +157,9 @@ class CollectionWatcher : public QObject {
|
||||
QMultiMap<QString, Song> cached_songs_missing_fingerprint_;
|
||||
bool cached_songs_missing_fingerprint_dirty_;
|
||||
|
||||
QMultiMap<QString, Song> cached_songs_missing_loudness_characteristics_;
|
||||
bool cached_songs_missing_loudness_characteristics_dirty_;
|
||||
|
||||
CollectionSubdirectoryList known_subdirs_;
|
||||
bool known_subdirs_dirty_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user