diff options
author | Max Kellermann <max@duempel.org> | 2008-10-29 17:29:30 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-29 17:29:30 +0100 |
commit | c6714f1755582e590b19a4dc95bebc2a9328cc2b (patch) | |
tree | 42871a03455c80a894e4d309b8a3a086bec87b32 | |
parent | 528b7c3f5e7afc155058eeba631aa93ba9f42b0c (diff) | |
download | mpd-c6714f1755582e590b19a4dc95bebc2a9328cc2b.tar.gz mpd-c6714f1755582e590b19a4dc95bebc2a9328cc2b.tar.xz mpd-c6714f1755582e590b19a4dc95bebc2a9328cc2b.zip |
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.
-rw-r--r-- | src/player_thread.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; |