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.
This commit is contained in:
Max Kellermann
2016-05-04 09:31:21 +02:00
parent 69bf835059
commit e7edc02647
18 changed files with 777 additions and 996 deletions

View File

@@ -20,44 +20,25 @@
#ifndef MPD_ENCODER_PLUGIN_HXX
#define MPD_ENCODER_PLUGIN_HXX
#include <stddef.h>
struct Encoder;
struct PreparedEncoder;
class Encoder;
struct AudioFormat;
struct ConfigBlock;
struct Tag;
class Error;
struct EncoderPlugin {
const char *name;
Encoder *(*init)(const ConfigBlock &block,
PreparedEncoder *(*init)(const ConfigBlock &block,
Error &error);
void (*finish)(PreparedEncoder *encoder);
Encoder *(*open)(PreparedEncoder *encoder,
AudioFormat &audio_format,
Error &error);
void (*finish)(Encoder *encoder);
bool (*open)(Encoder *encoder,
AudioFormat &audio_format,
Error &error);
void (*close)(Encoder *encoder);
bool (*end)(Encoder *encoder, Error &error);
bool (*flush)(Encoder *encoder, Error &error);
bool (*pre_tag)(Encoder *encoder, Error &error);
bool (*tag)(Encoder *encoder, const Tag &tag,
Error &error);
bool (*write)(Encoder *encoder,
const void *data, size_t length,
Error &error);
size_t (*read)(Encoder *encoder, void *dest, size_t length);
const char *(*get_mime_type)(Encoder *encoder);
const char *(*get_mime_type)(PreparedEncoder *encoder);
};
/**
@@ -67,7 +48,7 @@ struct EncoderPlugin {
* @param error location to store the error occurring, or nullptr to ignore errors.
* @return an encoder object on success, nullptr on failure
*/
static inline Encoder *
static inline PreparedEncoder *
encoder_init(const EncoderPlugin &plugin, const ConfigBlock &block,
Error &error)
{