Commit 9a0061c5 authored by Max Kellermann's avatar Max Kellermann

encoder_api: convert to C++

parent 7a3aac18
...@@ -55,8 +55,6 @@ mpd_headers = \ ...@@ -55,8 +55,6 @@ mpd_headers = \
src/filter_internal.h \ src/filter_internal.h \
src/command.h \ src/command.h \
src/conf.h \ src/conf.h \
src/encoder_plugin.h \
src/encoder_api.h \
src/fd_util.h \ src/fd_util.h \
src/gerror.h \ src/gerror.h \
src/glib_compat.h \ src/glib_compat.h \
...@@ -639,6 +637,8 @@ ENCODER_LIBS = \ ...@@ -639,6 +637,8 @@ ENCODER_LIBS = \
$(VORBISENC_LIBS) $(VORBISENC_LIBS)
libencoder_plugins_a_SOURCES = \ libencoder_plugins_a_SOURCES = \
src/EncoderAPI.hxx \
src/EncoderPlugin.hxx \
src/encoder/OggStream.hxx \ src/encoder/OggStream.hxx \
src/encoder/NullEncoderPlugin.cxx src/encoder/NullEncoderPlugin.hxx \ src/encoder/NullEncoderPlugin.cxx src/encoder/NullEncoderPlugin.hxx \
src/EncoderList.cxx src/EncoderList.hxx src/EncoderList.cxx src/EncoderList.hxx
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#ifdef ENABLE_ENCODER #ifdef ENABLE_ENCODER
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#endif #endif
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
* *
*/ */
#ifndef MPD_ENCODER_API_H #ifndef MPD_ENCODER_API_HXX
#define MPD_ENCODER_API_H #define MPD_ENCODER_API_HXX
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "audio_format.h" #include "audio_format.h"
#include "tag.h" #include "tag.h"
#include "conf.h" #include "conf.h"
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "encoder/NullEncoderPlugin.hxx" #include "encoder/NullEncoderPlugin.hxx"
#include "encoder/WaveEncoderPlugin.hxx" #include "encoder/WaveEncoderPlugin.hxx"
#include "encoder/VorbisEncoderPlugin.hxx" #include "encoder/VorbisEncoderPlugin.hxx"
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <string.h> #include <string.h>
const struct encoder_plugin *const encoder_plugins[] = { const EncoderPlugin *const encoder_plugins[] = {
&null_encoder_plugin, &null_encoder_plugin,
#ifdef ENABLE_VORBIS_ENCODER #ifdef ENABLE_VORBIS_ENCODER
&vorbis_encoder_plugin, &vorbis_encoder_plugin,
...@@ -53,7 +53,7 @@ const struct encoder_plugin *const encoder_plugins[] = { ...@@ -53,7 +53,7 @@ const struct encoder_plugin *const encoder_plugins[] = {
NULL NULL
}; };
const struct encoder_plugin * const EncoderPlugin *
encoder_plugin_get(const char *name) encoder_plugin_get(const char *name)
{ {
encoder_plugins_for_each(plugin) encoder_plugins_for_each(plugin)
......
...@@ -20,12 +20,12 @@ ...@@ -20,12 +20,12 @@
#ifndef MPD_ENCODER_LIST_HXX #ifndef MPD_ENCODER_LIST_HXX
#define MPD_ENCODER_LIST_HXX #define MPD_ENCODER_LIST_HXX
struct encoder_plugin; struct EncoderPlugin;
extern const struct encoder_plugin *const encoder_plugins[]; extern const EncoderPlugin *const encoder_plugins[];
#define encoder_plugins_for_each(plugin) \ #define encoder_plugins_for_each(plugin) \
for (const struct encoder_plugin *plugin, \ for (const EncoderPlugin *plugin, \
*const*encoder_plugin_iterator = &encoder_plugins[0]; \ *const*encoder_plugin_iterator = &encoder_plugins[0]; \
(plugin = *encoder_plugin_iterator) != NULL; \ (plugin = *encoder_plugin_iterator) != NULL; \
++encoder_plugin_iterator) ++encoder_plugin_iterator)
...@@ -37,7 +37,7 @@ extern const struct encoder_plugin *const encoder_plugins[]; ...@@ -37,7 +37,7 @@ extern const struct encoder_plugin *const encoder_plugins[];
* @return the encoder plugin with the specified name, or NULL if none * @return the encoder plugin with the specified name, or NULL if none
* was found * was found
*/ */
const struct encoder_plugin * const EncoderPlugin *
encoder_plugin_get(const char *name); encoder_plugin_get(const char *name);
#endif #endif
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_ENCODER_PLUGIN_H #ifndef MPD_ENCODER_PLUGIN_HXX
#define MPD_ENCODER_PLUGIN_H #define MPD_ENCODER_PLUGIN_HXX
#include "gerror.h" #include "gerror.h"
...@@ -26,67 +26,59 @@ ...@@ -26,67 +26,59 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
struct encoder_plugin; struct EncoderPlugin;
struct audio_format; struct audio_format;
struct config_param; struct config_param;
struct tag; struct tag;
struct encoder { struct Encoder {
const struct encoder_plugin *plugin; const EncoderPlugin &plugin;
#ifndef NDEBUG #ifndef NDEBUG
bool open, pre_tag, tag, end; bool open, pre_tag, tag, end;
#endif #endif
explicit Encoder(const EncoderPlugin &_plugin)
:plugin(_plugin)
#ifndef NDEBUG
, open(false)
#endif
{}
}; };
struct encoder_plugin { struct EncoderPlugin {
const char *name; const char *name;
struct encoder *(*init)(const struct config_param *param, Encoder *(*init)(const struct config_param *param,
GError **error); GError **error);
void (*finish)(struct encoder *encoder); void (*finish)(Encoder *encoder);
bool (*open)(struct encoder *encoder, bool (*open)(Encoder *encoder,
struct audio_format *audio_format, struct audio_format *audio_format,
GError **error); GError **error);
void (*close)(struct encoder *encoder); void (*close)(Encoder *encoder);
bool (*end)(struct encoder *encoder, GError **error); bool (*end)(Encoder *encoder, GError **error);
bool (*flush)(struct encoder *encoder, GError **error); bool (*flush)(Encoder *encoder, GError **error);
bool (*pre_tag)(struct encoder *encoder, GError **error); bool (*pre_tag)(Encoder *encoder, GError **error);
bool (*tag)(struct encoder *encoder, const struct tag *tag, bool (*tag)(Encoder *encoder, const struct tag *tag,
GError **error); GError **error);
bool (*write)(struct encoder *encoder, bool (*write)(Encoder *encoder,
const void *data, size_t length, const void *data, size_t length,
GError **error); GError **error);
size_t (*read)(struct encoder *encoder, void *dest, size_t length); size_t (*read)(Encoder *encoder, void *dest, size_t length);
const char *(*get_mime_type)(struct encoder *encoder); const char *(*get_mime_type)(Encoder *encoder);
}; };
/** /**
* Initializes an encoder object. This should be used by encoder
* plugins to initialize their base class.
*/
static inline void
encoder_struct_init(struct encoder *encoder,
const struct encoder_plugin *plugin)
{
encoder->plugin = plugin;
#ifndef NDEBUG
encoder->open = false;
#endif
}
/**
* Creates a new encoder object. * Creates a new encoder object.
* *
* @param plugin the encoder plugin * @param plugin the encoder plugin
...@@ -94,11 +86,11 @@ encoder_struct_init(struct encoder *encoder, ...@@ -94,11 +86,11 @@ encoder_struct_init(struct encoder *encoder,
* @param error location to store the error occurring, or NULL to ignore errors. * @param error location to store the error occurring, or NULL to ignore errors.
* @return an encoder object on success, NULL on failure * @return an encoder object on success, NULL on failure
*/ */
static inline struct encoder * static inline Encoder *
encoder_init(const struct encoder_plugin *plugin, encoder_init(const EncoderPlugin &plugin, const config_param *param,
const struct config_param *param, GError **error) GError **error_r)
{ {
return plugin->init(param, error); return plugin.init(param, error_r);
} }
/** /**
...@@ -107,11 +99,11 @@ encoder_init(const struct encoder_plugin *plugin, ...@@ -107,11 +99,11 @@ encoder_init(const struct encoder_plugin *plugin,
* @param encoder the encoder * @param encoder the encoder
*/ */
static inline void static inline void
encoder_finish(struct encoder *encoder) encoder_finish(Encoder *encoder)
{ {
assert(!encoder->open); assert(!encoder->open);
encoder->plugin->finish(encoder); encoder->plugin.finish(encoder);
} }
/** /**
...@@ -130,12 +122,12 @@ encoder_finish(struct encoder *encoder) ...@@ -130,12 +122,12 @@ encoder_finish(struct encoder *encoder)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_open(struct encoder *encoder, struct audio_format *audio_format, encoder_open(Encoder *encoder, struct audio_format *audio_format,
GError **error) GError **error)
{ {
assert(!encoder->open); assert(!encoder->open);
bool success = encoder->plugin->open(encoder, audio_format, error); bool success = encoder->plugin.open(encoder, audio_format, error);
#ifndef NDEBUG #ifndef NDEBUG
encoder->open = success; encoder->open = success;
encoder->pre_tag = encoder->tag = encoder->end = false; encoder->pre_tag = encoder->tag = encoder->end = false;
...@@ -150,12 +142,12 @@ encoder_open(struct encoder *encoder, struct audio_format *audio_format, ...@@ -150,12 +142,12 @@ encoder_open(struct encoder *encoder, struct audio_format *audio_format,
* @param encoder the encoder * @param encoder the encoder
*/ */
static inline void static inline void
encoder_close(struct encoder *encoder) encoder_close(Encoder *encoder)
{ {
assert(encoder->open); assert(encoder->open);
if (encoder->plugin->close != NULL) if (encoder->plugin.close != NULL)
encoder->plugin->close(encoder); encoder->plugin.close(encoder);
#ifndef NDEBUG #ifndef NDEBUG
encoder->open = false; encoder->open = false;
...@@ -176,7 +168,7 @@ encoder_close(struct encoder *encoder) ...@@ -176,7 +168,7 @@ encoder_close(struct encoder *encoder)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_end(struct encoder *encoder, GError **error) encoder_end(Encoder *encoder, GError **error)
{ {
assert(encoder->open); assert(encoder->open);
assert(!encoder->end); assert(!encoder->end);
...@@ -186,8 +178,8 @@ encoder_end(struct encoder *encoder, GError **error) ...@@ -186,8 +178,8 @@ encoder_end(struct encoder *encoder, GError **error)
#endif #endif
/* this method is optional */ /* this method is optional */
return encoder->plugin->end != NULL return encoder->plugin.end != NULL
? encoder->plugin->end(encoder, error) ? encoder->plugin.end(encoder, error)
: true; : true;
} }
...@@ -200,7 +192,7 @@ encoder_end(struct encoder *encoder, GError **error) ...@@ -200,7 +192,7 @@ encoder_end(struct encoder *encoder, GError **error)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_flush(struct encoder *encoder, GError **error) encoder_flush(Encoder *encoder, GError **error)
{ {
assert(encoder->open); assert(encoder->open);
assert(!encoder->pre_tag); assert(!encoder->pre_tag);
...@@ -208,8 +200,8 @@ encoder_flush(struct encoder *encoder, GError **error) ...@@ -208,8 +200,8 @@ encoder_flush(struct encoder *encoder, GError **error)
assert(!encoder->end); assert(!encoder->end);
/* this method is optional */ /* this method is optional */
return encoder->plugin->flush != NULL return encoder->plugin.flush != NULL
? encoder->plugin->flush(encoder, error) ? encoder->plugin.flush(encoder, error)
: true; : true;
} }
...@@ -224,7 +216,7 @@ encoder_flush(struct encoder *encoder, GError **error) ...@@ -224,7 +216,7 @@ encoder_flush(struct encoder *encoder, GError **error)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_pre_tag(struct encoder *encoder, GError **error) encoder_pre_tag(Encoder *encoder, GError **error)
{ {
assert(encoder->open); assert(encoder->open);
assert(!encoder->pre_tag); assert(!encoder->pre_tag);
...@@ -232,8 +224,8 @@ encoder_pre_tag(struct encoder *encoder, GError **error) ...@@ -232,8 +224,8 @@ encoder_pre_tag(struct encoder *encoder, GError **error)
assert(!encoder->end); assert(!encoder->end);
/* this method is optional */ /* this method is optional */
bool success = encoder->plugin->pre_tag != NULL bool success = encoder->plugin.pre_tag != NULL
? encoder->plugin->pre_tag(encoder, error) ? encoder->plugin.pre_tag(encoder, error)
: true; : true;
#ifndef NDEBUG #ifndef NDEBUG
...@@ -254,7 +246,7 @@ encoder_pre_tag(struct encoder *encoder, GError **error) ...@@ -254,7 +246,7 @@ encoder_pre_tag(struct encoder *encoder, GError **error)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error) encoder_tag(Encoder *encoder, const struct tag *tag, GError **error)
{ {
assert(encoder->open); assert(encoder->open);
assert(!encoder->pre_tag); assert(!encoder->pre_tag);
...@@ -266,8 +258,8 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error) ...@@ -266,8 +258,8 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error)
#endif #endif
/* this method is optional */ /* this method is optional */
return encoder->plugin->tag != NULL return encoder->plugin.tag != NULL
? encoder->plugin->tag(encoder, tag, error) ? encoder->plugin.tag(encoder, tag, error)
: true; : true;
} }
...@@ -281,7 +273,7 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error) ...@@ -281,7 +273,7 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error)
* @return true on success * @return true on success
*/ */
static inline bool static inline bool
encoder_write(struct encoder *encoder, const void *data, size_t length, encoder_write(Encoder *encoder, const void *data, size_t length,
GError **error) GError **error)
{ {
assert(encoder->open); assert(encoder->open);
...@@ -289,7 +281,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length, ...@@ -289,7 +281,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length,
assert(!encoder->tag); assert(!encoder->tag);
assert(!encoder->end); assert(!encoder->end);
return encoder->plugin->write(encoder, data, length, error); return encoder->plugin.write(encoder, data, length, error);
} }
/** /**
...@@ -303,7 +295,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length, ...@@ -303,7 +295,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length,
* @return the number of bytes written to #dest * @return the number of bytes written to #dest
*/ */
static inline size_t static inline size_t
encoder_read(struct encoder *encoder, void *dest, size_t length) encoder_read(Encoder *encoder, void *dest, size_t length)
{ {
assert(encoder->open); assert(encoder->open);
assert(!encoder->pre_tag || !encoder->tag); assert(!encoder->pre_tag || !encoder->tag);
...@@ -315,7 +307,7 @@ encoder_read(struct encoder *encoder, void *dest, size_t length) ...@@ -315,7 +307,7 @@ encoder_read(struct encoder *encoder, void *dest, size_t length)
} }
#endif #endif
return encoder->plugin->read(encoder, dest, length); return encoder->plugin.read(encoder, dest, length);
} }
/** /**
...@@ -325,11 +317,11 @@ encoder_read(struct encoder *encoder, void *dest, size_t length) ...@@ -325,11 +317,11 @@ encoder_read(struct encoder *encoder, void *dest, size_t length)
* @return an constant string, NULL on failure * @return an constant string, NULL on failure
*/ */
static inline const char * static inline const char *
encoder_get_mime_type(struct encoder *encoder) encoder_get_mime_type(Encoder *encoder)
{ {
/* this method is optional */ /* this method is optional */
return encoder->plugin->get_mime_type != NULL return encoder->plugin.get_mime_type != NULL
? encoder->plugin->get_mime_type(encoder) ? encoder->plugin.get_mime_type(encoder)
: NULL; : NULL;
} }
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "FlacEncoderPlugin.hxx" #include "FlacEncoderPlugin.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "audio_format.h" #include "audio_format.h"
#include "pcm/PcmBuffer.hxx" #include "pcm/PcmBuffer.hxx"
#include "util/fifo_buffer.h" #include "util/fifo_buffer.h"
...@@ -39,7 +38,7 @@ extern "C" { ...@@ -39,7 +38,7 @@ extern "C" {
#endif #endif
struct flac_encoder { struct flac_encoder {
struct encoder encoder; Encoder encoder;
struct audio_format audio_format; struct audio_format audio_format;
unsigned compression; unsigned compression;
...@@ -53,10 +52,9 @@ struct flac_encoder { ...@@ -53,10 +52,9 @@ struct flac_encoder {
* picked up with flac_encoder_read(). * picked up with flac_encoder_read().
*/ */
struct fifo_buffer *output_buffer; struct fifo_buffer *output_buffer;
};
extern const struct encoder_plugin flac_encoder_plugin;
flac_encoder():encoder(flac_encoder_plugin) {}
};
static inline GQuark static inline GQuark
flac_encoder_quark(void) flac_encoder_quark(void)
...@@ -74,18 +72,15 @@ flac_encoder_configure(struct flac_encoder *encoder, ...@@ -74,18 +72,15 @@ flac_encoder_configure(struct flac_encoder *encoder,
return true; return true;
} }
static struct encoder * static Encoder *
flac_encoder_init(const struct config_param *param, GError **error) flac_encoder_init(const struct config_param *param, GError **error)
{ {
struct flac_encoder *encoder; flac_encoder *encoder = new flac_encoder();
encoder = g_new(struct flac_encoder, 1);
encoder_struct_init(&encoder->encoder, &flac_encoder_plugin);
/* load configuration from "param" */ /* load configuration from "param" */
if (!flac_encoder_configure(encoder, param, error)) { if (!flac_encoder_configure(encoder, param, error)) {
/* configuration has failed, roll back and return error */ /* configuration has failed, roll back and return error */
g_free(encoder); delete encoder;
return nullptr; return nullptr;
} }
...@@ -93,13 +88,13 @@ flac_encoder_init(const struct config_param *param, GError **error) ...@@ -93,13 +88,13 @@ flac_encoder_init(const struct config_param *param, GError **error)
} }
static void static void
flac_encoder_finish(struct encoder *_encoder) flac_encoder_finish(Encoder *_encoder)
{ {
struct flac_encoder *encoder = (struct flac_encoder *)_encoder; struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
/* the real libFLAC cleanup was already performed by /* the real libFLAC cleanup was already performed by
flac_encoder_close(), so no real work here */ flac_encoder_close(), so no real work here */
g_free(encoder); delete encoder;
} }
static bool static bool
...@@ -154,7 +149,7 @@ flac_write_callback(G_GNUC_UNUSED const FLAC__StreamEncoder *fse, ...@@ -154,7 +149,7 @@ flac_write_callback(G_GNUC_UNUSED const FLAC__StreamEncoder *fse,
} }
static void static void
flac_encoder_close(struct encoder *_encoder) flac_encoder_close(Encoder *_encoder)
{ {
struct flac_encoder *encoder = (struct flac_encoder *)_encoder; struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
...@@ -165,7 +160,7 @@ flac_encoder_close(struct encoder *_encoder) ...@@ -165,7 +160,7 @@ flac_encoder_close(struct encoder *_encoder)
} }
static bool static bool
flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, flac_encoder_open(Encoder *_encoder, struct audio_format *audio_format,
GError **error) GError **error)
{ {
struct flac_encoder *encoder = (struct flac_encoder *)_encoder; struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
...@@ -230,7 +225,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, ...@@ -230,7 +225,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
static bool static bool
flac_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) flac_encoder_flush(Encoder *_encoder, G_GNUC_UNUSED GError **error)
{ {
struct flac_encoder *encoder = (struct flac_encoder *)_encoder; struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
...@@ -257,7 +252,7 @@ pcm16_to_flac(int32_t *out, const int16_t *in, unsigned num_samples) ...@@ -257,7 +252,7 @@ pcm16_to_flac(int32_t *out, const int16_t *in, unsigned num_samples)
} }
static bool static bool
flac_encoder_write(struct encoder *_encoder, flac_encoder_write(Encoder *_encoder,
const void *data, size_t length, const void *data, size_t length,
G_GNUC_UNUSED GError **error) G_GNUC_UNUSED GError **error)
{ {
...@@ -308,7 +303,7 @@ flac_encoder_write(struct encoder *_encoder, ...@@ -308,7 +303,7 @@ flac_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
flac_encoder_read(struct encoder *_encoder, void *dest, size_t length) flac_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
struct flac_encoder *encoder = (struct flac_encoder *)_encoder; struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
...@@ -327,12 +322,12 @@ flac_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -327,12 +322,12 @@ flac_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
flac_encoder_get_mime_type(G_GNUC_UNUSED struct encoder *_encoder) flac_encoder_get_mime_type(G_GNUC_UNUSED Encoder *_encoder)
{ {
return "audio/flac"; return "audio/flac";
} }
const struct encoder_plugin flac_encoder_plugin = { const EncoderPlugin flac_encoder_plugin = {
"flac", "flac",
flac_encoder_init, flac_encoder_init,
flac_encoder_finish, flac_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_FLAC_HXX #ifndef MPD_ENCODER_FLAC_HXX
#define MPD_ENCODER_FLAC_HXX #define MPD_ENCODER_FLAC_HXX
extern const struct encoder_plugin flac_encoder_plugin; extern const struct EncoderPlugin flac_encoder_plugin;
#endif #endif
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "LameEncoderPlugin.hxx" #include "LameEncoderPlugin.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "audio_format.h" #include "audio_format.h"
#include <lame/lame.h> #include <lame/lame.h>
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
#include <string.h> #include <string.h>
struct LameEncoder final { struct LameEncoder final {
struct encoder encoder; Encoder encoder;
struct audio_format audio_format; struct audio_format audio_format;
float quality; float quality;
...@@ -42,9 +41,7 @@ struct LameEncoder final { ...@@ -42,9 +41,7 @@ struct LameEncoder final {
unsigned char buffer[32768]; unsigned char buffer[32768];
size_t buffer_length; size_t buffer_length;
LameEncoder() { LameEncoder():encoder(lame_encoder_plugin) {}
encoder_struct_init(&encoder, &lame_encoder_plugin);
}
bool Configure(const config_param *param, GError **error); bool Configure(const config_param *param, GError **error);
}; };
...@@ -108,7 +105,7 @@ LameEncoder::Configure(const config_param *param, GError **error) ...@@ -108,7 +105,7 @@ LameEncoder::Configure(const config_param *param, GError **error)
return true; return true;
} }
static struct encoder * static Encoder *
lame_encoder_init(const struct config_param *param, GError **error_r) lame_encoder_init(const struct config_param *param, GError **error_r)
{ {
LameEncoder *encoder = new LameEncoder(); LameEncoder *encoder = new LameEncoder();
...@@ -124,7 +121,7 @@ lame_encoder_init(const struct config_param *param, GError **error_r) ...@@ -124,7 +121,7 @@ lame_encoder_init(const struct config_param *param, GError **error_r)
} }
static void static void
lame_encoder_finish(struct encoder *_encoder) lame_encoder_finish(Encoder *_encoder)
{ {
LameEncoder *encoder = (LameEncoder *)_encoder; LameEncoder *encoder = (LameEncoder *)_encoder;
...@@ -190,7 +187,7 @@ lame_encoder_setup(LameEncoder *encoder, GError **error) ...@@ -190,7 +187,7 @@ lame_encoder_setup(LameEncoder *encoder, GError **error)
} }
static bool static bool
lame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, lame_encoder_open(Encoder *_encoder, struct audio_format *audio_format,
GError **error) GError **error)
{ {
LameEncoder *encoder = (LameEncoder *)_encoder; LameEncoder *encoder = (LameEncoder *)_encoder;
...@@ -218,7 +215,7 @@ lame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, ...@@ -218,7 +215,7 @@ lame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
} }
static void static void
lame_encoder_close(struct encoder *_encoder) lame_encoder_close(Encoder *_encoder)
{ {
LameEncoder *encoder = (LameEncoder *)_encoder; LameEncoder *encoder = (LameEncoder *)_encoder;
...@@ -226,7 +223,7 @@ lame_encoder_close(struct encoder *_encoder) ...@@ -226,7 +223,7 @@ lame_encoder_close(struct encoder *_encoder)
} }
static bool static bool
lame_encoder_write(struct encoder *_encoder, lame_encoder_write(Encoder *_encoder,
const void *data, size_t length, const void *data, size_t length,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -265,7 +262,7 @@ lame_encoder_write(struct encoder *_encoder, ...@@ -265,7 +262,7 @@ lame_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
lame_encoder_read(struct encoder *_encoder, void *dest, size_t length) lame_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
LameEncoder *encoder = (LameEncoder *)_encoder; LameEncoder *encoder = (LameEncoder *)_encoder;
...@@ -282,12 +279,12 @@ lame_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -282,12 +279,12 @@ lame_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
lame_encoder_get_mime_type(gcc_unused struct encoder *_encoder) lame_encoder_get_mime_type(gcc_unused Encoder *_encoder)
{ {
return "audio/mpeg"; return "audio/mpeg";
} }
const struct encoder_plugin lame_encoder_plugin = { const EncoderPlugin lame_encoder_plugin = {
"lame", "lame",
lame_encoder_init, lame_encoder_init,
lame_encoder_finish, lame_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_LAME_HXX #ifndef MPD_ENCODER_LAME_HXX
#define MPD_ENCODER_LAME_HXX #define MPD_ENCODER_LAME_HXX
extern const struct encoder_plugin lame_encoder_plugin; extern const struct EncoderPlugin lame_encoder_plugin;
#endif #endif
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "NullEncoderPlugin.hxx" #include "NullEncoderPlugin.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "util/fifo_buffer.h" #include "util/fifo_buffer.h"
extern "C" { extern "C" {
#include "util/growing_fifo.h" #include "util/growing_fifo.h"
...@@ -33,16 +32,14 @@ extern "C" { ...@@ -33,16 +32,14 @@ extern "C" {
#include <string.h> #include <string.h>
struct NullEncoder final { struct NullEncoder final {
struct encoder encoder; Encoder encoder;
struct fifo_buffer *buffer; struct fifo_buffer *buffer;
NullEncoder() { NullEncoder():encoder(null_encoder_plugin) {}
encoder_struct_init(&encoder, &null_encoder_plugin);
}
}; };
static struct encoder * static Encoder *
null_encoder_init(gcc_unused const struct config_param *param, null_encoder_init(gcc_unused const struct config_param *param,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -51,7 +48,7 @@ null_encoder_init(gcc_unused const struct config_param *param, ...@@ -51,7 +48,7 @@ null_encoder_init(gcc_unused const struct config_param *param,
} }
static void static void
null_encoder_finish(struct encoder *_encoder) null_encoder_finish(Encoder *_encoder)
{ {
NullEncoder *encoder = (NullEncoder *)_encoder; NullEncoder *encoder = (NullEncoder *)_encoder;
...@@ -59,7 +56,7 @@ null_encoder_finish(struct encoder *_encoder) ...@@ -59,7 +56,7 @@ null_encoder_finish(struct encoder *_encoder)
} }
static void static void
null_encoder_close(struct encoder *_encoder) null_encoder_close(Encoder *_encoder)
{ {
NullEncoder *encoder = (NullEncoder *)_encoder; NullEncoder *encoder = (NullEncoder *)_encoder;
...@@ -68,7 +65,7 @@ null_encoder_close(struct encoder *_encoder) ...@@ -68,7 +65,7 @@ null_encoder_close(struct encoder *_encoder)
static bool static bool
null_encoder_open(struct encoder *_encoder, null_encoder_open(Encoder *_encoder,
gcc_unused struct audio_format *audio_format, gcc_unused struct audio_format *audio_format,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -78,7 +75,7 @@ null_encoder_open(struct encoder *_encoder, ...@@ -78,7 +75,7 @@ null_encoder_open(struct encoder *_encoder,
} }
static bool static bool
null_encoder_write(struct encoder *_encoder, null_encoder_write(Encoder *_encoder,
const void *data, size_t length, const void *data, size_t length,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -89,7 +86,7 @@ null_encoder_write(struct encoder *_encoder, ...@@ -89,7 +86,7 @@ null_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
null_encoder_read(struct encoder *_encoder, void *dest, size_t length) null_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
NullEncoder *encoder = (NullEncoder *)_encoder; NullEncoder *encoder = (NullEncoder *)_encoder;
...@@ -106,7 +103,7 @@ null_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -106,7 +103,7 @@ null_encoder_read(struct encoder *_encoder, void *dest, size_t length)
return length; return length;
} }
const struct encoder_plugin null_encoder_plugin = { const EncoderPlugin null_encoder_plugin = {
"null", "null",
null_encoder_init, null_encoder_init,
null_encoder_finish, null_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_NULL_HXX #ifndef MPD_ENCODER_NULL_HXX
#define MPD_ENCODER_NULL_HXX #define MPD_ENCODER_NULL_HXX
extern const struct encoder_plugin null_encoder_plugin; extern const struct EncoderPlugin null_encoder_plugin;
#endif #endif
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#include "config.h" #include "config.h"
#include "OpusEncoderPlugin.hxx" #include "OpusEncoderPlugin.hxx"
#include "OggStream.hxx" #include "OggStream.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "audio_format.h" #include "audio_format.h"
#include "mpd_error.h" #include "mpd_error.h"
...@@ -35,7 +34,7 @@ ...@@ -35,7 +34,7 @@
struct opus_encoder { struct opus_encoder {
/** the base class */ /** the base class */
struct encoder encoder; Encoder encoder;
/* configuration */ /* configuration */
...@@ -64,9 +63,7 @@ struct opus_encoder { ...@@ -64,9 +63,7 @@ struct opus_encoder {
ogg_int64_t granulepos; ogg_int64_t granulepos;
opus_encoder() { opus_encoder():encoder(opus_encoder_plugin) {}
encoder_struct_init(&encoder, &opus_encoder_plugin);
}
}; };
gcc_const gcc_const
...@@ -120,7 +117,7 @@ opus_encoder_configure(struct opus_encoder *encoder, ...@@ -120,7 +117,7 @@ opus_encoder_configure(struct opus_encoder *encoder,
return true; return true;
} }
static struct encoder * static Encoder *
opus_encoder_init(const struct config_param *param, GError **error) opus_encoder_init(const struct config_param *param, GError **error)
{ {
opus_encoder *encoder = new opus_encoder(); opus_encoder *encoder = new opus_encoder();
...@@ -136,7 +133,7 @@ opus_encoder_init(const struct config_param *param, GError **error) ...@@ -136,7 +133,7 @@ opus_encoder_init(const struct config_param *param, GError **error)
} }
static void static void
opus_encoder_finish(struct encoder *_encoder) opus_encoder_finish(Encoder *_encoder)
{ {
struct opus_encoder *encoder = (struct opus_encoder *)_encoder; struct opus_encoder *encoder = (struct opus_encoder *)_encoder;
...@@ -146,7 +143,7 @@ opus_encoder_finish(struct encoder *_encoder) ...@@ -146,7 +143,7 @@ opus_encoder_finish(struct encoder *_encoder)
} }
static bool static bool
opus_encoder_open(struct encoder *_encoder, opus_encoder_open(Encoder *_encoder,
struct audio_format *audio_format, struct audio_format *audio_format,
GError **error_r) GError **error_r)
{ {
...@@ -205,7 +202,7 @@ opus_encoder_open(struct encoder *_encoder, ...@@ -205,7 +202,7 @@ opus_encoder_open(struct encoder *_encoder,
} }
static void static void
opus_encoder_close(struct encoder *_encoder) opus_encoder_close(Encoder *_encoder)
{ {
struct opus_encoder *encoder = (struct opus_encoder *)_encoder; struct opus_encoder *encoder = (struct opus_encoder *)_encoder;
...@@ -255,7 +252,7 @@ opus_encoder_do_encode(struct opus_encoder *encoder, bool eos, ...@@ -255,7 +252,7 @@ opus_encoder_do_encode(struct opus_encoder *encoder, bool eos,
} }
static bool static bool
opus_encoder_end(struct encoder *_encoder, GError **error_r) opus_encoder_end(Encoder *_encoder, GError **error_r)
{ {
struct opus_encoder *encoder = (struct opus_encoder *)_encoder; struct opus_encoder *encoder = (struct opus_encoder *)_encoder;
...@@ -269,7 +266,7 @@ opus_encoder_end(struct encoder *_encoder, GError **error_r) ...@@ -269,7 +266,7 @@ opus_encoder_end(struct encoder *_encoder, GError **error_r)
} }
static bool static bool
opus_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) opus_encoder_flush(Encoder *_encoder, G_GNUC_UNUSED GError **error)
{ {
struct opus_encoder *encoder = (struct opus_encoder *)_encoder; struct opus_encoder *encoder = (struct opus_encoder *)_encoder;
...@@ -303,7 +300,7 @@ opus_encoder_write_silence(struct opus_encoder *encoder, unsigned fill_frames, ...@@ -303,7 +300,7 @@ opus_encoder_write_silence(struct opus_encoder *encoder, unsigned fill_frames,
} }
static bool static bool
opus_encoder_write(struct encoder *_encoder, opus_encoder_write(Encoder *_encoder,
const void *_data, size_t length, const void *_data, size_t length,
GError **error_r) GError **error_r)
{ {
...@@ -395,7 +392,7 @@ opus_encoder_generate_tags(struct opus_encoder *encoder) ...@@ -395,7 +392,7 @@ opus_encoder_generate_tags(struct opus_encoder *encoder)
} }
static size_t static size_t
opus_encoder_read(struct encoder *_encoder, void *dest, size_t length) opus_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
struct opus_encoder *encoder = (struct opus_encoder *)_encoder; struct opus_encoder *encoder = (struct opus_encoder *)_encoder;
...@@ -408,12 +405,12 @@ opus_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -408,12 +405,12 @@ opus_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
opus_encoder_get_mime_type(G_GNUC_UNUSED struct encoder *_encoder) opus_encoder_get_mime_type(G_GNUC_UNUSED Encoder *_encoder)
{ {
return "audio/ogg"; return "audio/ogg";
} }
const struct encoder_plugin opus_encoder_plugin = { const EncoderPlugin opus_encoder_plugin = {
"opus", "opus",
opus_encoder_init, opus_encoder_init,
opus_encoder_finish, opus_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_OPUS_H #ifndef MPD_ENCODER_OPUS_H
#define MPD_ENCODER_OPUS_H #define MPD_ENCODER_OPUS_H
extern const struct encoder_plugin opus_encoder_plugin; extern const struct EncoderPlugin opus_encoder_plugin;
#endif #endif
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "TwolameEncoderPlugin.hxx" #include "TwolameEncoderPlugin.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "audio_format.h" #include "audio_format.h"
#include <twolame.h> #include <twolame.h>
...@@ -31,7 +30,7 @@ ...@@ -31,7 +30,7 @@
#include <string.h> #include <string.h>
struct TwolameEncoder final { struct TwolameEncoder final {
struct encoder encoder; Encoder encoder;
struct audio_format audio_format; struct audio_format audio_format;
float quality; float quality;
...@@ -47,9 +46,7 @@ struct TwolameEncoder final { ...@@ -47,9 +46,7 @@ struct TwolameEncoder final {
*/ */
bool flush; bool flush;
TwolameEncoder() { TwolameEncoder():encoder(twolame_encoder_plugin) {}
encoder_struct_init(&encoder, &twolame_encoder_plugin);
}
bool Configure(const config_param *param, GError **error); bool Configure(const config_param *param, GError **error);
}; };
...@@ -113,7 +110,7 @@ TwolameEncoder::Configure(const config_param *param, GError **error) ...@@ -113,7 +110,7 @@ TwolameEncoder::Configure(const config_param *param, GError **error)
return true; return true;
} }
static struct encoder * static Encoder *
twolame_encoder_init(const struct config_param *param, GError **error_r) twolame_encoder_init(const struct config_param *param, GError **error_r)
{ {
g_debug("libtwolame version %s", get_twolame_version()); g_debug("libtwolame version %s", get_twolame_version());
...@@ -131,7 +128,7 @@ twolame_encoder_init(const struct config_param *param, GError **error_r) ...@@ -131,7 +128,7 @@ twolame_encoder_init(const struct config_param *param, GError **error_r)
} }
static void static void
twolame_encoder_finish(struct encoder *_encoder) twolame_encoder_finish(Encoder *_encoder)
{ {
TwolameEncoder *encoder = (TwolameEncoder *)_encoder; TwolameEncoder *encoder = (TwolameEncoder *)_encoder;
...@@ -190,7 +187,7 @@ twolame_encoder_setup(TwolameEncoder *encoder, GError **error) ...@@ -190,7 +187,7 @@ twolame_encoder_setup(TwolameEncoder *encoder, GError **error)
} }
static bool static bool
twolame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format, twolame_encoder_open(Encoder *_encoder, struct audio_format *audio_format,
GError **error) GError **error)
{ {
TwolameEncoder *encoder = (TwolameEncoder *)_encoder; TwolameEncoder *encoder = (TwolameEncoder *)_encoder;
...@@ -219,7 +216,7 @@ twolame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format ...@@ -219,7 +216,7 @@ twolame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format
} }
static void static void
twolame_encoder_close(struct encoder *_encoder) twolame_encoder_close(Encoder *_encoder)
{ {
TwolameEncoder *encoder = (TwolameEncoder *)_encoder; TwolameEncoder *encoder = (TwolameEncoder *)_encoder;
...@@ -227,7 +224,7 @@ twolame_encoder_close(struct encoder *_encoder) ...@@ -227,7 +224,7 @@ twolame_encoder_close(struct encoder *_encoder)
} }
static bool static bool
twolame_encoder_flush(struct encoder *_encoder, gcc_unused GError **error) twolame_encoder_flush(Encoder *_encoder, gcc_unused GError **error)
{ {
TwolameEncoder *encoder = (TwolameEncoder *)_encoder; TwolameEncoder *encoder = (TwolameEncoder *)_encoder;
...@@ -236,7 +233,7 @@ twolame_encoder_flush(struct encoder *_encoder, gcc_unused GError **error) ...@@ -236,7 +233,7 @@ twolame_encoder_flush(struct encoder *_encoder, gcc_unused GError **error)
} }
static bool static bool
twolame_encoder_write(struct encoder *_encoder, twolame_encoder_write(Encoder *_encoder,
const void *data, size_t length, const void *data, size_t length,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -263,7 +260,7 @@ twolame_encoder_write(struct encoder *_encoder, ...@@ -263,7 +260,7 @@ twolame_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
twolame_encoder_read(struct encoder *_encoder, void *dest, size_t length) twolame_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
TwolameEncoder *encoder = (TwolameEncoder *)_encoder; TwolameEncoder *encoder = (TwolameEncoder *)_encoder;
...@@ -290,12 +287,12 @@ twolame_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -290,12 +287,12 @@ twolame_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
twolame_encoder_get_mime_type(gcc_unused struct encoder *_encoder) twolame_encoder_get_mime_type(gcc_unused Encoder *_encoder)
{ {
return "audio/mpeg"; return "audio/mpeg";
} }
const struct encoder_plugin twolame_encoder_plugin = { const EncoderPlugin twolame_encoder_plugin = {
"twolame", "twolame",
twolame_encoder_init, twolame_encoder_init,
twolame_encoder_finish, twolame_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_TWOLAME_HXX #ifndef MPD_ENCODER_TWOLAME_HXX
#define MPD_ENCODER_TWOLAME_HXX #define MPD_ENCODER_TWOLAME_HXX
extern const struct encoder_plugin twolame_encoder_plugin; extern const struct EncoderPlugin twolame_encoder_plugin;
#endif #endif
...@@ -20,8 +20,7 @@ ...@@ -20,8 +20,7 @@
#include "config.h" #include "config.h"
#include "VorbisEncoderPlugin.hxx" #include "VorbisEncoderPlugin.hxx"
#include "OggStream.hxx" #include "OggStream.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "tag.h" #include "tag.h"
#include "audio_format.h" #include "audio_format.h"
#include "mpd_error.h" #include "mpd_error.h"
...@@ -35,7 +34,7 @@ ...@@ -35,7 +34,7 @@
struct vorbis_encoder { struct vorbis_encoder {
/** the base class */ /** the base class */
struct encoder encoder; Encoder encoder;
/* configuration */ /* configuration */
...@@ -52,9 +51,7 @@ struct vorbis_encoder { ...@@ -52,9 +51,7 @@ struct vorbis_encoder {
OggStream stream; OggStream stream;
vorbis_encoder() { vorbis_encoder():encoder(vorbis_encoder_plugin) {}
encoder_struct_init(&encoder, &vorbis_encoder_plugin);
}
}; };
static inline GQuark static inline GQuark
...@@ -117,7 +114,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder, ...@@ -117,7 +114,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
return true; return true;
} }
static struct encoder * static Encoder *
vorbis_encoder_init(const struct config_param *param, GError **error) vorbis_encoder_init(const struct config_param *param, GError **error)
{ {
vorbis_encoder *encoder = new vorbis_encoder(); vorbis_encoder *encoder = new vorbis_encoder();
...@@ -133,7 +130,7 @@ vorbis_encoder_init(const struct config_param *param, GError **error) ...@@ -133,7 +130,7 @@ vorbis_encoder_init(const struct config_param *param, GError **error)
} }
static void static void
vorbis_encoder_finish(struct encoder *_encoder) vorbis_encoder_finish(Encoder *_encoder)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -204,7 +201,7 @@ vorbis_encoder_send_header(struct vorbis_encoder *encoder) ...@@ -204,7 +201,7 @@ vorbis_encoder_send_header(struct vorbis_encoder *encoder)
} }
static bool static bool
vorbis_encoder_open(struct encoder *_encoder, vorbis_encoder_open(Encoder *_encoder,
struct audio_format *audio_format, struct audio_format *audio_format,
GError **error) GError **error)
{ {
...@@ -232,7 +229,7 @@ vorbis_encoder_clear(struct vorbis_encoder *encoder) ...@@ -232,7 +229,7 @@ vorbis_encoder_clear(struct vorbis_encoder *encoder)
} }
static void static void
vorbis_encoder_close(struct encoder *_encoder) vorbis_encoder_close(Encoder *_encoder)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -253,7 +250,7 @@ vorbis_encoder_blockout(struct vorbis_encoder *encoder) ...@@ -253,7 +250,7 @@ vorbis_encoder_blockout(struct vorbis_encoder *encoder)
} }
static bool static bool
vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) vorbis_encoder_flush(Encoder *_encoder, G_GNUC_UNUSED GError **error)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -262,7 +259,7 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) ...@@ -262,7 +259,7 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
} }
static bool static bool
vorbis_encoder_pre_tag(struct encoder *_encoder, G_GNUC_UNUSED GError **error) vorbis_encoder_pre_tag(Encoder *_encoder, G_GNUC_UNUSED GError **error)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -292,7 +289,7 @@ copy_tag_to_vorbis_comment(vorbis_comment *vc, const struct tag *tag) ...@@ -292,7 +289,7 @@ copy_tag_to_vorbis_comment(vorbis_comment *vc, const struct tag *tag)
} }
static bool static bool
vorbis_encoder_tag(struct encoder *_encoder, const struct tag *tag, vorbis_encoder_tag(Encoder *_encoder, const struct tag *tag,
G_GNUC_UNUSED GError **error) G_GNUC_UNUSED GError **error)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -325,7 +322,7 @@ interleaved_to_vorbis_buffer(float **dest, const float *src, ...@@ -325,7 +322,7 @@ interleaved_to_vorbis_buffer(float **dest, const float *src,
} }
static bool static bool
vorbis_encoder_write(struct encoder *_encoder, vorbis_encoder_write(Encoder *_encoder,
const void *data, size_t length, const void *data, size_t length,
G_GNUC_UNUSED GError **error) G_GNUC_UNUSED GError **error)
{ {
...@@ -348,7 +345,7 @@ vorbis_encoder_write(struct encoder *_encoder, ...@@ -348,7 +345,7 @@ vorbis_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
vorbis_encoder_read(struct encoder *_encoder, void *dest, size_t length) vorbis_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder;
...@@ -356,12 +353,12 @@ vorbis_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -356,12 +353,12 @@ vorbis_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
vorbis_encoder_get_mime_type(G_GNUC_UNUSED struct encoder *_encoder) vorbis_encoder_get_mime_type(G_GNUC_UNUSED Encoder *_encoder)
{ {
return "audio/ogg"; return "audio/ogg";
} }
const struct encoder_plugin vorbis_encoder_plugin = { const EncoderPlugin vorbis_encoder_plugin = {
"vorbis", "vorbis",
vorbis_encoder_init, vorbis_encoder_init,
vorbis_encoder_finish, vorbis_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_VORBIS_H #ifndef MPD_ENCODER_VORBIS_H
#define MPD_ENCODER_VORBIS_H #define MPD_ENCODER_VORBIS_H
extern const struct encoder_plugin vorbis_encoder_plugin; extern const struct EncoderPlugin vorbis_encoder_plugin;
#endif #endif
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
#include "config.h" #include "config.h"
#include "WaveEncoderPlugin.hxx" #include "WaveEncoderPlugin.hxx"
#include "encoder_api.h" #include "EncoderAPI.hxx"
#include "encoder_plugin.h"
#include "util/fifo_buffer.h" #include "util/fifo_buffer.h"
extern "C" { extern "C" {
#include "util/growing_fifo.h" #include "util/growing_fifo.h"
...@@ -32,14 +31,12 @@ extern "C" { ...@@ -32,14 +31,12 @@ extern "C" {
#include <string.h> #include <string.h>
struct WaveEncoder { struct WaveEncoder {
struct encoder encoder; Encoder encoder;
unsigned bits; unsigned bits;
struct fifo_buffer *buffer; struct fifo_buffer *buffer;
WaveEncoder() { WaveEncoder():encoder(wave_encoder_plugin) {}
encoder_struct_init(&encoder, &wave_encoder_plugin);
}
}; };
struct wave_header { struct wave_header {
...@@ -58,8 +55,6 @@ struct wave_header { ...@@ -58,8 +55,6 @@ struct wave_header {
uint32_t data_size; uint32_t data_size;
}; };
extern const struct encoder_plugin wave_encoder_plugin;
static void static void
fill_wave_header(struct wave_header *header, int channels, int bits, fill_wave_header(struct wave_header *header, int channels, int bits,
int freq, int block_size) int freq, int block_size)
...@@ -87,7 +82,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits, ...@@ -87,7 +82,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits,
(8 + data_size)); (8 + data_size));
} }
static struct encoder * static Encoder *
wave_encoder_init(gcc_unused const struct config_param *param, wave_encoder_init(gcc_unused const struct config_param *param,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -96,7 +91,7 @@ wave_encoder_init(gcc_unused const struct config_param *param, ...@@ -96,7 +91,7 @@ wave_encoder_init(gcc_unused const struct config_param *param,
} }
static void static void
wave_encoder_finish(struct encoder *_encoder) wave_encoder_finish(Encoder *_encoder)
{ {
WaveEncoder *encoder = (WaveEncoder *)_encoder; WaveEncoder *encoder = (WaveEncoder *)_encoder;
...@@ -104,7 +99,7 @@ wave_encoder_finish(struct encoder *_encoder) ...@@ -104,7 +99,7 @@ wave_encoder_finish(struct encoder *_encoder)
} }
static bool static bool
wave_encoder_open(struct encoder *_encoder, wave_encoder_open(Encoder *_encoder,
gcc_unused struct audio_format *audio_format, gcc_unused struct audio_format *audio_format,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -151,7 +146,7 @@ wave_encoder_open(struct encoder *_encoder, ...@@ -151,7 +146,7 @@ wave_encoder_open(struct encoder *_encoder,
} }
static void static void
wave_encoder_close(struct encoder *_encoder) wave_encoder_close(Encoder *_encoder)
{ {
WaveEncoder *encoder = (WaveEncoder *)_encoder; WaveEncoder *encoder = (WaveEncoder *)_encoder;
...@@ -199,7 +194,7 @@ pcm24_to_wave(uint8_t *dst8, const uint32_t *src32, size_t length) ...@@ -199,7 +194,7 @@ pcm24_to_wave(uint8_t *dst8, const uint32_t *src32, size_t length)
} }
static bool static bool
wave_encoder_write(struct encoder *_encoder, wave_encoder_write(Encoder *_encoder,
const void *src, size_t length, const void *src, size_t length,
gcc_unused GError **error) gcc_unused GError **error)
{ {
...@@ -242,7 +237,7 @@ wave_encoder_write(struct encoder *_encoder, ...@@ -242,7 +237,7 @@ wave_encoder_write(struct encoder *_encoder,
} }
static size_t static size_t
wave_encoder_read(struct encoder *_encoder, void *dest, size_t length) wave_encoder_read(Encoder *_encoder, void *dest, size_t length)
{ {
WaveEncoder *encoder = (WaveEncoder *)_encoder; WaveEncoder *encoder = (WaveEncoder *)_encoder;
...@@ -260,12 +255,12 @@ wave_encoder_read(struct encoder *_encoder, void *dest, size_t length) ...@@ -260,12 +255,12 @@ wave_encoder_read(struct encoder *_encoder, void *dest, size_t length)
} }
static const char * static const char *
wave_encoder_get_mime_type(gcc_unused struct encoder *_encoder) wave_encoder_get_mime_type(gcc_unused Encoder *_encoder)
{ {
return "audio/wav"; return "audio/wav";
} }
const struct encoder_plugin wave_encoder_plugin = { const EncoderPlugin wave_encoder_plugin = {
"wave", "wave",
wave_encoder_init, wave_encoder_init,
wave_encoder_finish, wave_encoder_finish,
......
...@@ -20,6 +20,6 @@ ...@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_WAVE_HXX #ifndef MPD_ENCODER_WAVE_HXX
#define MPD_ENCODER_WAVE_HXX #define MPD_ENCODER_WAVE_HXX
extern const struct encoder_plugin wave_encoder_plugin; extern const struct EncoderPlugin wave_encoder_plugin;
#endif #endif
...@@ -37,6 +37,7 @@ class EventLoop; ...@@ -37,6 +37,7 @@ class EventLoop;
class ServerSocket; class ServerSocket;
class HttpdClient; class HttpdClient;
class Page; class Page;
struct Encoder;
struct HttpdOutput final : private ServerSocket { struct HttpdOutput final : private ServerSocket {
struct audio_output base; struct audio_output base;
...@@ -50,7 +51,7 @@ struct HttpdOutput final : private ServerSocket { ...@@ -50,7 +51,7 @@ struct HttpdOutput final : private ServerSocket {
/** /**
* The configured encoder plugin. * The configured encoder plugin.
*/ */
struct encoder *encoder; Encoder *encoder;
/** /**
* Number of bytes which were fed into the encoder, without * Number of bytes which were fed into the encoder, without
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "HttpdInternal.hxx" #include "HttpdInternal.hxx"
#include "HttpdClient.hxx" #include "HttpdClient.hxx"
#include "OutputAPI.hxx" #include "OutputAPI.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "resolver.h" #include "resolver.h"
#include "Page.hxx" #include "Page.hxx"
...@@ -102,8 +102,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r) ...@@ -102,8 +102,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
const char *encoder_name = const char *encoder_name =
config_get_block_string(param, "encoder", "vorbis"); config_get_block_string(param, "encoder", "vorbis");
const struct encoder_plugin *encoder_plugin = const auto encoder_plugin = encoder_plugin_get(encoder_name);
encoder_plugin_get(encoder_name);
if (encoder_plugin == NULL) { if (encoder_plugin == NULL) {
g_set_error(error_r, httpd_output_quark(), 0, g_set_error(error_r, httpd_output_quark(), 0,
"No such encoder: %s", encoder_name); "No such encoder: %s", encoder_name);
...@@ -125,7 +124,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r) ...@@ -125,7 +124,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
/* initialize encoder */ /* initialize encoder */
encoder = encoder_init(encoder_plugin, param, error_r); encoder = encoder_init(*encoder_plugin, param, error_r);
if (encoder == nullptr) if (encoder == nullptr)
return false; return false;
...@@ -190,7 +189,7 @@ inline void ...@@ -190,7 +189,7 @@ inline void
HttpdOutput::AddClient(int fd) HttpdOutput::AddClient(int fd)
{ {
clients.emplace_front(this, fd, GetEventLoop(), clients.emplace_front(this, fd, GetEventLoop(),
encoder->plugin->tag == NULL); encoder->plugin.tag == nullptr);
++clients_cnt; ++clients_cnt;
/* pass metadata to client */ /* pass metadata to client */
...@@ -489,7 +488,7 @@ HttpdOutput::SendTag(const struct tag *tag) ...@@ -489,7 +488,7 @@ HttpdOutput::SendTag(const struct tag *tag)
{ {
assert(tag != NULL); assert(tag != NULL);
if (encoder->plugin->tag != NULL) { if (encoder->plugin.tag != nullptr) {
/* embed encoder tags */ /* embed encoder tags */
/* flush the current stream, and end it */ /* flush the current stream, and end it */
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "config.h" #include "config.h"
#include "RecorderOutputPlugin.hxx" #include "RecorderOutputPlugin.hxx"
#include "OutputAPI.hxx" #include "OutputAPI.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "fd_util.h" #include "fd_util.h"
#include "open.h" #include "open.h"
...@@ -40,7 +40,7 @@ struct RecorderOutput { ...@@ -40,7 +40,7 @@ struct RecorderOutput {
/** /**
* The configured encoder plugin. * The configured encoder plugin.
*/ */
struct encoder *encoder; Encoder *encoder;
/** /**
* The destination file name. * The destination file name.
...@@ -92,8 +92,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r) ...@@ -92,8 +92,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
const char *encoder_name = const char *encoder_name =
config_get_block_string(param, "encoder", "vorbis"); config_get_block_string(param, "encoder", "vorbis");
const struct encoder_plugin *encoder_plugin = const auto encoder_plugin = encoder_plugin_get(encoder_name);
encoder_plugin_get(encoder_name);
if (encoder_plugin == nullptr) { if (encoder_plugin == nullptr) {
g_set_error(error_r, recorder_output_quark(), 0, g_set_error(error_r, recorder_output_quark(), 0,
"No such encoder: %s", encoder_name); "No such encoder: %s", encoder_name);
...@@ -109,7 +108,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r) ...@@ -109,7 +108,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
/* initialize encoder */ /* initialize encoder */
encoder = encoder_init(encoder_plugin, param, error_r); encoder = encoder_init(*encoder_plugin, param, error_r);
if (encoder == nullptr) if (encoder == nullptr)
return false; return false;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "config.h" #include "config.h"
#include "ShoutOutputPlugin.hxx" #include "ShoutOutputPlugin.hxx"
#include "OutputAPI.hxx" #include "OutputAPI.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "mpd_error.h" #include "mpd_error.h"
...@@ -42,7 +42,7 @@ struct ShoutOutput final { ...@@ -42,7 +42,7 @@ struct ShoutOutput final {
shout_t *shout_conn; shout_t *shout_conn;
shout_metadata_t *shout_meta; shout_metadata_t *shout_meta;
struct encoder *encoder; Encoder *encoder;
float quality; float quality;
int bitrate; int bitrate;
...@@ -88,7 +88,7 @@ shout_output_quark(void) ...@@ -88,7 +88,7 @@ shout_output_quark(void)
return g_quark_from_static_string("shout_output"); return g_quark_from_static_string("shout_output");
} }
static const struct encoder_plugin * static const EncoderPlugin *
shout_encoder_plugin_get(const char *name) shout_encoder_plugin_get(const char *name)
{ {
if (strcmp(name, "ogg") == 0) if (strcmp(name, "ogg") == 0)
...@@ -179,8 +179,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) ...@@ -179,8 +179,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
const char *encoding = config_get_block_string(param, "encoding", const char *encoding = config_get_block_string(param, "encoding",
"ogg"); "ogg");
const struct encoder_plugin *encoder_plugin = const auto encoder_plugin = shout_encoder_plugin_get(encoding);
shout_encoder_plugin_get(encoding);
if (encoder_plugin == nullptr) { if (encoder_plugin == nullptr) {
g_set_error(error_r, shout_output_quark(), 0, g_set_error(error_r, shout_output_quark(), 0,
"couldn't find shout encoder plugin \"%s\"", "couldn't find shout encoder plugin \"%s\"",
...@@ -188,7 +187,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) ...@@ -188,7 +187,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
return false; return false;
} }
encoder = encoder_init(encoder_plugin, param, error_r); encoder = encoder_init(*encoder_plugin, param, error_r);
if (encoder == nullptr) if (encoder == nullptr)
return false; return false;
...@@ -514,7 +513,7 @@ static void my_shout_set_tag(struct audio_output *ao, ...@@ -514,7 +513,7 @@ static void my_shout_set_tag(struct audio_output *ao,
ShoutOutput *sd = (ShoutOutput *)ao; ShoutOutput *sd = (ShoutOutput *)ao;
GError *error = nullptr; GError *error = nullptr;
if (sd->encoder->plugin->tag != nullptr) { if (sd->encoder->plugin.tag != nullptr) {
/* encoder plugin supports stream tags */ /* encoder plugin supports stream tags */
if (!encoder_pre_tag(sd->encoder, &error)) { if (!encoder_pre_tag(sd->encoder, &error)) {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "audio_format.h" #include "audio_format.h"
#include "AudioParser.hxx" #include "AudioParser.hxx"
#include "conf.h" #include "conf.h"
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
#include <unistd.h> #include <unistd.h>
static void static void
encoder_to_stdout(struct encoder *encoder) encoder_to_stdout(Encoder &encoder)
{ {
size_t length; size_t length;
static char buffer[32768]; static char buffer[32768];
while ((length = encoder_read(encoder, buffer, sizeof(buffer))) > 0) { while ((length = encoder_read(&encoder, buffer, sizeof(buffer))) > 0) {
G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length); G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length);
} }
} }
...@@ -47,8 +47,6 @@ int main(int argc, char **argv) ...@@ -47,8 +47,6 @@ int main(int argc, char **argv)
struct audio_format audio_format; struct audio_format audio_format;
bool ret; bool ret;
const char *encoder_name; const char *encoder_name;
const struct encoder_plugin *plugin;
struct encoder *encoder;
static char buffer[32768]; static char buffer[32768];
/* parse command line */ /* parse command line */
...@@ -67,7 +65,7 @@ int main(int argc, char **argv) ...@@ -67,7 +65,7 @@ int main(int argc, char **argv)
/* create the encoder */ /* create the encoder */
plugin = encoder_plugin_get(encoder_name); const auto plugin = encoder_plugin_get(encoder_name);
if (plugin == NULL) { if (plugin == NULL) {
g_printerr("No such encoder: %s\n", encoder_name); g_printerr("No such encoder: %s\n", encoder_name);
return 1; return 1;
...@@ -76,7 +74,7 @@ int main(int argc, char **argv) ...@@ -76,7 +74,7 @@ int main(int argc, char **argv)
config_param param; config_param param;
param.AddBlockParam("quality", "5.0", -1); param.AddBlockParam("quality", "5.0", -1);
encoder = encoder_init(plugin, &param, &error); const auto encoder = encoder_init(*plugin, &param, &error);
if (encoder == NULL) { if (encoder == NULL) {
g_printerr("Failed to initialize encoder: %s\n", g_printerr("Failed to initialize encoder: %s\n",
error->message); error->message);
...@@ -104,7 +102,7 @@ int main(int argc, char **argv) ...@@ -104,7 +102,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
/* do it */ /* do it */
...@@ -118,7 +116,7 @@ int main(int argc, char **argv) ...@@ -118,7 +116,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
} }
ret = encoder_end(encoder, &error); ret = encoder_end(encoder, &error);
...@@ -129,5 +127,5 @@ int main(int argc, char **argv) ...@@ -129,5 +127,5 @@ int main(int argc, char **argv)
return 1; return 1;
} }
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
} }
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "config.h" #include "config.h"
#include "EncoderList.hxx" #include "EncoderList.hxx"
#include "encoder_plugin.h" #include "EncoderPlugin.hxx"
#include "audio_format.h" #include "audio_format.h"
#include "conf.h" #include "conf.h"
#include "stdbin.h" #include "stdbin.h"
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
static uint8_t zero[256]; static uint8_t zero[256];
static void static void
encoder_to_stdout(struct encoder *encoder) encoder_to_stdout(Encoder &encoder)
{ {
size_t length; size_t length;
static char buffer[32768]; static char buffer[32768];
while ((length = encoder_read(encoder, buffer, sizeof(buffer))) > 0) { while ((length = encoder_read(&encoder, buffer, sizeof(buffer))) > 0) {
G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length); G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length);
} }
} }
...@@ -50,13 +50,13 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) ...@@ -50,13 +50,13 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
/* create the encoder */ /* create the encoder */
const struct encoder_plugin *plugin = encoder_plugin_get("vorbis"); const auto plugin = encoder_plugin_get("vorbis");
assert(plugin != NULL); assert(plugin != NULL);
config_param param; config_param param;
param.AddBlockParam("quality", "5.0", -1); param.AddBlockParam("quality", "5.0", -1);
struct encoder *encoder = encoder_init(plugin, &param, NULL); const auto encoder = encoder_init(*plugin, &param, NULL);
assert(encoder != NULL); assert(encoder != NULL);
/* open the encoder */ /* open the encoder */
...@@ -67,21 +67,21 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) ...@@ -67,21 +67,21 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
success = encoder_open(encoder, &audio_format, NULL); success = encoder_open(encoder, &audio_format, NULL);
assert(success); assert(success);
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
/* write a block of data */ /* write a block of data */
success = encoder_write(encoder, zero, sizeof(zero), NULL); success = encoder_write(encoder, zero, sizeof(zero), NULL);
assert(success); assert(success);
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
/* write a tag */ /* write a tag */
success = encoder_pre_tag(encoder, NULL); success = encoder_pre_tag(encoder, NULL);
assert(success); assert(success);
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
struct tag *tag = tag_new(); struct tag *tag = tag_new();
tag_add_item(tag, TAG_ARTIST, "Foo"); tag_add_item(tag, TAG_ARTIST, "Foo");
...@@ -92,7 +92,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) ...@@ -92,7 +92,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
tag_free(tag); tag_free(tag);
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
/* write another block of data */ /* write another block of data */
...@@ -104,7 +104,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) ...@@ -104,7 +104,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
success = encoder_end(encoder, NULL); success = encoder_end(encoder, NULL);
assert(success); assert(success);
encoder_to_stdout(encoder); encoder_to_stdout(*encoder);
encoder_close(encoder); encoder_close(encoder);
encoder_finish(encoder); encoder_finish(encoder);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment