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.
This commit is contained in:
parent
528b7c3f5e
commit
c6714f1755
@ -238,6 +238,7 @@ static void do_play(void)
|
|||||||
song */
|
song */
|
||||||
int nextChunk = 0;
|
int nextChunk = 0;
|
||||||
static const char silence[CHUNK_SIZE];
|
static const char silence[CHUNK_SIZE];
|
||||||
|
struct audio_format play_audio_format;
|
||||||
double sizeToTime = 0.0;
|
double sizeToTime = 0.0;
|
||||||
|
|
||||||
ob_clear();
|
ob_clear();
|
||||||
@ -303,6 +304,7 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
pc.totalTime = dc.totalTime;
|
pc.totalTime = dc.totalTime;
|
||||||
pc.audio_format = dc.audioFormat;
|
pc.audio_format = dc.audioFormat;
|
||||||
|
play_audio_format = ob.audioFormat;
|
||||||
sizeToTime = audioFormatSizeToTime(&ob.audioFormat);
|
sizeToTime = audioFormatSizeToTime(&ob.audioFormat);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -397,7 +399,7 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* play the current chunk */
|
/* play the current chunk */
|
||||||
if (playChunk(beginChunk, &(ob.audioFormat),
|
if (playChunk(beginChunk, &play_audio_format,
|
||||||
sizeToTime) < 0)
|
sizeToTime) < 0)
|
||||||
break;
|
break;
|
||||||
ob_shift();
|
ob_shift();
|
||||||
@ -430,7 +432,7 @@ static void do_play(void)
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
size_t frame_size =
|
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
|
/* this formula ensures that we don't send
|
||||||
partial frames */
|
partial frames */
|
||||||
unsigned num_frames = CHUNK_SIZE / frame_size;
|
unsigned num_frames = CHUNK_SIZE / frame_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user