diff options
Diffstat (limited to 'src/player_control.c')
-rw-r--r-- | src/player_control.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/player_control.c b/src/player_control.c index 1d5c76aa0..b8e9499f6 100644 --- a/src/player_control.c +++ b/src/player_control.c @@ -44,6 +44,13 @@ void pc_deinit(void) notify_deinit(&pc.notify); } +void +pc_song_deleted(const struct song *song) +{ + if (pc.errored_song == song) + pc.errored_song = NULL; +} + static void player_command(enum player_command cmd) { pc.command = cmd; @@ -141,12 +148,22 @@ enum player_error getPlayerError(void) return pc.error; } +static const char * +pc_errored_song_uri(void) +{ + char path_max_tmp[MPD_PATH_MAX]; + + if (pc.errored_song == NULL) + return "?"; + + return song_get_url(pc.errored_song, path_max_tmp); +} + char *getPlayerErrorStr(void) { /* static OK here, only one user in main task */ static char error[MPD_PATH_MAX + 64]; /* still too much */ static const size_t errorlen = sizeof(error); - char path_max_tmp[MPD_PATH_MAX]; *error = '\0'; /* likely */ switch (pc.error) { @@ -156,11 +173,11 @@ char *getPlayerErrorStr(void) case PLAYER_ERROR_FILENOTFOUND: snprintf(error, errorlen, "file \"%s\" does not exist or is inaccessible", - song_get_url(pc.errored_song, path_max_tmp)); + pc_errored_song_uri()); break; case PLAYER_ERROR_FILE: snprintf(error, errorlen, "problems decoding \"%s\"", - song_get_url(pc.errored_song, path_max_tmp)); + pc_errored_song_uri()); break; case PLAYER_ERROR_AUDIO: strcpy(error, "problems opening audio device"); @@ -170,7 +187,7 @@ char *getPlayerErrorStr(void) break; case PLAYER_ERROR_UNKTYPE: snprintf(error, errorlen, "file type of \"%s\" is unknown", - song_get_url(pc.errored_song, path_max_tmp)); + pc_errored_song_uri()); } return *error ? error : NULL; } |