decoder_control: merge next_song and current_song

These two variables are redundant, we need only one of them.
This commit is contained in:
Max Kellermann 2009-11-03 20:02:19 +01:00
parent bfa7da943c
commit 89893faa19
5 changed files with 16 additions and 16 deletions

View File

@ -86,7 +86,7 @@ char *decoder_get_uri(G_GNUC_UNUSED struct decoder *decoder)
assert(dc->pipe != NULL); assert(dc->pipe != NULL);
return song_get_uri(dc->current_song); return song_get_uri(dc->song);
} }
enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder) enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)

View File

@ -89,7 +89,7 @@ dc_start(struct decoder_control *dc, struct song *song)
assert(dc->pipe != NULL); assert(dc->pipe != NULL);
assert(song != NULL); assert(song != NULL);
dc->next_song = song; dc->song = song;
dc_command(dc, DECODE_COMMAND_START); dc_command(dc, DECODE_COMMAND_START);
} }

View File

@ -72,8 +72,13 @@ struct decoder_control {
/** the format being sent to the music pipe */ /** the format being sent to the music pipe */
struct audio_format out_audio_format; struct audio_format out_audio_format;
const struct song *current_song; /**
const struct song *next_song; * The song currently being decoded. This attribute is set by
* the player thread, when it sends the #DECODE_COMMAND_START
* command.
*/
const struct song *song;
float total_time; float total_time;
/** the #music_chunk allocator */ /** the #music_chunk allocator */
@ -198,7 +203,7 @@ decoder_current_song(const struct decoder_control *dc)
case DECODE_STATE_START: case DECODE_STATE_START:
case DECODE_STATE_DECODE: case DECODE_STATE_DECODE:
return dc->current_song; return dc->song;
} }
assert(false); assert(false);

View File

@ -268,9 +268,11 @@ decoder_run_song(struct decoder_control *dc,
static void static void
decoder_run(struct decoder_control *dc) decoder_run(struct decoder_control *dc)
{ {
const struct song *song = dc->next_song; const struct song *song = dc->song;
char *uri; char *uri;
assert(song != NULL);
if (song_is_file(song)) if (song_is_file(song))
uri = map_song_fs(song); uri = map_song_fs(song);
else else
@ -281,7 +283,6 @@ decoder_run(struct decoder_control *dc)
return; return;
} }
dc->current_song = dc->next_song; /* NEED LOCK */
decoder_run_song(dc, song, uri); decoder_run_song(dc, song, uri);
g_free(uri); g_free(uri);

View File

@ -160,10 +160,8 @@ player_wait_for_decoder(struct player *player)
struct decoder_control *dc = player->dc; struct decoder_control *dc = player->dc;
if (decoder_lock_has_failed(dc)) { if (decoder_lock_has_failed(dc)) {
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
player_lock(); player_lock();
pc.errored_song = dc->next_song; pc.errored_song = dc->song;
pc.error = PLAYER_ERROR_FILE; pc.error = PLAYER_ERROR_FILE;
pc.next_song = NULL; pc.next_song = NULL;
player_unlock(); player_unlock();
@ -210,11 +208,9 @@ player_check_decoder_startup(struct player *player)
if (decoder_has_failed(dc)) { if (decoder_has_failed(dc)) {
/* the decoder failed */ /* the decoder failed */
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
decoder_unlock(dc); decoder_unlock(dc);
pc.errored_song = dc->next_song; pc.errored_song = dc->song;
pc.error = PLAYER_ERROR_FILE; pc.error = PLAYER_ERROR_FILE;
return false; return false;
@ -237,12 +233,11 @@ player_check_decoder_startup(struct player *player)
if (!player->paused && if (!player->paused &&
!audio_output_all_open(&dc->out_audio_format, !audio_output_all_open(&dc->out_audio_format,
player_buffer)) { player_buffer)) {
char *uri = song_get_uri(dc->next_song); char *uri = song_get_uri(dc->song);
g_warning("problems opening audio device " g_warning("problems opening audio device "
"while playing \"%s\"", uri); "while playing \"%s\"", uri);
g_free(uri); g_free(uri);
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
pc.error = PLAYER_ERROR_AUDIO; pc.error = PLAYER_ERROR_AUDIO;
/* pause: the user may resume playback as soon /* pause: the user may resume playback as soon
@ -433,7 +428,6 @@ static void player_process_command(struct player *player)
} else { } else {
/* the audio device has failed - rollback to /* the audio device has failed - rollback to
pause mode */ pause mode */
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
pc.error = PLAYER_ERROR_AUDIO; pc.error = PLAYER_ERROR_AUDIO;
player->paused = true; player->paused = true;