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.
This commit is contained in:
Max Kellermann 2011-10-08 15:03:43 +02:00
parent 3057d19cdf
commit accd262561

View File

@ -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.
*/