decoder_control: merge next_song and current_song
These two variables are redundant, we need only one of them.
This commit is contained in:
parent
bfa7da943c
commit
89893faa19
@ -86,7 +86,7 @@ char *decoder_get_uri(G_GNUC_UNUSED struct decoder *decoder)
|
||||
|
||||
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)
|
||||
|
@ -89,7 +89,7 @@ dc_start(struct decoder_control *dc, struct song *song)
|
||||
assert(dc->pipe != NULL);
|
||||
assert(song != NULL);
|
||||
|
||||
dc->next_song = song;
|
||||
dc->song = song;
|
||||
dc_command(dc, DECODE_COMMAND_START);
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,13 @@ struct decoder_control {
|
||||
/** the format being sent to the music pipe */
|
||||
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;
|
||||
|
||||
/** the #music_chunk allocator */
|
||||
@ -198,7 +203,7 @@ decoder_current_song(const struct decoder_control *dc)
|
||||
|
||||
case DECODE_STATE_START:
|
||||
case DECODE_STATE_DECODE:
|
||||
return dc->current_song;
|
||||
return dc->song;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
|
@ -268,9 +268,11 @@ decoder_run_song(struct decoder_control *dc,
|
||||
static void
|
||||
decoder_run(struct decoder_control *dc)
|
||||
{
|
||||
const struct song *song = dc->next_song;
|
||||
const struct song *song = dc->song;
|
||||
char *uri;
|
||||
|
||||
assert(song != NULL);
|
||||
|
||||
if (song_is_file(song))
|
||||
uri = map_song_fs(song);
|
||||
else
|
||||
@ -281,7 +283,6 @@ decoder_run(struct decoder_control *dc)
|
||||
return;
|
||||
}
|
||||
|
||||
dc->current_song = dc->next_song; /* NEED LOCK */
|
||||
decoder_run_song(dc, song, uri);
|
||||
g_free(uri);
|
||||
|
||||
|
@ -160,10 +160,8 @@ player_wait_for_decoder(struct player *player)
|
||||
struct decoder_control *dc = player->dc;
|
||||
|
||||
if (decoder_lock_has_failed(dc)) {
|
||||
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
|
||||
|
||||
player_lock();
|
||||
pc.errored_song = dc->next_song;
|
||||
pc.errored_song = dc->song;
|
||||
pc.error = PLAYER_ERROR_FILE;
|
||||
pc.next_song = NULL;
|
||||
player_unlock();
|
||||
@ -210,11 +208,9 @@ player_check_decoder_startup(struct player *player)
|
||||
|
||||
if (decoder_has_failed(dc)) {
|
||||
/* the decoder failed */
|
||||
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
|
||||
|
||||
decoder_unlock(dc);
|
||||
|
||||
pc.errored_song = dc->next_song;
|
||||
pc.errored_song = dc->song;
|
||||
pc.error = PLAYER_ERROR_FILE;
|
||||
|
||||
return false;
|
||||
@ -237,12 +233,11 @@ player_check_decoder_startup(struct player *player)
|
||||
if (!player->paused &&
|
||||
!audio_output_all_open(&dc->out_audio_format,
|
||||
player_buffer)) {
|
||||
char *uri = song_get_uri(dc->next_song);
|
||||
char *uri = song_get_uri(dc->song);
|
||||
g_warning("problems opening audio device "
|
||||
"while playing \"%s\"", uri);
|
||||
g_free(uri);
|
||||
|
||||
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
|
||||
pc.error = PLAYER_ERROR_AUDIO;
|
||||
|
||||
/* pause: the user may resume playback as soon
|
||||
@ -433,7 +428,6 @@ static void player_process_command(struct player *player)
|
||||
} else {
|
||||
/* the audio device has failed - rollback to
|
||||
pause mode */
|
||||
assert(dc->next_song == NULL || dc->next_song->uri != NULL);
|
||||
pc.error = PLAYER_ERROR_AUDIO;
|
||||
|
||||
player->paused = true;
|
||||
|
Loading…
Reference in New Issue
Block a user