Commit cfeeb7af authored by Max Kellermann's avatar Max Kellermann

test/run_encoder, ...: convert to C++

parent ac887d3a
...@@ -1257,7 +1257,7 @@ endif ...@@ -1257,7 +1257,7 @@ endif
if ENABLE_ENCODER if ENABLE_ENCODER
noinst_PROGRAMS += test/run_encoder noinst_PROGRAMS += test/run_encoder
test_run_encoder_SOURCES = test/run_encoder.c \ test_run_encoder_SOURCES = test/run_encoder.cxx \
test/stdbin.h \ test/stdbin.h \
src/tokenizer.c src/utils.c src/string_util.c \ src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx \ src/Tag.cxx src/TagNames.c src/TagPool.cxx \
...@@ -1295,7 +1295,7 @@ test_test_vorbis_encoder_LDADD = $(MPD_LIBS) \ ...@@ -1295,7 +1295,7 @@ test_test_vorbis_encoder_LDADD = $(MPD_LIBS) \
$(GLIB_LIBS) $(GLIB_LIBS)
endif endif
test_software_volume_SOURCES = test/software_volume.c \ test_software_volume_SOURCES = test/software_volume.cxx \
test/stdbin.h \ test/stdbin.h \
src/audio_check.c \ src/audio_check.c \
src/audio_parser.c src/audio_parser.c
...@@ -1311,7 +1311,7 @@ test_run_normalize_SOURCES = test/run_normalize.c \ ...@@ -1311,7 +1311,7 @@ test_run_normalize_SOURCES = test/run_normalize.c \
test_run_normalize_LDADD = \ test_run_normalize_LDADD = \
$(GLIB_LIBS) $(GLIB_LIBS)
test_run_convert_SOURCES = test/run_convert.c \ test_run_convert_SOURCES = test/run_convert.cxx \
src/dsd2pcm/dsd2pcm.c \ src/dsd2pcm/dsd2pcm.c \
src/audio_format.c \ src/audio_format.c \
src/audio_check.c \ src/audio_check.c \
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
struct audio_format; struct audio_format;
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Parses a string in the form "SAMPLE_RATE:BITS:CHANNELS" into an * Parses a string in the form "SAMPLE_RATE:BITS:CHANNELS" into an
* #audio_format. * #audio_format.
...@@ -46,4 +50,8 @@ bool ...@@ -46,4 +50,8 @@ bool
audio_format_parse(struct audio_format *dest, const char *src, audio_format_parse(struct audio_format *dest, const char *src,
bool mask, GError **error_r); bool mask, GError **error_r);
#ifdef __cplusplus
}
#endif
#endif #endif
...@@ -65,6 +65,10 @@ pcm_volume_dither(void) ...@@ -65,6 +65,10 @@ pcm_volume_dither(void)
return (r & 511) - ((r >> 9) & 511); return (r & 511) - ((r >> 9) & 511);
} }
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Adjust the volume of the specified PCM buffer. * Adjust the volume of the specified PCM buffer.
* *
...@@ -79,4 +83,8 @@ pcm_volume(void *buffer, size_t length, ...@@ -79,4 +83,8 @@ pcm_volume(void *buffer, size_t length,
enum sample_format format, enum sample_format format,
int volume); int volume);
#ifdef __cplusplus
}
#endif
#endif #endif
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -51,7 +51,6 @@ int main(int argc, char **argv) ...@@ -51,7 +51,6 @@ int main(int argc, char **argv)
struct encoder *encoder; struct encoder *encoder;
struct config_param *param; struct config_param *param;
static char buffer[32768]; static char buffer[32768];
ssize_t nbytes;
/* parse command line */ /* parse command line */
...@@ -110,6 +109,7 @@ int main(int argc, char **argv) ...@@ -110,6 +109,7 @@ int main(int argc, char **argv)
/* do it */ /* do it */
ssize_t nbytes;
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
ret = encoder_write(encoder, buffer, nbytes, &error); ret = encoder_write(encoder, buffer, nbytes, &error);
if (!ret) { if (!ret) {
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -59,7 +59,8 @@ int main(int argc, char **argv) ...@@ -59,7 +59,8 @@ int main(int argc, char **argv)
audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2); audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
if (!pcm_volume(buffer, nbytes, audio_format.format, if (!pcm_volume(buffer, nbytes,
sample_format(audio_format.format),
PCM_VOLUME_1 / 2)) { PCM_VOLUME_1 / 2)) {
g_printerr("pcm_volume() has failed\n"); g_printerr("pcm_volume() has failed\n");
return 2; return 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment