summaryrefslogtreecommitdiff
path: root/src/encoder/plugins/OpusEncoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-05-04 18:29:31 +0200
committerMax Kellermann <max@duempel.org>2016-05-04 18:32:52 +0200
commitb376536a3bcbcc8840c4df3dc5f3850fb7b09ac5 (patch)
tree8aedb8fad4522e71de0f0aaa80b852b2332220ad /src/encoder/plugins/OpusEncoderPlugin.cxx
parente7edc0264745499609aa22bd19620e15f6ef3e62 (diff)
encoder/Interface: convert PreparedEncoder to abstract class
Diffstat (limited to 'src/encoder/plugins/OpusEncoderPlugin.cxx')
-rw-r--r--src/encoder/plugins/OpusEncoderPlugin.cxx48
1 files changed, 10 insertions, 38 deletions
diff --git a/src/encoder/plugins/OpusEncoderPlugin.cxx b/src/encoder/plugins/OpusEncoderPlugin.cxx
index 87c6d56f8..86d18be5d 100644
--- a/src/encoder/plugins/OpusEncoderPlugin.cxx
+++ b/src/encoder/plugins/OpusEncoderPlugin.cxx
@@ -77,20 +77,20 @@ private:
void GenerateTags();
};
-struct PreparedOpusEncoder {
- /** the base class */
- PreparedEncoder encoder;
-
- /* configuration */
-
+class PreparedOpusEncoder final : public PreparedEncoder {
opus_int32 bitrate;
int complexity;
int signal;
- PreparedOpusEncoder():encoder(opus_encoder_plugin) {}
-
+public:
bool Configure(const ConfigBlock &block, Error &error);
- Encoder *Open(AudioFormat &audio_format, Error &error);
+
+ /* virtual methods from class PreparedEncoder */
+ Encoder *Open(AudioFormat &audio_format, Error &) override;
+
+ const char *GetMimeType() const override {
+ return "audio/ogg";
+ }
};
static constexpr Domain opus_encoder_domain("opus_encoder");
@@ -146,17 +146,7 @@ opus_encoder_init(const ConfigBlock &block, Error &error)
return nullptr;
}
- return &encoder->encoder;
-}
-
-static void
-opus_encoder_finish(PreparedEncoder *_encoder)
-{
- auto *encoder = (PreparedOpusEncoder *)_encoder;
-
- /* the real libopus cleanup was already performed by
- opus_encoder_close(), so no real work here */
- delete encoder;
+ return encoder;
}
OpusEncoder::OpusEncoder(AudioFormat &_audio_format, ::OpusEncoder *_enc)
@@ -214,15 +204,6 @@ PreparedOpusEncoder::Open(AudioFormat &audio_format, Error &error)
return new OpusEncoder(audio_format, enc);
}
-static Encoder *
-opus_encoder_open(PreparedEncoder *_encoder,
- AudioFormat &audio_format,
- Error &error)
-{
- auto &encoder = *(PreparedOpusEncoder *)_encoder;
- return encoder.Open(audio_format, error);
-}
-
OpusEncoder::~OpusEncoder()
{
stream.Deinitialize();
@@ -405,18 +386,9 @@ OpusEncoder::Read(void *dest, size_t length)
return stream.PageOut(dest, length);
}
-static const char *
-opus_encoder_get_mime_type(gcc_unused PreparedEncoder *_encoder)
-{
- return "audio/ogg";
-}
-
}
const EncoderPlugin opus_encoder_plugin = {
"opus",
opus_encoder_init,
- opus_encoder_finish,
- opus_encoder_open,
- opus_encoder_get_mime_type,
};