Make the code more readable by hiding big formulas in an inline function with a nice name. ---
src/audio_format.h | 5 +++++ src/decode.c | 2 +- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/audio_format.h b/src/audio_format.h index ba22b3b..a6e97e0 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -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; diff --git a/src/decode.c b/src/decode.c index da649ec..f0c13f7 100644 --- a/src/decode.c +++ b/src/decode.c @@ -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) ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team