From be9e60d55ef191b5b50a9d1eb2337a6b1199c8d4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 21 Nov 2008 20:27:05 +0100 Subject: audio_format: added audio_format_valid() --- src/audio_format.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/audio_format.h') diff --git a/src/audio_format.h b/src/audio_format.h index d2f32b85..739fe6c1 100644 --- a/src/audio_format.h +++ b/src/audio_format.h @@ -40,6 +40,17 @@ static inline bool audio_format_defined(const struct audio_format *af) return af->sample_rate != 0; } +/** + * Returns false if the format is not valid for playback with MPD. + * This function performs some basic validity checks. + */ +static inline bool audio_format_valid(const struct audio_format *af) +{ + return af->sample_rate > 0 && + (af->bits == 8 || af->bits == 16 || af->bits == 24) && + af->channels >= 1; +} + static inline bool audio_format_equals(const struct audio_format *a, const struct audio_format *b) { -- cgit v1.2.3