CddaDevice now does not re-read song list if disc is not changed
This commit is contained in:
parent
50404a967b
commit
62b5a0e77b
|
@ -50,7 +50,7 @@ bool CddaDevice::Init() {
|
|||
if (!cdio_) {
|
||||
cdio_ = cdio_open(url_.path().toLocal8Bit().constData(), DRIVER_DEVICE);
|
||||
if (!cdio_) return false;
|
||||
LoadSongs();
|
||||
ForceLoadSongs();
|
||||
WatchForDiscChanges(true);
|
||||
}
|
||||
return true;
|
||||
|
@ -69,12 +69,17 @@ void CddaDevice::WatchForDiscChanges(bool watch) {
|
|||
disc_changed_timer_.stop();
|
||||
}
|
||||
|
||||
void CddaDevice::LoadSongs() { cdda_song_loader_.LoadSongs(); }
|
||||
void CddaDevice::ForceLoadSongs() { cdda_song_loader_.LoadSongs(); }
|
||||
|
||||
void CddaDevice::LoadSongs() {
|
||||
SongList songs = cdda_song_loader_.cached_tracks();
|
||||
SongsLoaded(songs);
|
||||
}
|
||||
|
||||
void CddaDevice::SongsLoaded(const SongList& songs) {
|
||||
model_->Reset();
|
||||
emit SongsDiscovered(songs);
|
||||
song_count_ = songs.size();
|
||||
emit SongsDiscovered(songs);
|
||||
}
|
||||
|
||||
void CddaDevice::CheckDiscChanged() {
|
||||
|
@ -89,6 +94,6 @@ void CddaDevice::CheckDiscChanged() {
|
|||
song_count_ = 0;
|
||||
SongList no_songs;
|
||||
SongsLoaded(no_songs);
|
||||
LoadSongs();
|
||||
ForceLoadSongs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ class CddaDevice : public ConnectedDevice {
|
|||
void CheckDiscChanged();
|
||||
|
||||
private:
|
||||
void ForceLoadSongs();
|
||||
|
||||
CdIo_t* cdio_;
|
||||
QTimer disc_changed_timer_;
|
||||
CddaSongLoader cdda_song_loader_;
|
||||
|
|
|
@ -382,3 +382,5 @@ void CddaSongLoader::SetDiscTracks(const SongList& songs, bool has_titles) {
|
|||
disc_.has_titles = has_titles;
|
||||
emit SongsUpdated(disc_.tracks);
|
||||
}
|
||||
|
||||
SongList CddaSongLoader::cached_tracks() const { return disc_.tracks; }
|
||||
|
|
|
@ -48,6 +48,10 @@ class CddaSongLoader : public QObject {
|
|||
void LoadSongs();
|
||||
bool IsActive() const;
|
||||
|
||||
// The list of currently cached tracks. This gets updated during calls
|
||||
// LoadSongs() is called. Not thread-safe.
|
||||
SongList cached_tracks() const;
|
||||
|
||||
signals:
|
||||
// Emitted whenever information about tracks were updated.
|
||||
// Guarantees consistency with previous updates, i.e., consumers can rely
|
||||
|
|
|
@ -94,8 +94,6 @@ RipCDDialog::RipCDDialog(DeviceManager* device_manager, QWidget* parent)
|
|||
false); // will be enabled by signal handlers if a valid device is
|
||||
// selected by user and a list of tracks is loaded
|
||||
|
||||
InitializeDevices();
|
||||
|
||||
connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
|
||||
connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
|
||||
connect(ui_->invert_selection_button, SIGNAL(clicked()),
|
||||
|
@ -152,6 +150,8 @@ RipCDDialog::RipCDDialog(DeviceManager* device_manager, QWidget* parent)
|
|||
SLOT(YearEditChanged(const QString&)));
|
||||
connect(ui_->discLineEdit, SIGNAL(textEdited(const QString&)),
|
||||
SLOT(DiscEditChanged(const QString&)));
|
||||
|
||||
InitializeDevices();
|
||||
}
|
||||
|
||||
RipCDDialog::~RipCDDialog() {}
|
||||
|
|
Loading…
Reference in New Issue