aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio_format.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/audio_format.h b/src/audio_format.h
index d2f32b858..739fe6c1f 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)
{