test/run_filter: move code to WriteOrThrow()
This commit is contained in:
parent
f3e133c617
commit
1d332746af
@ -70,6 +70,16 @@ ReadOrThrow(FileDescriptor fd, void *buffer, size_t size)
|
|||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
FullRead(FileDescriptor fd, void *_buffer, size_t size)
|
FullRead(FileDescriptor fd, void *_buffer, size_t size)
|
||||||
{
|
{
|
||||||
@ -153,13 +163,7 @@ try {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
auto dest = filter->FilterPCM({(const void *)buffer, (size_t)nbytes});
|
auto dest = filter->FilterPCM({(const void *)buffer, (size_t)nbytes});
|
||||||
|
WriteOrThrow(output_fd, dest.data, dest.size);
|
||||||
nbytes = output_fd.Write(dest.data, dest.size);
|
|
||||||
if (nbytes < 0) {
|
|
||||||
fprintf(stderr, "Failed to write: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup and exit */
|
/* cleanup and exit */
|
||||||
|
Loading…
Reference in New Issue
Block a user