aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio_format.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_format.h')
-rw-r--r--src/audio_format.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/audio_format.h b/src/audio_format.h
index a4450ad71..1e26974bc 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -44,6 +44,8 @@ enum sample_format {
SAMPLE_FORMAT_S32,
};
+static const unsigned MAX_CHANNELS = 8;
+
/**
* This structure describes the format of a raw PCM stream.
*/
@@ -180,7 +182,7 @@ audio_valid_sample_format(enum sample_format format)
static inline bool
audio_valid_channel_count(unsigned channels)
{
- return channels >= 1 && channels <= 8;
+ return channels >= 1 && channels <= MAX_CHANNELS;
}
/**
@@ -235,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;
@@ -255,13 +255,22 @@ 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.
*/
static inline unsigned