aboutsummaryrefslogtreecommitdiffstats
path: root/src/AudioParser.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-03 21:00:50 +0200
committerMax Kellermann <max@duempel.org>2013-08-03 21:37:56 +0200
commitd1e7b4e38136f9342aad76c685a13adf0e69f869 (patch)
tree49643b937ddfe735511b566a71398da5a945d7aa /src/AudioParser.cxx
parent67f591a9ce60651da41afc499bd9a22e25314e35 (diff)
downloadmpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.gz
mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.xz
mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.zip
audio_format: convert to C++
Diffstat (limited to 'src/AudioParser.cxx')
-rw-r--r--src/AudioParser.cxx35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/AudioParser.cxx b/src/AudioParser.cxx
index 297d99f12..4c345ca33 100644
--- a/src/AudioParser.cxx
+++ b/src/AudioParser.cxx
@@ -24,7 +24,7 @@
#include "config.h"
#include "AudioParser.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include "CheckAudioFormat.hxx"
#include "gcc.h"
@@ -69,27 +69,27 @@ parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r,
static bool
parse_sample_format(const char *src, bool mask,
- enum sample_format *sample_format_r,
+ SampleFormat *sample_format_r,
const char **endptr_r, GError **error_r)
{
unsigned long value;
char *endptr;
- enum sample_format sample_format;
+ SampleFormat sample_format;
if (mask && *src == '*') {
- *sample_format_r = SAMPLE_FORMAT_UNDEFINED;
+ *sample_format_r = SampleFormat::UNDEFINED;
*endptr_r = src + 1;
return true;
}
if (*src == 'f') {
- *sample_format_r = SAMPLE_FORMAT_FLOAT;
+ *sample_format_r = SampleFormat::FLOAT;
*endptr_r = src + 1;
return true;
}
if (memcmp(src, "dsd", 3) == 0) {
- *sample_format_r = SAMPLE_FORMAT_DSD;
+ *sample_format_r = SampleFormat::DSD;
*endptr_r = src + 3;
return true;
}
@@ -103,11 +103,11 @@ parse_sample_format(const char *src, bool mask,
switch (value) {
case 8:
- sample_format = SAMPLE_FORMAT_S8;
+ sample_format = SampleFormat::S8;
break;
case 16:
- sample_format = SAMPLE_FORMAT_S16;
+ sample_format = SampleFormat::S16;
break;
case 24:
@@ -115,11 +115,11 @@ parse_sample_format(const char *src, bool mask,
/* for backwards compatibility */
endptr += 2;
- sample_format = SAMPLE_FORMAT_S24_P32;
+ sample_format = SampleFormat::S24_P32;
break;
case 32:
- sample_format = SAMPLE_FORMAT_S32;
+ sample_format = SampleFormat::S32;
break;
default:
@@ -162,14 +162,14 @@ parse_channel_count(const char *src, bool mask, uint8_t *channels_r,
}
bool
-audio_format_parse(struct audio_format *dest, const char *src,
+audio_format_parse(AudioFormat &dest, const char *src,
bool mask, GError **error_r)
{
uint32_t rate;
- enum sample_format sample_format;
+ SampleFormat sample_format;
uint8_t channels;
- audio_format_clear(dest);
+ dest.Clear();
/* parse sample rate */
@@ -191,7 +191,7 @@ audio_format_parse(struct audio_format *dest, const char *src,
#if GCC_CHECK_VERSION(4,7)
/* workaround -Wmaybe-uninitialized false positive */
- sample_format = SAMPLE_FORMAT_UNDEFINED;
+ sample_format = SampleFormat::UNDEFINED;
#endif
if (!parse_sample_format(src, mask, &sample_format, &src, error_r))
@@ -214,9 +214,10 @@ audio_format_parse(struct audio_format *dest, const char *src,
return false;
}
- audio_format_init(dest, rate, sample_format, channels);
- assert(mask ? audio_format_mask_valid(dest)
- : audio_format_valid(dest));
+ dest = AudioFormat(rate, sample_format, channels);
+ assert(mask
+ ? dest.IsMaskValid()
+ : dest.IsValid());
return true;
}