diff options
author | Max Kellermann <max@duempel.org> | 2013-12-22 23:26:52 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-23 10:58:37 +0100 |
commit | 8edde7a4b3d652d0ac6ac3770369ddababe310a3 (patch) | |
tree | 3f0f59fd22e20853eed3e0ecee65a75fcef87155 /test/software_volume.cxx | |
parent | d11a0c9f14dcabf9ddbf8e38379dc7d6d890b02b (diff) | |
download | mpd-8edde7a4b3d652d0ac6ac3770369ddababe310a3.tar.gz mpd-8edde7a4b3d652d0ac6ac3770369ddababe310a3.tar.xz mpd-8edde7a4b3d652d0ac6ac3770369ddababe310a3.zip |
pcm/Volume: convert to class
Prepare for adding state.
Diffstat (limited to '')
-rw-r--r-- | test/software_volume.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
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 <glib.h> #include <stddef.h> +#include <stdlib.h> #include <unistd.h> 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(); } |