From accd26256185f4627583057ff3fafa39b5bc6387 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Oct 2011 15:03:43 +0200 Subject: audio_format: move code to sample_format_size() Cast to enum sample_format. Without the cast, it's just a plain integer, and gcc cannot know that a "case" statement is missing. --- src/audio_format.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/audio_format.h b/src/audio_format.h index 6e4f94b71..1e26974bc 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -237,12 +237,10 @@ audio_format_mask_apply(struct audio_format *af, assert(audio_format_valid(af)); } -/** - * Returns the size of each (mono) sample in bytes. - */ -static inline unsigned audio_format_sample_size(const struct audio_format *af) +static inline unsigned +sample_format_size(enum sample_format format) { - switch (af->format) { + switch (format) { case SAMPLE_FORMAT_S8: return 1; @@ -257,12 +255,21 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af) return 4; case SAMPLE_FORMAT_UNDEFINED: - break; + return 0; } + assert(false); return 0; } +/** + * Returns the size of each (mono) sample in bytes. + */ +static inline unsigned audio_format_sample_size(const struct audio_format *af) +{ + return sample_format_size((enum sample_format)af->format); +} + /** * Returns the size of each full frame in bytes. */ -- cgit v1.2.3