encoder_api: convert to C++
This commit is contained in:
@@ -37,6 +37,7 @@ class EventLoop;
|
||||
class ServerSocket;
|
||||
class HttpdClient;
|
||||
class Page;
|
||||
struct Encoder;
|
||||
|
||||
struct HttpdOutput final : private ServerSocket {
|
||||
struct audio_output base;
|
||||
@@ -50,7 +51,7 @@ struct HttpdOutput final : private ServerSocket {
|
||||
/**
|
||||
* The configured encoder plugin.
|
||||
*/
|
||||
struct encoder *encoder;
|
||||
Encoder *encoder;
|
||||
|
||||
/**
|
||||
* Number of bytes which were fed into the encoder, without
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include "HttpdInternal.hxx"
|
||||
#include "HttpdClient.hxx"
|
||||
#include "OutputAPI.hxx"
|
||||
#include "encoder_plugin.h"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "EncoderList.hxx"
|
||||
#include "resolver.h"
|
||||
#include "Page.hxx"
|
||||
@@ -102,8 +102,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
|
||||
|
||||
const char *encoder_name =
|
||||
config_get_block_string(param, "encoder", "vorbis");
|
||||
const struct encoder_plugin *encoder_plugin =
|
||||
encoder_plugin_get(encoder_name);
|
||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||
if (encoder_plugin == NULL) {
|
||||
g_set_error(error_r, httpd_output_quark(), 0,
|
||||
"No such encoder: %s", encoder_name);
|
||||
@@ -125,7 +124,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
|
||||
|
||||
/* initialize encoder */
|
||||
|
||||
encoder = encoder_init(encoder_plugin, param, error_r);
|
||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -190,7 +189,7 @@ inline void
|
||||
HttpdOutput::AddClient(int fd)
|
||||
{
|
||||
clients.emplace_front(this, fd, GetEventLoop(),
|
||||
encoder->plugin->tag == NULL);
|
||||
encoder->plugin.tag == nullptr);
|
||||
++clients_cnt;
|
||||
|
||||
/* pass metadata to client */
|
||||
@@ -489,7 +488,7 @@ HttpdOutput::SendTag(const struct tag *tag)
|
||||
{
|
||||
assert(tag != NULL);
|
||||
|
||||
if (encoder->plugin->tag != NULL) {
|
||||
if (encoder->plugin.tag != nullptr) {
|
||||
/* embed encoder tags */
|
||||
|
||||
/* flush the current stream, and end it */
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "RecorderOutputPlugin.hxx"
|
||||
#include "OutputAPI.hxx"
|
||||
#include "encoder_plugin.h"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "EncoderList.hxx"
|
||||
#include "fd_util.h"
|
||||
#include "open.h"
|
||||
@@ -40,7 +40,7 @@ struct RecorderOutput {
|
||||
/**
|
||||
* The configured encoder plugin.
|
||||
*/
|
||||
struct encoder *encoder;
|
||||
Encoder *encoder;
|
||||
|
||||
/**
|
||||
* The destination file name.
|
||||
@@ -92,8 +92,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
|
||||
|
||||
const char *encoder_name =
|
||||
config_get_block_string(param, "encoder", "vorbis");
|
||||
const struct encoder_plugin *encoder_plugin =
|
||||
encoder_plugin_get(encoder_name);
|
||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||
if (encoder_plugin == nullptr) {
|
||||
g_set_error(error_r, recorder_output_quark(), 0,
|
||||
"No such encoder: %s", encoder_name);
|
||||
@@ -109,7 +108,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
|
||||
|
||||
/* initialize encoder */
|
||||
|
||||
encoder = encoder_init(encoder_plugin, param, error_r);
|
||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "ShoutOutputPlugin.hxx"
|
||||
#include "OutputAPI.hxx"
|
||||
#include "encoder_plugin.h"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "EncoderList.hxx"
|
||||
#include "mpd_error.h"
|
||||
|
||||
@@ -42,7 +42,7 @@ struct ShoutOutput final {
|
||||
shout_t *shout_conn;
|
||||
shout_metadata_t *shout_meta;
|
||||
|
||||
struct encoder *encoder;
|
||||
Encoder *encoder;
|
||||
|
||||
float quality;
|
||||
int bitrate;
|
||||
@@ -88,7 +88,7 @@ shout_output_quark(void)
|
||||
return g_quark_from_static_string("shout_output");
|
||||
}
|
||||
|
||||
static const struct encoder_plugin *
|
||||
static const EncoderPlugin *
|
||||
shout_encoder_plugin_get(const char *name)
|
||||
{
|
||||
if (strcmp(name, "ogg") == 0)
|
||||
@@ -179,8 +179,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
||||
|
||||
const char *encoding = config_get_block_string(param, "encoding",
|
||||
"ogg");
|
||||
const struct encoder_plugin *encoder_plugin =
|
||||
shout_encoder_plugin_get(encoding);
|
||||
const auto encoder_plugin = shout_encoder_plugin_get(encoding);
|
||||
if (encoder_plugin == nullptr) {
|
||||
g_set_error(error_r, shout_output_quark(), 0,
|
||||
"couldn't find shout encoder plugin \"%s\"",
|
||||
@@ -188,7 +187,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
||||
return false;
|
||||
}
|
||||
|
||||
encoder = encoder_init(encoder_plugin, param, error_r);
|
||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -514,7 +513,7 @@ static void my_shout_set_tag(struct audio_output *ao,
|
||||
ShoutOutput *sd = (ShoutOutput *)ao;
|
||||
GError *error = nullptr;
|
||||
|
||||
if (sd->encoder->plugin->tag != nullptr) {
|
||||
if (sd->encoder->plugin.tag != nullptr) {
|
||||
/* encoder plugin supports stream tags */
|
||||
|
||||
if (!encoder_pre_tag(sd->encoder, &error)) {
|
||||
|
Reference in New Issue
Block a user