aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-08 22:18:08 +0200
committerMax Kellermann <max@duempel.org>2012-08-08 22:54:49 +0200
commitd488d796f45a89eb20ef1f8dba6824706e1384d9 (patch)
tree5c46fe1ed382a6863566c0b1092938c45cfa9d93 /src/player_thread.c
parentf794b1e1aac61fd2e6f4758e0cebfcd8d15706be (diff)
downloadmpd-d488d796f45a89eb20ef1f8dba6824706e1384d9.tar.gz
mpd-d488d796f45a89eb20ef1f8dba6824706e1384d9.tar.xz
mpd-d488d796f45a89eb20ef1f8dba6824706e1384d9.zip
player_control: add GError attribute
Rewrite of the pc_get_error_message() function, now using a GError object instead of the complicated "errored_song" attribute.
Diffstat (limited to '')
-rw-r--r--src/player_thread.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index be314849b..486a8c96e 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -235,10 +235,10 @@ player_wait_for_decoder(struct player *player)
player->queued = false;
- if (decoder_lock_has_failed(dc)) {
+ GError *error = dc_lock_get_error(dc);
+ if (error != NULL) {
player_lock(pc);
- pc->errored_song = dc->song;
- pc->error_type = PLAYER_ERROR_DECODER;
+ pc_set_error(pc, PLAYER_ERROR_DECODER, error);
pc->next_song = NULL;
player_unlock(pc);
@@ -318,7 +318,6 @@ player_open_output(struct player *player)
return true;
} else {
g_warning("%s", error->message);
- g_error_free(error);
player->output_open = false;
@@ -327,7 +326,7 @@ player_open_output(struct player *player)
player->paused = true;
player_lock(pc);
- pc->error_type = PLAYER_ERROR_OUTPUT;
+ pc_set_error(pc, PLAYER_ERROR_OUTPUT, error);
pc->state = PLAYER_STATE_PAUSE;
player_unlock(pc);
@@ -352,13 +351,13 @@ player_check_decoder_startup(struct player *player)
decoder_lock(dc);
- if (decoder_has_failed(dc)) {
+ GError *error = dc_get_error(dc);
+ if (error != NULL) {
/* the decoder failed */
decoder_unlock(dc);
player_lock(pc);
- pc->errored_song = dc->song;
- pc->error_type = PLAYER_ERROR_DECODER;
+ pc_set_error(pc, PLAYER_ERROR_DECODER, error);
player_unlock(pc);
return false;
@@ -797,13 +796,12 @@ play_next_chunk(struct player *player)
if (!play_chunk(player->pc, player->song, chunk,
&player->play_audio_format, &error)) {
g_warning("%s", error->message);
- g_error_free(error);
music_buffer_return(player_buffer, chunk);
player_lock(pc);
- pc->error_type = PLAYER_ERROR_OUTPUT;
+ pc_set_error(pc, PLAYER_ERROR_OUTPUT, error);
/* pause: the user may resume playback as soon as an
audio output becomes available */