diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:09 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-08-30 18:44:35 -0700 |
commit | 43fc7747130702b7a2a02547f90bbcbddf42d32d (patch) | |
tree | df94657313ecadef7f02814c460697ca47951f76 /src | |
parent | 29eba419627437fb6f20714bb553d39a58305c5e (diff) | |
download | mpd-43fc7747130702b7a2a02547f90bbcbddf42d32d.tar.gz mpd-43fc7747130702b7a2a02547f90bbcbddf42d32d.tar.xz mpd-43fc7747130702b7a2a02547f90bbcbddf42d32d.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/audio_format.h | 5 | ||||
-rw-r--r-- | src/outputBuffer_xfade.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/audio_format.h b/src/audio_format.h index ba22b3bf6..a6e97e046 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/outputBuffer_xfade.h b/src/outputBuffer_xfade.h index 50fb062ce..70e490c65 100644 --- a/src/outputBuffer_xfade.h +++ b/src/outputBuffer_xfade.h @@ -29,7 +29,7 @@ static size_t calculate_xfade_chunks(struct rbvec vec[2]) 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 * (xfade_time + 0.5); assert(chunks); |