diff options
Diffstat (limited to 'test/software_volume.c')
-rw-r--r-- | test/software_volume.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/test/software_volume.c b/test/software_volume.c index 9a9fd56f6..c4de69328 100644 --- a/test/software_volume.c +++ b/test/software_volume.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2009 The Music Player Daemon Project + * Copyright (C) 2003-2010 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -23,9 +23,11 @@ * */ +#include "config.h" #include "pcm_volume.h" #include "audio_parser.h" #include "audio_format.h" +#include "stdbin.h" #include <glib.h> @@ -35,31 +37,34 @@ int main(int argc, char **argv) { GError *error = NULL; - struct audio_format audio_format = { - .sample_rate = 48000, - .bits = 16, - .channels = 2, - }; + struct audio_format audio_format; bool ret; static char buffer[4096]; ssize_t nbytes; if (argc > 2) { - g_printerr("Usage: software_voluem [FORMAT] <IN >OUT\n"); + g_printerr("Usage: software_volume [FORMAT] <IN >OUT\n"); return 1; } if (argc > 1) { - ret = audio_format_parse(&audio_format, argv[1], &error); + ret = audio_format_parse(&audio_format, argv[1], + false, &error); if (!ret) { g_printerr("Failed to parse audio format: %s\n", error->message); return 1; } - } + } else + audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2); while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { - pcm_volume(buffer, nbytes, &audio_format, PCM_VOLUME_1 / 2); + if (!pcm_volume(buffer, nbytes, &audio_format, + PCM_VOLUME_1 / 2)) { + g_printerr("pcm_volume() has failed\n"); + return 2; + } + write(1, buffer, nbytes); } } |