Commit cfeeb7af authored by Max Kellermann's avatar Max Kellermann

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

parent ac887d3a
......@@ -1257,7 +1257,7 @@ endif
if ENABLE_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 \
src/tokenizer.c src/utils.c src/string_util.c \
src/Tag.cxx src/TagNames.c src/TagPool.cxx \
......@@ -1295,7 +1295,7 @@ test_test_vorbis_encoder_LDADD = $(MPD_LIBS) \
$(GLIB_LIBS)
endif
test_software_volume_SOURCES = test/software_volume.c \
test_software_volume_SOURCES = test/software_volume.cxx \
test/stdbin.h \
src/audio_check.c \
src/audio_parser.c
......@@ -1311,7 +1311,7 @@ test_run_normalize_SOURCES = test/run_normalize.c \
test_run_normalize_LDADD = \
$(GLIB_LIBS)
test_run_convert_SOURCES = test/run_convert.c \
test_run_convert_SOURCES = test/run_convert.cxx \
src/dsd2pcm/dsd2pcm.c \
src/audio_format.c \
src/audio_check.c \
......
......@@ -31,6 +31,10 @@
struct audio_format;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Parses a string in the form "SAMPLE_RATE:BITS:CHANNELS" into an
* #audio_format.
......@@ -46,4 +50,8 @@ bool
audio_format_parse(struct audio_format *dest, const char *src,
bool mask, GError **error_r);
#ifdef __cplusplus
}
#endif
#endif
......@@ -65,6 +65,10 @@ pcm_volume_dither(void)
return (r & 511) - ((r >> 9) & 511);
}
#ifdef __cplusplus
extern "C" {
#endif
/**
* Adjust the volume of the specified PCM buffer.
*
......@@ -79,4 +83,8 @@ pcm_volume(void *buffer, size_t length,
enum sample_format format,
int volume);
#ifdef __cplusplus
}
#endif
#endif
/*
* 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
......
/*
* 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
......@@ -51,7 +51,6 @@ int main(int argc, char **argv)
struct encoder *encoder;
struct config_param *param;
static char buffer[32768];
ssize_t nbytes;
/* parse command line */
......@@ -110,6 +109,7 @@ int main(int argc, char **argv)
/* do it */
ssize_t nbytes;
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
ret = encoder_write(encoder, buffer, nbytes, &error);
if (!ret) {
......
/*
* 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
......@@ -59,7 +59,8 @@ int main(int argc, char **argv)
audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
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)) {
g_printerr("pcm_volume() has failed\n");
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