summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-09-07 20:11:00 +0200
committerMax Kellermann <max@musicpd.org>2020-09-07 20:13:43 +0200
commitae23682372c92c5416f5bd4ec5cd3c276f7add14 (patch)
treee43a348aebfc246982c95a5bb068b9fcb62222b6 /test
parent540919f256c761a3e5ce5cfa3d5c343ef09ed673 (diff)
system/FileDescriptor: add method FullWrite()
Diffstat (limited to 'test')
-rw-r--r--test/run_filter.cxx32
1 files changed, 2 insertions, 30 deletions
diff --git a/test/run_filter.cxx b/test/run_filter.cxx
index 5113a7250..dc8f11586 100644
--- a/test/run_filter.cxx
+++ b/test/run_filter.cxx
@@ -71,34 +71,6 @@ ReadOrThrow(FileDescriptor fd, void *buffer, size_t size)
}
static size_t
-WriteOrThrow(FileDescriptor fd, const void *buffer, size_t size)
-{
- auto nbytes = fd.Write(buffer, size);
- if (nbytes < 0)
- throw MakeErrno("Write failed");
-
- return nbytes;
-}
-
-static void
-FullWrite(FileDescriptor fd, ConstBuffer<uint8_t> src)
-{
- while (!src.empty()) {
- size_t nbytes = WriteOrThrow(fd, src.data, src.size);
- if (nbytes == 0)
- throw std::runtime_error("Write failed");
-
- src.skip_front(nbytes);
- }
-}
-
-static void
-FullWrite(FileDescriptor fd, ConstBuffer<void> src)
-{
- FullWrite(fd, ConstBuffer<uint8_t>::FromVoid(src));
-}
-
-static size_t
ReadFrames(FileDescriptor fd, void *_buffer, size_t size, size_t frame_size)
{
auto buffer = (uint8_t *)_buffer;
@@ -166,14 +138,14 @@ try {
break;
auto dest = filter->FilterPCM({(const void *)buffer, (size_t)nbytes});
- FullWrite(output_fd, dest);
+ output_fd.FullWrite(dest.data, dest.size);
}
while (true) {
auto dest = filter->Flush();
if (dest.IsNull())
break;
- FullWrite(output_fd, dest);
+ output_fd.FullWrite(dest.data, dest.size);
}
/* cleanup and exit */