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