Filter: FilterPCM() returns ConstBuffer

API simplification.  We can now avoid abusing a "size_t*" as
additional return value.
This commit is contained in:
Max Kellermann
2014-08-12 16:09:07 +02:00
parent 56f61a6d59
commit 7244dc4511
11 changed files with 95 additions and 140 deletions

View File

@@ -29,6 +29,7 @@
#include "mixer/MixerControl.hxx"
#include "stdbin.h"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "system/FatalError.hxx"
#include "Log.hxx"
@@ -132,23 +133,21 @@ int main(int argc, char **argv)
while (true) {
ssize_t nbytes;
size_t length;
const void *dest;
nbytes = read(0, buffer, sizeof(buffer));
if (nbytes <= 0)
break;
dest = filter->FilterPCM(buffer, (size_t)nbytes,
&length, error);
if (dest == NULL) {
auto dest = filter->FilterPCM({(const void *)buffer, (size_t)nbytes},
error);
if (dest.IsNull()) {
LogError(error, "filter/Filter failed");
filter->Close();
delete filter;
return EXIT_FAILURE;
}
nbytes = write(1, dest, length);
nbytes = write(1, dest.data, dest.size);
if (nbytes < 0) {
fprintf(stderr, "Failed to write: %s\n",
strerror(errno));