static struct mpd_connection *mpdc;
static bool is_stream;
static int song_id;
+static int abnormal_stop;
int mpd_check_for_error(void)
{
{
struct mpd_status *status;
enum mpd_state state;
- int abnormal_stop;
status = mpd_run_status(mpdc);
if (status == NULL)
case MPD_STATE_PLAY:
log_info("Playback started\n");
is_stream = is_stream_uri(status);
+ abnormal_stop = false;
break;
case MPD_STATE_PAUSE:
log_info("Playback paused\n"); /* No action */
+ abnormal_stop = false;
break;
case MPD_STATE_STOP:
log_info("Playback stopped\n");
abnormal_stop = mpd_check_abnormal_stop(status);
- if (abnormal_stop) {
- log_warn("Auto restart stream after error...\n");
- (void) mpd_replay(song_id);
- }
break;
default:
log_warn("Playback unknown state\n");
(void) mpdstream_monitor_status();
+ if (abnormal_stop) {
+ log_warn("Auto restart stream after error...\n");
+ (void) mpd_replay(song_id);
+ }
+
/*
* Configure idle event(s):
* MPD_IDLE_PLAYER: state has changed: play, stop, pause, seek, etc
is_stream = false;
song_id = -1;
last_state = -1;
+ abnormal_stop = false;
log_debug("Waiting for events...\n");