From 8edde7a4b3d652d0ac6ac3770369ddababe310a3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 22 Dec 2013 23:26:52 +0100 Subject: pcm/Volume: convert to class Prepare for adding state. --- test/software_volume.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'test/software_volume.cxx') diff --git a/test/software_volume.cxx b/test/software_volume.cxx index b850217df..ae2d53a08 100644 --- a/test/software_volume.cxx +++ b/test/software_volume.cxx @@ -27,12 +27,14 @@ #include "pcm/Volume.hxx" #include "AudioParser.hxx" #include "AudioFormat.hxx" +#include "util/ConstBuffer.hxx" #include "util/Error.hxx" #include "stdbin.h" #include #include +#include #include int main(int argc, char **argv) @@ -55,14 +57,16 @@ int main(int argc, char **argv) } } - while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { - if (!pcm_volume(buffer, nbytes, - audio_format.format, - PCM_VOLUME_1 / 2)) { - g_printerr("pcm_volume() has failed\n"); - return 2; - } + PcmVolume pv; + if (!pv.Open(audio_format.format, error)) { + fprintf(stderr, "%s\n", error.GetMessage()); + return EXIT_FAILURE; + } - gcc_unused ssize_t ignored = write(1, buffer, nbytes); + while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { + auto dest = pv.Apply({buffer, size_t(nbytes)}); + gcc_unused ssize_t ignored = write(1, dest.data, dest.size); } + + pv.Close(); } -- cgit v1.2.3