pcm/Normalizer: use std::span

This commit is contained in:
Max Kellermann
2023-03-13 12:45:01 +01:00
parent 738254b2fc
commit 8ea9b89321
4 changed files with 11 additions and 11 deletions

View File

@@ -11,6 +11,7 @@
#include "pcm/AudioParser.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/PrintException.hxx"
#include "util/SpanCast.hxx"
#include <stdexcept>
@@ -22,9 +23,6 @@
int main(int argc, char **argv)
try {
static char buffer[4096];
ssize_t nbytes;
if (argc > 2) {
fprintf(stderr, "Usage: run_normalize [FORMAT] <IN >OUT\n");
return 1;
@@ -36,9 +34,10 @@ try {
PcmNormalizer normalizer;
static std::byte buffer[4096];
ssize_t nbytes;
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
normalizer.ProcessS16((int16_t *)buffer, nbytes / 2);
normalizer.ProcessS16(FromBytesStrict<int16_t>(std::span{buffer}.first(nbytes)));
[[maybe_unused]] ssize_t ignored = write(1, buffer, nbytes);
}