From c6714f1755582e590b19a4dc95bebc2a9328cc2b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 29 Oct 2008 17:29:30 +0100 Subject: player: added variable "play_audio_format" The local variable "play_audio_format" is updated every time the player starts playing a new song. This way, we always know exactly which audio format is current. The old code broke when a new song had a different format: ob.audio_format is the format of the next song, not of the current one - using this caused breakage for the software volume control. --- src/player_thread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/player_thread.c b/src/player_thread.c index c06be3d82..b8bc92af8 100644 --- a/src/player_thread.c +++ b/src/player_thread.c @@ -238,6 +238,7 @@ static void do_play(void) song */ int nextChunk = 0; static const char silence[CHUNK_SIZE]; + struct audio_format play_audio_format; double sizeToTime = 0.0; ob_clear(); @@ -303,6 +304,7 @@ static void do_play(void) } pc.totalTime = dc.totalTime; pc.audio_format = dc.audioFormat; + play_audio_format = ob.audioFormat; sizeToTime = audioFormatSizeToTime(&ob.audioFormat); } else { @@ -397,7 +399,7 @@ static void do_play(void) } /* play the current chunk */ - if (playChunk(beginChunk, &(ob.audioFormat), + if (playChunk(beginChunk, &play_audio_format, sizeToTime) < 0) break; ob_shift(); @@ -430,7 +432,7 @@ static void do_play(void) break; } else { size_t frame_size = - audio_format_frame_size(&pc.audio_format); + audio_format_frame_size(&play_audio_format); /* this formula ensures that we don't send partial frames */ unsigned num_frames = CHUNK_SIZE / frame_size; -- cgit v1.2.3