aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio_format.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-10 11:43:27 +0200
committerMax Kellermann <max@duempel.org>2008-09-10 11:43:27 +0200
commitd92543698c8d5ffa0c1adec4da343e5d7ab65d02 (patch)
tree8de7bd2ba7238fdde837d48e48eef930579b954a /src/audio_format.h
parent9ceadb0561d416b3f729fe3471aa7c4ec3ad1456 (diff)
downloadmpd-d92543698c8d5ffa0c1adec4da343e5d7ab65d02.tar.gz
mpd-d92543698c8d5ffa0c1adec4da343e5d7ab65d02.tar.xz
mpd-d92543698c8d5ffa0c1adec4da343e5d7ab65d02.zip
audio_format: added audio_format_clear() and audio_format_defined()
audio_format_clear() sets an audio_format struct to an cleared (undefined) state, which is both faster and smaller than memset(0). audio_format_defined() checks if the audio_format struct actually has a defined value (i.e. non-zero). Both can be used to avoid pointers to audio_format, replacing the "NULL" value with an "undefined" audio_format.
Diffstat (limited to '')
-rw-r--r--src/audio_format.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/audio_format.h b/src/audio_format.h
index 1cfb258ae..d2461a338 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -27,6 +27,18 @@ struct audio_format {
mpd_sint8 channels;
};
+static inline void audio_format_clear(struct audio_format *af)
+{
+ af->sampleRate = 0;
+ af->bits = 0;
+ af->channels = 0;
+}
+
+static inline int audio_format_defined(const struct audio_format *af)
+{
+ return af->sampleRate != 0;
+}
+
static inline int audio_format_equals(const struct audio_format *a,
const struct audio_format *b)
{