Device change watchdog timer no longer freezes main thread while CddaSongLoader is active.
This commit is contained in:
parent
2dd566653f
commit
d2240ec0ae
|
@ -77,6 +77,10 @@ void CddaDevice::SongsLoaded(const SongList& songs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CddaDevice::CheckDiscChanged() {
|
void CddaDevice::CheckDiscChanged() {
|
||||||
|
// do nothing if loader is currently reading;
|
||||||
|
// we'd just block until it's finished
|
||||||
|
if (cdda_song_loader_.IsActive()) return;
|
||||||
|
|
||||||
Q_ASSERT(cdio_);
|
Q_ASSERT(cdio_);
|
||||||
if (cdio_get_media_changed(cdio_) == 1) {
|
if (cdio_get_media_changed(cdio_) == 1) {
|
||||||
emit DiscChanged();
|
emit DiscChanged();
|
||||||
|
|
|
@ -50,9 +50,11 @@ QUrl CddaSongLoader::GetUrlFromTrack(int track_number) const {
|
||||||
return CddaDevice::TrackStrToUrl(track);
|
return CddaDevice::TrackStrToUrl(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CddaSongLoader::IsActive() const { return loading_future_.isRunning(); }
|
||||||
|
|
||||||
void CddaSongLoader::LoadSongs() {
|
void CddaSongLoader::LoadSongs() {
|
||||||
// only dispatch a new thread for loading tracks if not already running.
|
// only dispatch a new thread for loading tracks if not already running.
|
||||||
if (!loading_future_.isRunning()) {
|
if (!IsActive()) {
|
||||||
loading_future_ =
|
loading_future_ =
|
||||||
QtConcurrent::run(this, &CddaSongLoader::LoadSongsFromCdda);
|
QtConcurrent::run(this, &CddaSongLoader::LoadSongsFromCdda);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ class CddaSongLoader : public QObject {
|
||||||
// Signals declared below will be emitted anytime new information will be
|
// Signals declared below will be emitted anytime new information will be
|
||||||
// available.
|
// available.
|
||||||
void LoadSongs();
|
void LoadSongs();
|
||||||
|
bool IsActive() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SongsLoaded(const SongList& songs);
|
void SongsLoaded(const SongList& songs);
|
||||||
|
|
|
@ -47,8 +47,8 @@ class RipCDDialog : public QDialog {
|
||||||
~RipCDDialog();
|
~RipCDDialog();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent* event);
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ClickedRipButton();
|
void ClickedRipButton();
|
||||||
|
|
Loading…
Reference in New Issue