added inline function audio_format_time_to_size()

Make the code more readable by hiding big formulas in an inline
function with a nice name.
This commit is contained in:
Max Kellermann 2008-08-26 08:27:09 +02:00
parent 0aedf7dd5a
commit 2650b9eb31
2 changed files with 6 additions and 1 deletions

View File

@ -27,6 +27,11 @@ typedef struct _AudioFormat {
volatile mpd_sint8 bits;
} AudioFormat;
static inline double audio_format_time_to_size(const AudioFormat * af)
{
return af->sampleRate * af->bits * af->channels / 8.0;
}
static inline double audioFormatSizeToTime(const AudioFormat * af)
{
return 8.0 / af->bits / af->channels / af->sampleRate;

View File

@ -78,7 +78,7 @@ static unsigned calculateCrossFadeChunks(AudioFormat * af,
assert(af->channels > 0);
assert(af->sampleRate > 0);
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
chunks = audio_format_time_to_size(af) / CHUNK_SIZE;
chunks = (chunks * pc.crossFade + 0.5);
if (chunks > max_chunks)