Add better error handling between engine and player
This commit is contained in:
parent
6105b99a7f
commit
faee1977fe
|
@ -71,6 +71,7 @@
|
|||
#include "equalizer/equalizer.h"
|
||||
#include "analyzer/analyzercontainer.h"
|
||||
#include "settings/backendsettingspage.h"
|
||||
#include "settings/playbacksettingspage.h"
|
||||
#include "settings/behavioursettingspage.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "internet/internetservices.h"
|
||||
|
@ -86,6 +87,8 @@ Player::Player(Application *app, QObject *parent)
|
|||
nb_errors_received_(0),
|
||||
volume_before_mute_(50),
|
||||
last_pressed_previous_(QDateTime::currentDateTime()),
|
||||
continue_on_error_(false),
|
||||
greyout_(true),
|
||||
menu_previousmode_(PreviousBehaviour_DontRestart),
|
||||
seek_step_sec_(10) {
|
||||
|
||||
|
@ -177,6 +180,7 @@ void Player::Init() {
|
|||
analyzer_->SetEngine(engine_.get());
|
||||
|
||||
connect(engine_.get(), SIGNAL(Error(QString)), SIGNAL(Error(QString)));
|
||||
connect(engine_.get(), SIGNAL(FatalError()), SLOT(FatalError()));
|
||||
connect(engine_.get(), SIGNAL(ValidSongRequested(QUrl)), SLOT(ValidSongRequested(QUrl)));
|
||||
connect(engine_.get(), SIGNAL(InvalidSongRequested(QUrl)), SLOT(InvalidSongRequested(QUrl)));
|
||||
connect(engine_.get(), SIGNAL(StateChanged(Engine::State)), SLOT(EngineStateChanged(Engine::State)));
|
||||
|
@ -206,6 +210,8 @@ void Player::ReloadSettings() {
|
|||
QSettings s;
|
||||
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
continue_on_error_ = s.value("continue_on_error", false).toBool();
|
||||
greyout_ = s.value("greyout_songs_play", true).toBool();
|
||||
menu_previousmode_ = PreviousBehaviour(s.value("menu_previousmode", PreviousBehaviour_DontRestart).toInt());
|
||||
s.endGroup();
|
||||
|
||||
|
@ -703,29 +709,25 @@ void Player::TrackAboutToEnd() {
|
|||
|
||||
void Player::IntroPointReached() { NextInternal(Engine::Intro); }
|
||||
|
||||
void Player::FatalError() {
|
||||
nb_errors_received_ = 0;
|
||||
Stop();
|
||||
}
|
||||
|
||||
void Player::ValidSongRequested(const QUrl &url) {
|
||||
emit SongChangeRequestProcessed(url, true);
|
||||
}
|
||||
|
||||
void Player::InvalidSongRequested(const QUrl &url) {
|
||||
|
||||
// First send the notification to others...
|
||||
emit SongChangeRequestProcessed(url, false);
|
||||
if (greyout_) emit SongChangeRequestProcessed(url, false);
|
||||
|
||||
// TODO: Continue to the next item in the playlist based on the error type.
|
||||
// When our listeners have completed their processing of the current item we can change the current item by skipping to the next song
|
||||
// NextItem(Engine::Auto);
|
||||
|
||||
// Manual track changes override "Repeat track"
|
||||
Playlist *active_playlist = app_->playlist_manager()->active();
|
||||
const bool ignore_repeat_track = Engine::Auto & Engine::Manual;
|
||||
int i = active_playlist->next_row(ignore_repeat_track);
|
||||
if (i == -1) {
|
||||
app_->playlist_manager()->active()->set_current_row(i);
|
||||
emit PlaylistFinished();
|
||||
if (!continue_on_error_) {
|
||||
FatalError();
|
||||
return;
|
||||
}
|
||||
nb_errors_received_ = 0;
|
||||
Stop();
|
||||
|
||||
NextItem(Engine::Auto);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ class Player : public PlayerInterface {
|
|||
|
||||
void NextInternal(Engine::TrackChangeFlags);
|
||||
|
||||
void FatalError();
|
||||
void ValidSongRequested(const QUrl&);
|
||||
void InvalidSongRequested(const QUrl&);
|
||||
|
||||
|
@ -219,10 +220,11 @@ class Player : public PlayerInterface {
|
|||
QMap<QString, UrlHandler*> url_handlers_;
|
||||
|
||||
QUrl loading_async_;
|
||||
|
||||
int volume_before_mute_;
|
||||
|
||||
QDateTime last_pressed_previous_;
|
||||
|
||||
bool continue_on_error_;
|
||||
bool greyout_;
|
||||
PreviousBehaviour menu_previousmode_;
|
||||
int seek_step_sec_;
|
||||
|
||||
|
|
|
@ -137,13 +137,15 @@ signals:
|
|||
|
||||
void FadeoutFinishedSignal();
|
||||
|
||||
void StatusText(const QString&);
|
||||
void Error(const QString&);
|
||||
void StatusText(const QString &text);
|
||||
void Error(const QString &text);
|
||||
|
||||
// Emitted when there was a fatal error
|
||||
void FatalError();
|
||||
// Emitted when Engine was unable to play a song with the given QUrl.
|
||||
void InvalidSongRequested(const QUrl&);
|
||||
void InvalidSongRequested(const QUrl &url);
|
||||
// Emitted when Engine successfully started playing a song with the given QUrl.
|
||||
void ValidSongRequested(const QUrl&);
|
||||
void ValidSongRequested(const QUrl &url);
|
||||
|
||||
void MetaData(const Engine::SimpleMetaBundle&);
|
||||
|
||||
|
|
Loading…
Reference in New Issue