From 6238cc073474ce079197ff62e3f66f81963fc127 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 26 Aug 2019 21:14:19 +0200 Subject: test/run_filter: pass ConstBuffer to FullWrite() --- test/run_filter.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/run_filter.cxx b/test/run_filter.cxx index 6d8a270f0..d51461511 100644 --- a/test/run_filter.cxx +++ b/test/run_filter.cxx @@ -96,20 +96,23 @@ FullRead(FileDescriptor fd, void *_buffer, size_t size) } static void -FullWrite(FileDescriptor fd, const void *_buffer, size_t size) +FullWrite(FileDescriptor fd, ConstBuffer src) { - auto buffer = (const uint8_t *)_buffer; - - while (size > 0) { - size_t nbytes = WriteOrThrow(fd, buffer, size); + while (!src.empty()) { + size_t nbytes = WriteOrThrow(fd, src.data, src.size); if (nbytes == 0) throw std::runtime_error("Write failed"); - buffer += nbytes; - size -= nbytes; + src.skip_front(nbytes); } } +static void +FullWrite(FileDescriptor fd, ConstBuffer src) +{ + FullWrite(fd, ConstBuffer::FromVoid(src)); +} + static size_t ReadFrames(FileDescriptor fd, void *_buffer, size_t size, size_t frame_size) { @@ -178,7 +181,7 @@ try { break; auto dest = filter->FilterPCM({(const void *)buffer, (size_t)nbytes}); - FullWrite(output_fd, dest.data, dest.size); + FullWrite(output_fd, dest); } /* cleanup and exit */ -- cgit v1.2.3