mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-22 15:58:45 +01:00
CddaDevice: Preventing double read on disc change.
This commit is contained in:
parent
62b5a0e77b
commit
2936578fa4
@ -34,6 +34,8 @@ CddaDevice::CddaDevice(const QUrl& url, DeviceLister* lister,
|
|||||||
cdda_song_loader_(url) {
|
cdda_song_loader_(url) {
|
||||||
connect(&cdda_song_loader_, SIGNAL(SongsUpdated(SongList)), this,
|
connect(&cdda_song_loader_, SIGNAL(SongsUpdated(SongList)), this,
|
||||||
SLOT(SongsLoaded(SongList)));
|
SLOT(SongsLoaded(SongList)));
|
||||||
|
connect(&cdda_song_loader_, SIGNAL(Finished()), this,
|
||||||
|
SLOT(SongsLoadingFinished()));
|
||||||
connect(this, SIGNAL(SongsDiscovered(SongList)), model_,
|
connect(this, SIGNAL(SongsDiscovered(SongList)), model_,
|
||||||
SLOT(SongsDiscovered(SongList)));
|
SLOT(SongsDiscovered(SongList)));
|
||||||
connect(&disc_changed_timer_, SIGNAL(timeout()), SLOT(CheckDiscChanged()));
|
connect(&disc_changed_timer_, SIGNAL(timeout()), SLOT(CheckDiscChanged()));
|
||||||
@ -69,7 +71,10 @@ void CddaDevice::WatchForDiscChanges(bool watch) {
|
|||||||
disc_changed_timer_.stop();
|
disc_changed_timer_.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CddaDevice::ForceLoadSongs() { cdda_song_loader_.LoadSongs(); }
|
void CddaDevice::ForceLoadSongs() {
|
||||||
|
cdda_song_loader_.LoadSongs();
|
||||||
|
disc_changed_timer_.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void CddaDevice::LoadSongs() {
|
void CddaDevice::LoadSongs() {
|
||||||
SongList songs = cdda_song_loader_.cached_tracks();
|
SongList songs = cdda_song_loader_.cached_tracks();
|
||||||
@ -80,8 +85,20 @@ void CddaDevice::SongsLoaded(const SongList& songs) {
|
|||||||
model_->Reset();
|
model_->Reset();
|
||||||
song_count_ = songs.size();
|
song_count_ = songs.size();
|
||||||
emit SongsDiscovered(songs);
|
emit SongsDiscovered(songs);
|
||||||
|
// When a disc is inserted, cdio_get_media_changed will
|
||||||
|
// return true for two times with a bit of delay in between
|
||||||
|
// (at least on linux).
|
||||||
|
// We clear cdio_get_media_changed after songs are
|
||||||
|
// loaded, so we don't potentially re-read the same disc.terminal
|
||||||
|
// There's a slight chance that this hides an actual
|
||||||
|
// media change, but this should be rare enough to not
|
||||||
|
// be a problem in practice and is easily rectified
|
||||||
|
// by user cycling the disc once more.
|
||||||
|
cdio_get_media_changed(cdio_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CddaDevice::SongsLoadingFinished() { disc_changed_timer_.start(); }
|
||||||
|
|
||||||
void CddaDevice::CheckDiscChanged() {
|
void CddaDevice::CheckDiscChanged() {
|
||||||
if (!cdio_) return; // do nothing if not initialized
|
if (!cdio_) return; // do nothing if not initialized
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class CddaDevice : public ConnectedDevice {
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SongsLoaded(const SongList& songs);
|
void SongsLoaded(const SongList& songs);
|
||||||
|
void SongsLoadingFinished();
|
||||||
void CheckDiscChanged();
|
void CheckDiscChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user