player_control: rename player_error enum values

This commit is contained in:
Max Kellermann 2012-08-08 22:22:00 +02:00
parent fa84ed412d
commit d35d2b269f
4 changed files with 24 additions and 16 deletions

View File

@ -47,7 +47,7 @@ pc_new(unsigned buffer_chunks, unsigned int buffered_before_play)
pc->cond = g_cond_new(); pc->cond = g_cond_new();
pc->command = PLAYER_COMMAND_NONE; pc->command = PLAYER_COMMAND_NONE;
pc->error = PLAYER_ERROR_NOERROR; pc->error = PLAYER_ERROR_NONE;
pc->state = PLAYER_STATE_STOP; pc->state = PLAYER_STATE_STOP;
pc->cross_fade_seconds = 0; pc->cross_fade_seconds = 0;
pc->mixramp_db = 0; pc->mixramp_db = 0;
@ -80,7 +80,7 @@ void
pc_song_deleted(struct player_control *pc, const struct song *song) pc_song_deleted(struct player_control *pc, const struct song *song)
{ {
if (pc->errored_song == song) { if (pc->errored_song == song) {
pc->error = PLAYER_ERROR_NOERROR; pc->error = PLAYER_ERROR_NONE;
pc->errored_song = NULL; pc->errored_song = NULL;
} }
} }
@ -232,7 +232,7 @@ void
pc_clear_error(struct player_control *pc) pc_clear_error(struct player_control *pc)
{ {
player_lock(pc); player_lock(pc);
pc->error = PLAYER_ERROR_NOERROR; pc->error = PLAYER_ERROR_NONE;
pc->errored_song = NULL; pc->errored_song = NULL;
player_unlock(pc); player_unlock(pc);
} }
@ -250,16 +250,16 @@ pc_get_error_message(struct player_control *pc)
char *uri; char *uri;
switch (pc->error) { switch (pc->error) {
case PLAYER_ERROR_NOERROR: case PLAYER_ERROR_NONE:
return NULL; return NULL;
case PLAYER_ERROR_FILE: case PLAYER_ERROR_DECODER:
uri = pc_errored_song_uri(pc); uri = pc_errored_song_uri(pc);
error = g_strdup_printf("problems decoding \"%s\"", uri); error = g_strdup_printf("problems decoding \"%s\"", uri);
g_free(uri); g_free(uri);
return error; return error;
case PLAYER_ERROR_AUDIO: case PLAYER_ERROR_OUTPUT:
return g_strdup("problems opening audio device"); return g_strdup("problems opening audio device");
} }

View File

@ -66,9 +66,17 @@ enum player_command {
}; };
enum player_error { enum player_error {
PLAYER_ERROR_NOERROR = 0, PLAYER_ERROR_NONE = 0,
PLAYER_ERROR_FILE,
PLAYER_ERROR_AUDIO, /**
* The decoder has failed to decode the song.
*/
PLAYER_ERROR_DECODER,
/**
* The audio output has failed.
*/
PLAYER_ERROR_OUTPUT,
}; };
struct player_status { struct player_status {

View File

@ -238,7 +238,7 @@ player_wait_for_decoder(struct player *player)
if (decoder_lock_has_failed(dc)) { if (decoder_lock_has_failed(dc)) {
player_lock(pc); player_lock(pc);
pc->errored_song = dc->song; pc->errored_song = dc->song;
pc->error = PLAYER_ERROR_FILE; pc->error = PLAYER_ERROR_DECODER;
pc->next_song = NULL; pc->next_song = NULL;
player_unlock(pc); player_unlock(pc);
@ -322,7 +322,7 @@ player_open_output(struct player *player)
player->paused = true; player->paused = true;
player_lock(pc); player_lock(pc);
pc->error = PLAYER_ERROR_AUDIO; pc->error = PLAYER_ERROR_OUTPUT;
pc->state = PLAYER_STATE_PAUSE; pc->state = PLAYER_STATE_PAUSE;
player_unlock(pc); player_unlock(pc);
@ -353,7 +353,7 @@ player_check_decoder_startup(struct player *player)
player_lock(pc); player_lock(pc);
pc->errored_song = dc->song; pc->errored_song = dc->song;
pc->error = PLAYER_ERROR_FILE; pc->error = PLAYER_ERROR_DECODER;
player_unlock(pc); player_unlock(pc);
return false; return false;
@ -789,7 +789,7 @@ play_next_chunk(struct player *player)
player_lock(pc); player_lock(pc);
pc->error = PLAYER_ERROR_AUDIO; pc->error = PLAYER_ERROR_OUTPUT;
/* pause: the user may resume playback as soon as an /* pause: the user may resume playback as soon as an
audio output becomes available */ audio output becomes available */

View File

@ -259,13 +259,13 @@ playlist_resume_playback(struct playlist *playlist, struct player_control *pc)
assert(pc_get_state(pc) == PLAYER_STATE_STOP); assert(pc_get_state(pc) == PLAYER_STATE_STOP);
error = pc_get_error(pc); error = pc_get_error(pc);
if (error == PLAYER_ERROR_NOERROR) if (error == PLAYER_ERROR_NONE)
playlist->error_count = 0; playlist->error_count = 0;
else else
++playlist->error_count; ++playlist->error_count;
if ((playlist->stop_on_error && error != PLAYER_ERROR_NOERROR) || if ((playlist->stop_on_error && error != PLAYER_ERROR_NONE) ||
error == PLAYER_ERROR_AUDIO || error == PLAYER_ERROR_OUTPUT ||
playlist->error_count >= queue_length(&playlist->queue)) playlist->error_count >= queue_length(&playlist->queue))
/* too many errors, or critical error: stop /* too many errors, or critical error: stop
playback */ playback */