aboutsummaryrefslogtreecommitdiffstats
path: root/test/software_volume.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/software_volume.cxx')
-rw-r--r--test/software_volume.cxx20
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();
}