You need to sign in or sign up before continuing.
Commit 51e90440 authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

don't calculate bytes per sample within the loop

AudioFormat.bits is volatile, and to read it, 3 pointers had to be deferenced. Calculate this value once. This speeds up this function by 5%. git-svn-id: https://svn.musicpd.org/mpd/trunk@7325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 96eb0119
...@@ -216,6 +216,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, ...@@ -216,6 +216,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
FLAC__uint16 u16; FLAC__uint16 u16;
unsigned char *uc; unsigned char *uc;
unsigned int c_samp, c_chan; unsigned int c_samp, c_chan;
const unsigned int bytes_per_sample = (data->dc->audioFormat.bits / 8);
unsigned int i; unsigned int i;
float timeChange; float timeChange;
FLAC__uint64 newPosition = 0; FLAC__uint64 newPosition = 0;
...@@ -241,7 +242,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, ...@@ -241,7 +242,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
c_chan++) { c_chan++) {
u16 = buf[c_chan][c_samp]; u16 = buf[c_chan][c_samp];
uc = (unsigned char *)&u16; uc = (unsigned char *)&u16;
for (i = 0; i < (unsigned)(data->dc->audioFormat.bits / 8); i++) { for (i = 0; i < bytes_per_sample; i++) {
if (data->chunk_length >= FLAC_CHUNK_SIZE) { if (data->chunk_length >= FLAC_CHUNK_SIZE) {
if (flacSendChunk(data) < 0) { if (flacSendChunk(data) < 0) {
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment