diff options
author | Max Kellermann <max@duempel.org> | 2013-08-03 21:00:50 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-03 21:37:56 +0200 |
commit | d1e7b4e38136f9342aad76c685a13adf0e69f869 (patch) | |
tree | 49643b937ddfe735511b566a71398da5a945d7aa /src/AudioFormat.cxx | |
parent | 67f591a9ce60651da41afc499bd9a22e25314e35 (diff) | |
download | mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.gz mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.xz mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.zip |
audio_format: convert to C++
Diffstat (limited to '')
-rw-r--r-- | src/AudioFormat.cxx (renamed from src/audio_format.c) | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/audio_format.c b/src/AudioFormat.cxx index cfe3a4cae..04636c1e2 100644 --- a/src/audio_format.c +++ b/src/AudioFormat.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 The Music Player Daemon Project + * Copyright (C) 2003-2013 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -17,53 +17,52 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "audio_format.h" +#include "AudioFormat.hxx" #include <assert.h> #include <stdio.h> void -audio_format_mask_apply(struct audio_format *af, - const struct audio_format *mask) +AudioFormat::ApplyMask(AudioFormat mask) { - assert(audio_format_valid(af)); - assert(audio_format_mask_valid(mask)); + assert(IsValid()); + assert(mask.IsMaskValid()); - if (mask->sample_rate != 0) - af->sample_rate = mask->sample_rate; + if (mask.sample_rate != 0) + sample_rate = mask.sample_rate; - if (mask->format != SAMPLE_FORMAT_UNDEFINED) - af->format = mask->format; + if (mask.format != SampleFormat::UNDEFINED) + format = mask.format; - if (mask->channels != 0) - af->channels = mask->channels; + if (mask.channels != 0) + channels = mask.channels; - assert(audio_format_valid(af)); + assert(IsValid()); } const char * -sample_format_to_string(enum sample_format format) +sample_format_to_string(SampleFormat format) { switch (format) { - case SAMPLE_FORMAT_UNDEFINED: + case SampleFormat::UNDEFINED: return "?"; - case SAMPLE_FORMAT_S8: + case SampleFormat::S8: return "8"; - case SAMPLE_FORMAT_S16: + case SampleFormat::S16: return "16"; - case SAMPLE_FORMAT_S24_P32: + case SampleFormat::S24_P32: return "24"; - case SAMPLE_FORMAT_S32: + case SampleFormat::S32: return "32"; - case SAMPLE_FORMAT_FLOAT: + case SampleFormat::FLOAT: return "f"; - case SAMPLE_FORMAT_DSD: + case SampleFormat::DSD: return "dsd"; } @@ -73,15 +72,14 @@ sample_format_to_string(enum sample_format format) } const char * -audio_format_to_string(const struct audio_format *af, +audio_format_to_string(const AudioFormat af, struct audio_format_string *s) { - assert(af != NULL); - assert(s != NULL); + assert(s != nullptr); snprintf(s->buffer, sizeof(s->buffer), "%u:%s:%u", - af->sample_rate, sample_format_to_string(af->format), - af->channels); + af.sample_rate, sample_format_to_string(af.format), + af.channels); return s->buffer; } |