diff options
author | Max Kellermann <max@duempel.org> | 2016-05-04 09:31:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-05-04 16:32:31 +0200 |
commit | e7edc0264745499609aa22bd19620e15f6ef3e62 (patch) | |
tree | 057402f9c77c5d5e9bf3346ca8cff4499ca444b6 /test/run_encoder.cxx | |
parent | 69bf835059cfb8c233979b9988404a65c971e2a5 (diff) |
encoder/Interface: move instance methods to abstract class
Rename struct Encoder to PreparedEncoder, and add a new (abstract)
class Encoder which represents one encoder instance.
Diffstat (limited to 'test/run_encoder.cxx')
-rw-r--r-- | test/run_encoder.cxx | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/test/run_encoder.cxx b/test/run_encoder.cxx index 8341e7ff5..ad4d1444a 100644 --- a/test/run_encoder.cxx +++ b/test/run_encoder.cxx @@ -65,8 +65,8 @@ int main(int argc, char **argv) try { Error error; - const auto encoder = encoder_init(*plugin, block, error); - if (encoder == NULL) { + const auto p_encoder = encoder_init(*plugin, block, error); + if (p_encoder == nullptr) { LogError(error, "Failed to initialize encoder"); return EXIT_FAILURE; } @@ -81,7 +81,8 @@ int main(int argc, char **argv) } } - if (!encoder->Open(audio_format, error)) { + auto *encoder = p_encoder->Open(audio_format, error); + if (encoder == nullptr) { LogError(error, "Failed to open encoder"); return EXIT_FAILURE; } @@ -94,7 +95,7 @@ int main(int argc, char **argv) ssize_t nbytes; while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { - if (!encoder_write(encoder, buffer, nbytes, error)) { + if (!encoder->Write(buffer, nbytes, error)) { LogError(error, "encoder_write() failed"); return EXIT_FAILURE; } @@ -102,15 +103,15 @@ int main(int argc, char **argv) EncoderToOutputStream(os, *encoder); } - if (!encoder_end(encoder, error)) { + if (!encoder->End(error)) { LogError(error, "encoder_flush() failed"); return EXIT_FAILURE; } EncoderToOutputStream(os, *encoder); - encoder->Close(); - encoder->Dispose(); + delete encoder; + p_encoder->Dispose(); return EXIT_SUCCESS; } catch (const std::exception &e) { |