Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9a0061c5
Commit
9a0061c5
authored
Jul 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoder_api: convert to C++
parent
7a3aac18
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
198 additions
and
235 deletions
+198
-235
Makefile.am
Makefile.am
+2
-2
CommandLine.cxx
src/CommandLine.cxx
+1
-1
EncoderAPI.hxx
src/EncoderAPI.hxx
+4
-4
EncoderList.cxx
src/EncoderList.cxx
+3
-3
EncoderList.hxx
src/EncoderList.hxx
+4
-4
EncoderPlugin.hxx
src/EncoderPlugin.hxx
+55
-63
FlacEncoderPlugin.cxx
src/encoder/FlacEncoderPlugin.cxx
+16
-21
FlacEncoderPlugin.hxx
src/encoder/FlacEncoderPlugin.hxx
+1
-1
LameEncoderPlugin.cxx
src/encoder/LameEncoderPlugin.cxx
+11
-14
LameEncoderPlugin.hxx
src/encoder/LameEncoderPlugin.hxx
+1
-1
NullEncoderPlugin.cxx
src/encoder/NullEncoderPlugin.cxx
+10
-13
NullEncoderPlugin.hxx
src/encoder/NullEncoderPlugin.hxx
+1
-1
OpusEncoderPlugin.cxx
src/encoder/OpusEncoderPlugin.cxx
+13
-16
OpusEncoderPlugin.hxx
src/encoder/OpusEncoderPlugin.hxx
+1
-1
TwolameEncoderPlugin.cxx
src/encoder/TwolameEncoderPlugin.cxx
+12
-15
TwolameEncoderPlugin.hxx
src/encoder/TwolameEncoderPlugin.hxx
+1
-1
VorbisEncoderPlugin.cxx
src/encoder/VorbisEncoderPlugin.cxx
+14
-17
VorbisEncoderPlugin.hxx
src/encoder/VorbisEncoderPlugin.hxx
+1
-1
WaveEncoderPlugin.cxx
src/encoder/WaveEncoderPlugin.cxx
+11
-16
WaveEncoderPlugin.hxx
src/encoder/WaveEncoderPlugin.hxx
+1
-1
HttpdInternal.hxx
src/output/HttpdInternal.hxx
+2
-1
HttpdOutputPlugin.cxx
src/output/HttpdOutputPlugin.cxx
+5
-6
RecorderOutputPlugin.cxx
src/output/RecorderOutputPlugin.cxx
+4
-5
ShoutOutputPlugin.cxx
src/output/ShoutOutputPlugin.cxx
+6
-7
run_encoder.cxx
test/run_encoder.cxx
+8
-10
test_vorbis_encoder.cxx
test/test_vorbis_encoder.cxx
+10
-10
No files found.
Makefile.am
View file @
9a0061c5
...
...
@@ -55,8 +55,6 @@ mpd_headers = \
src/filter_internal.h
\
src/command.h
\
src/conf.h
\
src/encoder_plugin.h
\
src/encoder_api.h
\
src/fd_util.h
\
src/gerror.h
\
src/glib_compat.h
\
...
...
@@ -639,6 +637,8 @@ ENCODER_LIBS = \
$(VORBISENC_LIBS)
libencoder_plugins_a_SOURCES
=
\
src/EncoderAPI.hxx
\
src/EncoderPlugin.hxx
\
src/encoder/OggStream.hxx
\
src/encoder/NullEncoderPlugin.cxx src/encoder/NullEncoderPlugin.hxx
\
src/EncoderList.cxx src/EncoderList.hxx
...
...
src/CommandLine.cxx
View file @
9a0061c5
...
...
@@ -36,7 +36,7 @@
#ifdef ENABLE_ENCODER
#include "EncoderList.hxx"
#include "
encoder_plugin.h
"
#include "
EncoderPlugin.hxx
"
#endif
#ifdef ENABLE_ARCHIVE
...
...
src/
encoder_api.h
→
src/
EncoderAPI.hxx
View file @
9a0061c5
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -22,10 +22,10 @@
*
*/
#ifndef MPD_ENCODER_API_H
#define MPD_ENCODER_API_H
#ifndef MPD_ENCODER_API_H
XX
#define MPD_ENCODER_API_H
XX
#include "
encoder_plugin.h
"
#include "
EncoderPlugin.hxx
"
#include "audio_format.h"
#include "tag.h"
#include "conf.h"
...
...
src/EncoderList.cxx
View file @
9a0061c5
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "EncoderList.hxx"
#include "
encoder_plugin.h
"
#include "
EncoderPlugin.hxx
"
#include "encoder/NullEncoderPlugin.hxx"
#include "encoder/WaveEncoderPlugin.hxx"
#include "encoder/VorbisEncoderPlugin.hxx"
...
...
@@ -30,7 +30,7 @@
#include <string.h>
const
struct
encoder_p
lugin
*
const
encoder_plugins
[]
=
{
const
EncoderP
lugin
*
const
encoder_plugins
[]
=
{
&
null_encoder_plugin
,
#ifdef ENABLE_VORBIS_ENCODER
&
vorbis_encoder_plugin
,
...
...
@@ -53,7 +53,7 @@ const struct encoder_plugin *const encoder_plugins[] = {
NULL
};
const
struct
encoder_p
lugin
*
const
EncoderP
lugin
*
encoder_plugin_get
(
const
char
*
name
)
{
encoder_plugins_for_each
(
plugin
)
...
...
src/EncoderList.hxx
View file @
9a0061c5
...
...
@@ -20,12 +20,12 @@
#ifndef MPD_ENCODER_LIST_HXX
#define MPD_ENCODER_LIST_HXX
struct
encoder_p
lugin
;
struct
EncoderP
lugin
;
extern
const
struct
encoder_p
lugin
*
const
encoder_plugins
[];
extern
const
EncoderP
lugin
*
const
encoder_plugins
[];
#define encoder_plugins_for_each(plugin) \
for (const
struct encoder_p
lugin *plugin, \
for (const
EncoderP
lugin *plugin, \
*const*encoder_plugin_iterator = &encoder_plugins[0]; \
(plugin = *encoder_plugin_iterator) != NULL; \
++encoder_plugin_iterator)
...
...
@@ -37,7 +37,7 @@ extern const struct encoder_plugin *const encoder_plugins[];
* @return the encoder plugin with the specified name, or NULL if none
* was found
*/
const
struct
encoder_p
lugin
*
const
EncoderP
lugin
*
encoder_plugin_get
(
const
char
*
name
);
#endif
src/
encoder_plugin.h
→
src/
EncoderPlugin.hxx
View file @
9a0061c5
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ENCODER_PLUGIN_H
#define MPD_ENCODER_PLUGIN_H
#ifndef MPD_ENCODER_PLUGIN_H
XX
#define MPD_ENCODER_PLUGIN_H
XX
#include "gerror.h"
...
...
@@ -26,67 +26,59 @@
#include <stdbool.h>
#include <stddef.h>
struct
encoder_p
lugin
;
struct
EncoderP
lugin
;
struct
audio_format
;
struct
config_param
;
struct
tag
;
struct
e
ncoder
{
const
struct
encoder_plugin
*
plugin
;
struct
E
ncoder
{
const
EncoderPlugin
&
plugin
;
#ifndef NDEBUG
bool
open
,
pre_tag
,
tag
,
end
;
#endif
explicit
Encoder
(
const
EncoderPlugin
&
_plugin
)
:
plugin
(
_plugin
)
#ifndef NDEBUG
,
open
(
false
)
#endif
{}
};
struct
encoder_p
lugin
{
struct
EncoderP
lugin
{
const
char
*
name
;
struct
e
ncoder
*
(
*
init
)(
const
struct
config_param
*
param
,
E
ncoder
*
(
*
init
)(
const
struct
config_param
*
param
,
GError
**
error
);
void
(
*
finish
)(
struct
e
ncoder
*
encoder
);
void
(
*
finish
)(
E
ncoder
*
encoder
);
bool
(
*
open
)(
struct
e
ncoder
*
encoder
,
bool
(
*
open
)(
E
ncoder
*
encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
);
void
(
*
close
)(
struct
e
ncoder
*
encoder
);
void
(
*
close
)(
E
ncoder
*
encoder
);
bool
(
*
end
)(
struct
e
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
end
)(
E
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
flush
)(
struct
e
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
flush
)(
E
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
pre_tag
)(
struct
e
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
pre_tag
)(
E
ncoder
*
encoder
,
GError
**
error
);
bool
(
*
tag
)(
struct
e
ncoder
*
encoder
,
const
struct
tag
*
tag
,
bool
(
*
tag
)(
E
ncoder
*
encoder
,
const
struct
tag
*
tag
,
GError
**
error
);
bool
(
*
write
)(
struct
e
ncoder
*
encoder
,
bool
(
*
write
)(
E
ncoder
*
encoder
,
const
void
*
data
,
size_t
length
,
GError
**
error
);
size_t
(
*
read
)(
struct
e
ncoder
*
encoder
,
void
*
dest
,
size_t
length
);
size_t
(
*
read
)(
E
ncoder
*
encoder
,
void
*
dest
,
size_t
length
);
const
char
*
(
*
get_mime_type
)(
struct
e
ncoder
*
encoder
);
const
char
*
(
*
get_mime_type
)(
E
ncoder
*
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.
*
* @param plugin the encoder plugin
...
...
@@ -94,11 +86,11 @@ encoder_struct_init(struct encoder *encoder,
* @param error location to store the error occurring, or NULL to ignore errors.
* @return an encoder object on success, NULL on failure
*/
static
inline
struct
e
ncoder
*
encoder_init
(
const
struct
encoder_plugin
*
plugin
,
const
struct
config_param
*
param
,
GError
**
erro
r
)
static
inline
E
ncoder
*
encoder_init
(
const
EncoderPlugin
&
plugin
,
const
config_param
*
param
,
GError
**
error_
r
)
{
return
plugin
->
init
(
param
,
erro
r
);
return
plugin
.
init
(
param
,
error_
r
);
}
/**
...
...
@@ -107,11 +99,11 @@ encoder_init(const struct encoder_plugin *plugin,
* @param encoder the encoder
*/
static
inline
void
encoder_finish
(
struct
e
ncoder
*
encoder
)
encoder_finish
(
E
ncoder
*
encoder
)
{
assert
(
!
encoder
->
open
);
encoder
->
plugin
->
finish
(
encoder
);
encoder
->
plugin
.
finish
(
encoder
);
}
/**
...
...
@@ -130,12 +122,12 @@ encoder_finish(struct encoder *encoder)
* @return true on success
*/
static
inline
bool
encoder_open
(
struct
e
ncoder
*
encoder
,
struct
audio_format
*
audio_format
,
encoder_open
(
E
ncoder
*
encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
)
{
assert
(
!
encoder
->
open
);
bool
success
=
encoder
->
plugin
->
open
(
encoder
,
audio_format
,
error
);
bool
success
=
encoder
->
plugin
.
open
(
encoder
,
audio_format
,
error
);
#ifndef NDEBUG
encoder
->
open
=
success
;
encoder
->
pre_tag
=
encoder
->
tag
=
encoder
->
end
=
false
;
...
...
@@ -150,12 +142,12 @@ encoder_open(struct encoder *encoder, struct audio_format *audio_format,
* @param encoder the encoder
*/
static
inline
void
encoder_close
(
struct
e
ncoder
*
encoder
)
encoder_close
(
E
ncoder
*
encoder
)
{
assert
(
encoder
->
open
);
if
(
encoder
->
plugin
->
close
!=
NULL
)
encoder
->
plugin
->
close
(
encoder
);
if
(
encoder
->
plugin
.
close
!=
NULL
)
encoder
->
plugin
.
close
(
encoder
);
#ifndef NDEBUG
encoder
->
open
=
false
;
...
...
@@ -176,7 +168,7 @@ encoder_close(struct encoder *encoder)
* @return true on success
*/
static
inline
bool
encoder_end
(
struct
e
ncoder
*
encoder
,
GError
**
error
)
encoder_end
(
E
ncoder
*
encoder
,
GError
**
error
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
end
);
...
...
@@ -186,8 +178,8 @@ encoder_end(struct encoder *encoder, GError **error)
#endif
/* this method is optional */
return
encoder
->
plugin
->
end
!=
NULL
?
encoder
->
plugin
->
end
(
encoder
,
error
)
return
encoder
->
plugin
.
end
!=
NULL
?
encoder
->
plugin
.
end
(
encoder
,
error
)
:
true
;
}
...
...
@@ -200,7 +192,7 @@ encoder_end(struct encoder *encoder, GError **error)
* @return true on success
*/
static
inline
bool
encoder_flush
(
struct
e
ncoder
*
encoder
,
GError
**
error
)
encoder_flush
(
E
ncoder
*
encoder
,
GError
**
error
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
...
...
@@ -208,8 +200,8 @@ encoder_flush(struct encoder *encoder, GError **error)
assert
(
!
encoder
->
end
);
/* this method is optional */
return
encoder
->
plugin
->
flush
!=
NULL
?
encoder
->
plugin
->
flush
(
encoder
,
error
)
return
encoder
->
plugin
.
flush
!=
NULL
?
encoder
->
plugin
.
flush
(
encoder
,
error
)
:
true
;
}
...
...
@@ -224,7 +216,7 @@ encoder_flush(struct encoder *encoder, GError **error)
* @return true on success
*/
static
inline
bool
encoder_pre_tag
(
struct
e
ncoder
*
encoder
,
GError
**
error
)
encoder_pre_tag
(
E
ncoder
*
encoder
,
GError
**
error
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
...
...
@@ -232,8 +224,8 @@ encoder_pre_tag(struct encoder *encoder, GError **error)
assert
(
!
encoder
->
end
);
/* this method is optional */
bool
success
=
encoder
->
plugin
->
pre_tag
!=
NULL
?
encoder
->
plugin
->
pre_tag
(
encoder
,
error
)
bool
success
=
encoder
->
plugin
.
pre_tag
!=
NULL
?
encoder
->
plugin
.
pre_tag
(
encoder
,
error
)
:
true
;
#ifndef NDEBUG
...
...
@@ -254,7 +246,7 @@ encoder_pre_tag(struct encoder *encoder, GError **error)
* @return true on success
*/
static
inline
bool
encoder_tag
(
struct
e
ncoder
*
encoder
,
const
struct
tag
*
tag
,
GError
**
error
)
encoder_tag
(
E
ncoder
*
encoder
,
const
struct
tag
*
tag
,
GError
**
error
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
...
...
@@ -266,8 +258,8 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error)
#endif
/* this method is optional */
return
encoder
->
plugin
->
tag
!=
NULL
?
encoder
->
plugin
->
tag
(
encoder
,
tag
,
error
)
return
encoder
->
plugin
.
tag
!=
NULL
?
encoder
->
plugin
.
tag
(
encoder
,
tag
,
error
)
:
true
;
}
...
...
@@ -281,7 +273,7 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error)
* @return true on success
*/
static
inline
bool
encoder_write
(
struct
e
ncoder
*
encoder
,
const
void
*
data
,
size_t
length
,
encoder_write
(
E
ncoder
*
encoder
,
const
void
*
data
,
size_t
length
,
GError
**
error
)
{
assert
(
encoder
->
open
);
...
...
@@ -289,7 +281,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length,
assert
(
!
encoder
->
tag
);
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,
* @return the number of bytes written to #dest
*/
static
inline
size_t
encoder_read
(
struct
e
ncoder
*
encoder
,
void
*
dest
,
size_t
length
)
encoder_read
(
E
ncoder
*
encoder
,
void
*
dest
,
size_t
length
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
||
!
encoder
->
tag
);
...
...
@@ -315,7 +307,7 @@ encoder_read(struct encoder *encoder, void *dest, size_t length)
}
#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)
* @return an constant string, NULL on failure
*/
static
inline
const
char
*
encoder_get_mime_type
(
struct
e
ncoder
*
encoder
)
encoder_get_mime_type
(
E
ncoder
*
encoder
)
{
/* this method is optional */
return
encoder
->
plugin
->
get_mime_type
!=
NULL
?
encoder
->
plugin
->
get_mime_type
(
encoder
)
return
encoder
->
plugin
.
get_mime_type
!=
NULL
?
encoder
->
plugin
.
get_mime_type
(
encoder
)
:
NULL
;
}
...
...
src/encoder/FlacEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -19,8 +19,7 @@
#include "config.h"
#include "FlacEncoderPlugin.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "audio_format.h"
#include "pcm/PcmBuffer.hxx"
#include "util/fifo_buffer.h"
...
...
@@ -39,7 +38,7 @@ extern "C" {
#endif
struct
flac_encoder
{
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
struct
audio_format
audio_format
;
unsigned
compression
;
...
...
@@ -53,10 +52,9 @@ struct flac_encoder {
* picked up with flac_encoder_read().
*/
struct
fifo_buffer
*
output_buffer
;
};
extern
const
struct
encoder_plugin
flac_encoder_plugin
;
flac_encoder
()
:
encoder
(
flac_encoder_plugin
)
{}
};
static
inline
GQuark
flac_encoder_quark
(
void
)
...
...
@@ -74,18 +72,15 @@ flac_encoder_configure(struct flac_encoder *encoder,
return
true
;
}
static
struct
e
ncoder
*
static
E
ncoder
*
flac_encoder_init
(
const
struct
config_param
*
param
,
GError
**
error
)
{
struct
flac_encoder
*
encoder
;
encoder
=
g_new
(
struct
flac_encoder
,
1
);
encoder_struct_init
(
&
encoder
->
encoder
,
&
flac_encoder_plugin
);
flac_encoder
*
encoder
=
new
flac_encoder
();
/* load configuration from "param" */
if
(
!
flac_encoder_configure
(
encoder
,
param
,
error
))
{
/* configuration has failed, roll back and return error */
g_free
(
encoder
)
;
delete
encoder
;
return
nullptr
;
}
...
...
@@ -93,13 +88,13 @@ flac_encoder_init(const struct config_param *param, GError **error)
}
static
void
flac_encoder_finish
(
struct
e
ncoder
*
_encoder
)
flac_encoder_finish
(
E
ncoder
*
_encoder
)
{
struct
flac_encoder
*
encoder
=
(
struct
flac_encoder
*
)
_encoder
;
/* the real libFLAC cleanup was already performed by
flac_encoder_close(), so no real work here */
g_free
(
encoder
)
;
delete
encoder
;
}
static
bool
...
...
@@ -154,7 +149,7 @@ flac_write_callback(G_GNUC_UNUSED const FLAC__StreamEncoder *fse,
}
static
void
flac_encoder_close
(
struct
e
ncoder
*
_encoder
)
flac_encoder_close
(
E
ncoder
*
_encoder
)
{
struct
flac_encoder
*
encoder
=
(
struct
flac_encoder
*
)
_encoder
;
...
...
@@ -165,7 +160,7 @@ flac_encoder_close(struct encoder *_encoder)
}
static
bool
flac_encoder_open
(
struct
e
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
flac_encoder_open
(
E
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
)
{
struct
flac_encoder
*
encoder
=
(
struct
flac_encoder
*
)
_encoder
;
...
...
@@ -230,7 +225,7 @@ flac_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
static
bool
flac_encoder_flush
(
struct
e
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
flac_encoder_flush
(
E
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
{
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)
}
static
bool
flac_encoder_write
(
struct
e
ncoder
*
_encoder
,
flac_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
data
,
size_t
length
,
G_GNUC_UNUSED
GError
**
error
)
{
...
...
@@ -308,7 +303,7 @@ flac_encoder_write(struct encoder *_encoder,
}
static
size_t
flac_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
flac_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
struct
flac_encoder
*
encoder
=
(
struct
flac_encoder
*
)
_encoder
;
...
...
@@ -327,12 +322,12 @@ flac_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
flac_encoder_get_mime_type
(
G_GNUC_UNUSED
struct
e
ncoder
*
_encoder
)
flac_encoder_get_mime_type
(
G_GNUC_UNUSED
E
ncoder
*
_encoder
)
{
return
"audio/flac"
;
}
const
struct
encoder_p
lugin
flac_encoder_plugin
=
{
const
EncoderP
lugin
flac_encoder_plugin
=
{
"flac"
,
flac_encoder_init
,
flac_encoder_finish
,
...
...
src/encoder/FlacEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_FLAC_HXX
#define MPD_ENCODER_FLAC_HXX
extern
const
struct
encoder_p
lugin
flac_encoder_plugin
;
extern
const
struct
EncoderP
lugin
flac_encoder_plugin
;
#endif
src/encoder/LameEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -19,8 +19,7 @@
#include "config.h"
#include "LameEncoderPlugin.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "audio_format.h"
#include <lame/lame.h>
...
...
@@ -31,7 +30,7 @@
#include <string.h>
struct
LameEncoder
final
{
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
struct
audio_format
audio_format
;
float
quality
;
...
...
@@ -42,9 +41,7 @@ struct LameEncoder final {
unsigned
char
buffer
[
32768
];
size_t
buffer_length
;
LameEncoder
()
{
encoder_struct_init
(
&
encoder
,
&
lame_encoder_plugin
);
}
LameEncoder
()
:
encoder
(
lame_encoder_plugin
)
{}
bool
Configure
(
const
config_param
*
param
,
GError
**
error
);
};
...
...
@@ -108,7 +105,7 @@ LameEncoder::Configure(const config_param *param, GError **error)
return
true
;
}
static
struct
e
ncoder
*
static
E
ncoder
*
lame_encoder_init
(
const
struct
config_param
*
param
,
GError
**
error_r
)
{
LameEncoder
*
encoder
=
new
LameEncoder
();
...
...
@@ -124,7 +121,7 @@ lame_encoder_init(const struct config_param *param, GError **error_r)
}
static
void
lame_encoder_finish
(
struct
e
ncoder
*
_encoder
)
lame_encoder_finish
(
E
ncoder
*
_encoder
)
{
LameEncoder
*
encoder
=
(
LameEncoder
*
)
_encoder
;
...
...
@@ -190,7 +187,7 @@ lame_encoder_setup(LameEncoder *encoder, GError **error)
}
static
bool
lame_encoder_open
(
struct
e
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
lame_encoder_open
(
E
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
)
{
LameEncoder
*
encoder
=
(
LameEncoder
*
)
_encoder
;
...
...
@@ -218,7 +215,7 @@ lame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format,
}
static
void
lame_encoder_close
(
struct
e
ncoder
*
_encoder
)
lame_encoder_close
(
E
ncoder
*
_encoder
)
{
LameEncoder
*
encoder
=
(
LameEncoder
*
)
_encoder
;
...
...
@@ -226,7 +223,7 @@ lame_encoder_close(struct encoder *_encoder)
}
static
bool
lame_encoder_write
(
struct
e
ncoder
*
_encoder
,
lame_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
data
,
size_t
length
,
gcc_unused
GError
**
error
)
{
...
...
@@ -265,7 +262,7 @@ lame_encoder_write(struct encoder *_encoder,
}
static
size_t
lame_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
lame_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
LameEncoder
*
encoder
=
(
LameEncoder
*
)
_encoder
;
...
...
@@ -282,12 +279,12 @@ lame_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
lame_encoder_get_mime_type
(
gcc_unused
struct
e
ncoder
*
_encoder
)
lame_encoder_get_mime_type
(
gcc_unused
E
ncoder
*
_encoder
)
{
return
"audio/mpeg"
;
}
const
struct
encoder_p
lugin
lame_encoder_plugin
=
{
const
EncoderP
lugin
lame_encoder_plugin
=
{
"lame"
,
lame_encoder_init
,
lame_encoder_finish
,
...
...
src/encoder/LameEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_LAME_HXX
#define MPD_ENCODER_LAME_HXX
extern
const
struct
encoder_p
lugin
lame_encoder_plugin
;
extern
const
struct
EncoderP
lugin
lame_encoder_plugin
;
#endif
src/encoder/NullEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -19,8 +19,7 @@
#include "config.h"
#include "NullEncoderPlugin.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "util/fifo_buffer.h"
extern
"C"
{
#include "util/growing_fifo.h"
...
...
@@ -33,16 +32,14 @@ extern "C" {
#include <string.h>
struct
NullEncoder
final
{
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
struct
fifo_buffer
*
buffer
;
NullEncoder
()
{
encoder_struct_init
(
&
encoder
,
&
null_encoder_plugin
);
}
NullEncoder
()
:
encoder
(
null_encoder_plugin
)
{}
};
static
struct
e
ncoder
*
static
E
ncoder
*
null_encoder_init
(
gcc_unused
const
struct
config_param
*
param
,
gcc_unused
GError
**
error
)
{
...
...
@@ -51,7 +48,7 @@ null_encoder_init(gcc_unused const struct config_param *param,
}
static
void
null_encoder_finish
(
struct
e
ncoder
*
_encoder
)
null_encoder_finish
(
E
ncoder
*
_encoder
)
{
NullEncoder
*
encoder
=
(
NullEncoder
*
)
_encoder
;
...
...
@@ -59,7 +56,7 @@ null_encoder_finish(struct encoder *_encoder)
}
static
void
null_encoder_close
(
struct
e
ncoder
*
_encoder
)
null_encoder_close
(
E
ncoder
*
_encoder
)
{
NullEncoder
*
encoder
=
(
NullEncoder
*
)
_encoder
;
...
...
@@ -68,7 +65,7 @@ null_encoder_close(struct encoder *_encoder)
static
bool
null_encoder_open
(
struct
e
ncoder
*
_encoder
,
null_encoder_open
(
E
ncoder
*
_encoder
,
gcc_unused
struct
audio_format
*
audio_format
,
gcc_unused
GError
**
error
)
{
...
...
@@ -78,7 +75,7 @@ null_encoder_open(struct encoder *_encoder,
}
static
bool
null_encoder_write
(
struct
e
ncoder
*
_encoder
,
null_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
data
,
size_t
length
,
gcc_unused
GError
**
error
)
{
...
...
@@ -89,7 +86,7 @@ null_encoder_write(struct encoder *_encoder,
}
static
size_t
null_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
null_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
NullEncoder
*
encoder
=
(
NullEncoder
*
)
_encoder
;
...
...
@@ -106,7 +103,7 @@ null_encoder_read(struct encoder *_encoder, void *dest, size_t length)
return
length
;
}
const
struct
encoder_p
lugin
null_encoder_plugin
=
{
const
EncoderP
lugin
null_encoder_plugin
=
{
"null"
,
null_encoder_init
,
null_encoder_finish
,
...
...
src/encoder/NullEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_NULL_HXX
#define MPD_ENCODER_NULL_HXX
extern
const
struct
encoder_p
lugin
null_encoder_plugin
;
extern
const
struct
EncoderP
lugin
null_encoder_plugin
;
#endif
src/encoder/OpusEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -20,8 +20,7 @@
#include "config.h"
#include "OpusEncoderPlugin.hxx"
#include "OggStream.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "audio_format.h"
#include "mpd_error.h"
...
...
@@ -35,7 +34,7 @@
struct
opus_encoder
{
/** the base class */
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
/* configuration */
...
...
@@ -64,9 +63,7 @@ struct opus_encoder {
ogg_int64_t
granulepos
;
opus_encoder
()
{
encoder_struct_init
(
&
encoder
,
&
opus_encoder_plugin
);
}
opus_encoder
()
:
encoder
(
opus_encoder_plugin
)
{}
};
gcc_const
...
...
@@ -120,7 +117,7 @@ opus_encoder_configure(struct opus_encoder *encoder,
return
true
;
}
static
struct
e
ncoder
*
static
E
ncoder
*
opus_encoder_init
(
const
struct
config_param
*
param
,
GError
**
error
)
{
opus_encoder
*
encoder
=
new
opus_encoder
();
...
...
@@ -136,7 +133,7 @@ opus_encoder_init(const struct config_param *param, GError **error)
}
static
void
opus_encoder_finish
(
struct
e
ncoder
*
_encoder
)
opus_encoder_finish
(
E
ncoder
*
_encoder
)
{
struct
opus_encoder
*
encoder
=
(
struct
opus_encoder
*
)
_encoder
;
...
...
@@ -146,7 +143,7 @@ opus_encoder_finish(struct encoder *_encoder)
}
static
bool
opus_encoder_open
(
struct
e
ncoder
*
_encoder
,
opus_encoder_open
(
E
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
GError
**
error_r
)
{
...
...
@@ -205,7 +202,7 @@ opus_encoder_open(struct encoder *_encoder,
}
static
void
opus_encoder_close
(
struct
e
ncoder
*
_encoder
)
opus_encoder_close
(
E
ncoder
*
_encoder
)
{
struct
opus_encoder
*
encoder
=
(
struct
opus_encoder
*
)
_encoder
;
...
...
@@ -255,7 +252,7 @@ opus_encoder_do_encode(struct opus_encoder *encoder, bool eos,
}
static
bool
opus_encoder_end
(
struct
e
ncoder
*
_encoder
,
GError
**
error_r
)
opus_encoder_end
(
E
ncoder
*
_encoder
,
GError
**
error_r
)
{
struct
opus_encoder
*
encoder
=
(
struct
opus_encoder
*
)
_encoder
;
...
...
@@ -269,7 +266,7 @@ opus_encoder_end(struct encoder *_encoder, GError **error_r)
}
static
bool
opus_encoder_flush
(
struct
e
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
opus_encoder_flush
(
E
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
opus_encoder
*
encoder
=
(
struct
opus_encoder
*
)
_encoder
;
...
...
@@ -303,7 +300,7 @@ opus_encoder_write_silence(struct opus_encoder *encoder, unsigned fill_frames,
}
static
bool
opus_encoder_write
(
struct
e
ncoder
*
_encoder
,
opus_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
_data
,
size_t
length
,
GError
**
error_r
)
{
...
...
@@ -395,7 +392,7 @@ opus_encoder_generate_tags(struct opus_encoder *encoder)
}
static
size_t
opus_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
opus_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
struct
opus_encoder
*
encoder
=
(
struct
opus_encoder
*
)
_encoder
;
...
...
@@ -408,12 +405,12 @@ opus_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
opus_encoder_get_mime_type
(
G_GNUC_UNUSED
struct
e
ncoder
*
_encoder
)
opus_encoder_get_mime_type
(
G_GNUC_UNUSED
E
ncoder
*
_encoder
)
{
return
"audio/ogg"
;
}
const
struct
encoder_p
lugin
opus_encoder_plugin
=
{
const
EncoderP
lugin
opus_encoder_plugin
=
{
"opus"
,
opus_encoder_init
,
opus_encoder_finish
,
...
...
src/encoder/OpusEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_OPUS_H
#define MPD_ENCODER_OPUS_H
extern
const
struct
encoder_p
lugin
opus_encoder_plugin
;
extern
const
struct
EncoderP
lugin
opus_encoder_plugin
;
#endif
src/encoder/TwolameEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -19,8 +19,7 @@
#include "config.h"
#include "TwolameEncoderPlugin.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "audio_format.h"
#include <twolame.h>
...
...
@@ -31,7 +30,7 @@
#include <string.h>
struct
TwolameEncoder
final
{
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
struct
audio_format
audio_format
;
float
quality
;
...
...
@@ -47,9 +46,7 @@ struct TwolameEncoder final {
*/
bool
flush
;
TwolameEncoder
()
{
encoder_struct_init
(
&
encoder
,
&
twolame_encoder_plugin
);
}
TwolameEncoder
()
:
encoder
(
twolame_encoder_plugin
)
{}
bool
Configure
(
const
config_param
*
param
,
GError
**
error
);
};
...
...
@@ -113,7 +110,7 @@ TwolameEncoder::Configure(const config_param *param, GError **error)
return
true
;
}
static
struct
e
ncoder
*
static
E
ncoder
*
twolame_encoder_init
(
const
struct
config_param
*
param
,
GError
**
error_r
)
{
g_debug
(
"libtwolame version %s"
,
get_twolame_version
());
...
...
@@ -131,7 +128,7 @@ twolame_encoder_init(const struct config_param *param, GError **error_r)
}
static
void
twolame_encoder_finish
(
struct
e
ncoder
*
_encoder
)
twolame_encoder_finish
(
E
ncoder
*
_encoder
)
{
TwolameEncoder
*
encoder
=
(
TwolameEncoder
*
)
_encoder
;
...
...
@@ -190,7 +187,7 @@ twolame_encoder_setup(TwolameEncoder *encoder, GError **error)
}
static
bool
twolame_encoder_open
(
struct
e
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
twolame_encoder_open
(
E
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
)
{
TwolameEncoder
*
encoder
=
(
TwolameEncoder
*
)
_encoder
;
...
...
@@ -219,7 +216,7 @@ twolame_encoder_open(struct encoder *_encoder, struct audio_format *audio_format
}
static
void
twolame_encoder_close
(
struct
e
ncoder
*
_encoder
)
twolame_encoder_close
(
E
ncoder
*
_encoder
)
{
TwolameEncoder
*
encoder
=
(
TwolameEncoder
*
)
_encoder
;
...
...
@@ -227,7 +224,7 @@ twolame_encoder_close(struct encoder *_encoder)
}
static
bool
twolame_encoder_flush
(
struct
e
ncoder
*
_encoder
,
gcc_unused
GError
**
error
)
twolame_encoder_flush
(
E
ncoder
*
_encoder
,
gcc_unused
GError
**
error
)
{
TwolameEncoder
*
encoder
=
(
TwolameEncoder
*
)
_encoder
;
...
...
@@ -236,7 +233,7 @@ twolame_encoder_flush(struct encoder *_encoder, gcc_unused GError **error)
}
static
bool
twolame_encoder_write
(
struct
e
ncoder
*
_encoder
,
twolame_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
data
,
size_t
length
,
gcc_unused
GError
**
error
)
{
...
...
@@ -263,7 +260,7 @@ twolame_encoder_write(struct encoder *_encoder,
}
static
size_t
twolame_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
twolame_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
TwolameEncoder
*
encoder
=
(
TwolameEncoder
*
)
_encoder
;
...
...
@@ -290,12 +287,12 @@ twolame_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
twolame_encoder_get_mime_type
(
gcc_unused
struct
e
ncoder
*
_encoder
)
twolame_encoder_get_mime_type
(
gcc_unused
E
ncoder
*
_encoder
)
{
return
"audio/mpeg"
;
}
const
struct
encoder_p
lugin
twolame_encoder_plugin
=
{
const
EncoderP
lugin
twolame_encoder_plugin
=
{
"twolame"
,
twolame_encoder_init
,
twolame_encoder_finish
,
...
...
src/encoder/TwolameEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_TWOLAME_HXX
#define MPD_ENCODER_TWOLAME_HXX
extern
const
struct
encoder_p
lugin
twolame_encoder_plugin
;
extern
const
struct
EncoderP
lugin
twolame_encoder_plugin
;
#endif
src/encoder/VorbisEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -20,8 +20,7 @@
#include "config.h"
#include "VorbisEncoderPlugin.hxx"
#include "OggStream.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "tag.h"
#include "audio_format.h"
#include "mpd_error.h"
...
...
@@ -35,7 +34,7 @@
struct
vorbis_encoder
{
/** the base class */
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
/* configuration */
...
...
@@ -52,9 +51,7 @@ struct vorbis_encoder {
OggStream
stream
;
vorbis_encoder
()
{
encoder_struct_init
(
&
encoder
,
&
vorbis_encoder_plugin
);
}
vorbis_encoder
()
:
encoder
(
vorbis_encoder_plugin
)
{}
};
static
inline
GQuark
...
...
@@ -117,7 +114,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
return
true
;
}
static
struct
e
ncoder
*
static
E
ncoder
*
vorbis_encoder_init
(
const
struct
config_param
*
param
,
GError
**
error
)
{
vorbis_encoder
*
encoder
=
new
vorbis_encoder
();
...
...
@@ -133,7 +130,7 @@ vorbis_encoder_init(const struct config_param *param, GError **error)
}
static
void
vorbis_encoder_finish
(
struct
e
ncoder
*
_encoder
)
vorbis_encoder_finish
(
E
ncoder
*
_encoder
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -204,7 +201,7 @@ vorbis_encoder_send_header(struct vorbis_encoder *encoder)
}
static
bool
vorbis_encoder_open
(
struct
e
ncoder
*
_encoder
,
vorbis_encoder_open
(
E
ncoder
*
_encoder
,
struct
audio_format
*
audio_format
,
GError
**
error
)
{
...
...
@@ -232,7 +229,7 @@ vorbis_encoder_clear(struct vorbis_encoder *encoder)
}
static
void
vorbis_encoder_close
(
struct
e
ncoder
*
_encoder
)
vorbis_encoder_close
(
E
ncoder
*
_encoder
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -253,7 +250,7 @@ vorbis_encoder_blockout(struct vorbis_encoder *encoder)
}
static
bool
vorbis_encoder_flush
(
struct
e
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
vorbis_encoder_flush
(
E
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -262,7 +259,7 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
}
static
bool
vorbis_encoder_pre_tag
(
struct
e
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
vorbis_encoder_pre_tag
(
E
ncoder
*
_encoder
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -292,7 +289,7 @@ copy_tag_to_vorbis_comment(vorbis_comment *vc, const struct tag *tag)
}
static
bool
vorbis_encoder_tag
(
struct
e
ncoder
*
_encoder
,
const
struct
tag
*
tag
,
vorbis_encoder_tag
(
E
ncoder
*
_encoder
,
const
struct
tag
*
tag
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -325,7 +322,7 @@ interleaved_to_vorbis_buffer(float **dest, const float *src,
}
static
bool
vorbis_encoder_write
(
struct
e
ncoder
*
_encoder
,
vorbis_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
data
,
size_t
length
,
G_GNUC_UNUSED
GError
**
error
)
{
...
...
@@ -348,7 +345,7 @@ vorbis_encoder_write(struct encoder *_encoder,
}
static
size_t
vorbis_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
vorbis_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
struct
vorbis_encoder
*
encoder
=
(
struct
vorbis_encoder
*
)
_encoder
;
...
...
@@ -356,12 +353,12 @@ vorbis_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
vorbis_encoder_get_mime_type
(
G_GNUC_UNUSED
struct
e
ncoder
*
_encoder
)
vorbis_encoder_get_mime_type
(
G_GNUC_UNUSED
E
ncoder
*
_encoder
)
{
return
"audio/ogg"
;
}
const
struct
encoder_p
lugin
vorbis_encoder_plugin
=
{
const
EncoderP
lugin
vorbis_encoder_plugin
=
{
"vorbis"
,
vorbis_encoder_init
,
vorbis_encoder_finish
,
...
...
src/encoder/VorbisEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_VORBIS_H
#define MPD_ENCODER_VORBIS_H
extern
const
struct
encoder_p
lugin
vorbis_encoder_plugin
;
extern
const
struct
EncoderP
lugin
vorbis_encoder_plugin
;
#endif
src/encoder/WaveEncoderPlugin.cxx
View file @
9a0061c5
...
...
@@ -19,8 +19,7 @@
#include "config.h"
#include "WaveEncoderPlugin.hxx"
#include "encoder_api.h"
#include "encoder_plugin.h"
#include "EncoderAPI.hxx"
#include "util/fifo_buffer.h"
extern
"C"
{
#include "util/growing_fifo.h"
...
...
@@ -32,14 +31,12 @@ extern "C" {
#include <string.h>
struct
WaveEncoder
{
struct
e
ncoder
encoder
;
E
ncoder
encoder
;
unsigned
bits
;
struct
fifo_buffer
*
buffer
;
WaveEncoder
()
{
encoder_struct_init
(
&
encoder
,
&
wave_encoder_plugin
);
}
WaveEncoder
()
:
encoder
(
wave_encoder_plugin
)
{}
};
struct
wave_header
{
...
...
@@ -58,8 +55,6 @@ struct wave_header {
uint32_t
data_size
;
};
extern
const
struct
encoder_plugin
wave_encoder_plugin
;
static
void
fill_wave_header
(
struct
wave_header
*
header
,
int
channels
,
int
bits
,
int
freq
,
int
block_size
)
...
...
@@ -87,7 +82,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits,
(
8
+
data_size
));
}
static
struct
e
ncoder
*
static
E
ncoder
*
wave_encoder_init
(
gcc_unused
const
struct
config_param
*
param
,
gcc_unused
GError
**
error
)
{
...
...
@@ -96,7 +91,7 @@ wave_encoder_init(gcc_unused const struct config_param *param,
}
static
void
wave_encoder_finish
(
struct
e
ncoder
*
_encoder
)
wave_encoder_finish
(
E
ncoder
*
_encoder
)
{
WaveEncoder
*
encoder
=
(
WaveEncoder
*
)
_encoder
;
...
...
@@ -104,7 +99,7 @@ wave_encoder_finish(struct encoder *_encoder)
}
static
bool
wave_encoder_open
(
struct
e
ncoder
*
_encoder
,
wave_encoder_open
(
E
ncoder
*
_encoder
,
gcc_unused
struct
audio_format
*
audio_format
,
gcc_unused
GError
**
error
)
{
...
...
@@ -151,7 +146,7 @@ wave_encoder_open(struct encoder *_encoder,
}
static
void
wave_encoder_close
(
struct
e
ncoder
*
_encoder
)
wave_encoder_close
(
E
ncoder
*
_encoder
)
{
WaveEncoder
*
encoder
=
(
WaveEncoder
*
)
_encoder
;
...
...
@@ -199,7 +194,7 @@ pcm24_to_wave(uint8_t *dst8, const uint32_t *src32, size_t length)
}
static
bool
wave_encoder_write
(
struct
e
ncoder
*
_encoder
,
wave_encoder_write
(
E
ncoder
*
_encoder
,
const
void
*
src
,
size_t
length
,
gcc_unused
GError
**
error
)
{
...
...
@@ -242,7 +237,7 @@ wave_encoder_write(struct encoder *_encoder,
}
static
size_t
wave_encoder_read
(
struct
e
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
wave_encoder_read
(
E
ncoder
*
_encoder
,
void
*
dest
,
size_t
length
)
{
WaveEncoder
*
encoder
=
(
WaveEncoder
*
)
_encoder
;
...
...
@@ -260,12 +255,12 @@ wave_encoder_read(struct encoder *_encoder, void *dest, size_t length)
}
static
const
char
*
wave_encoder_get_mime_type
(
gcc_unused
struct
e
ncoder
*
_encoder
)
wave_encoder_get_mime_type
(
gcc_unused
E
ncoder
*
_encoder
)
{
return
"audio/wav"
;
}
const
struct
encoder_p
lugin
wave_encoder_plugin
=
{
const
EncoderP
lugin
wave_encoder_plugin
=
{
"wave"
,
wave_encoder_init
,
wave_encoder_finish
,
...
...
src/encoder/WaveEncoderPlugin.hxx
View file @
9a0061c5
...
...
@@ -20,6 +20,6 @@
#ifndef MPD_ENCODER_WAVE_HXX
#define MPD_ENCODER_WAVE_HXX
extern
const
struct
encoder_p
lugin
wave_encoder_plugin
;
extern
const
struct
EncoderP
lugin
wave_encoder_plugin
;
#endif
src/output/HttpdInternal.hxx
View file @
9a0061c5
...
...
@@ -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
e
ncoder
*
encoder
;
E
ncoder
*
encoder
;
/**
* Number of bytes which were fed into the encoder, without
...
...
src/output/HttpdOutputPlugin.cxx
View file @
9a0061c5
...
...
@@ -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 */
...
...
src/output/RecorderOutputPlugin.cxx
View file @
9a0061c5
...
...
@@ -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
e
ncoder
*
encoder
;
E
ncoder
*
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
;
...
...
src/output/ShoutOutputPlugin.cxx
View file @
9a0061c5
...
...
@@ -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
e
ncoder
*
encoder
;
E
ncoder
*
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_p
lugin
*
static
const
EncoderP
lugin
*
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
))
{
...
...
test/run_encoder.cxx
View file @
9a0061c5
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "EncoderList.hxx"
#include "
encoder_plugin.h
"
#include "
EncoderPlugin.hxx
"
#include "audio_format.h"
#include "AudioParser.hxx"
#include "conf.h"
...
...
@@ -31,12 +31,12 @@
#include <unistd.h>
static
void
encoder_to_stdout
(
struct
encoder
*
encoder
)
encoder_to_stdout
(
Encoder
&
encoder
)
{
size_t
length
;
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
);
}
}
...
...
@@ -47,8 +47,6 @@ int main(int argc, char **argv)
struct
audio_format
audio_format
;
bool
ret
;
const
char
*
encoder_name
;
const
struct
encoder_plugin
*
plugin
;
struct
encoder
*
encoder
;
static
char
buffer
[
32768
];
/* parse command line */
...
...
@@ -67,7 +65,7 @@ int main(int argc, char **argv)
/* create the encoder */
plugin
=
encoder_plugin_get
(
encoder_name
);
const
auto
plugin
=
encoder_plugin_get
(
encoder_name
);
if
(
plugin
==
NULL
)
{
g_printerr
(
"No such encoder: %s
\n
"
,
encoder_name
);
return
1
;
...
...
@@ -76,7 +74,7 @@ int main(int argc, char **argv)
config_param
param
;
param
.
AddBlockParam
(
"quality"
,
"5.0"
,
-
1
);
encoder
=
encoder_init
(
plugin
,
&
param
,
&
error
);
const
auto
encoder
=
encoder_init
(
*
plugin
,
&
param
,
&
error
);
if
(
encoder
==
NULL
)
{
g_printerr
(
"Failed to initialize encoder: %s
\n
"
,
error
->
message
);
...
...
@@ -104,7 +102,7 @@ int main(int argc, char **argv)
return
1
;
}
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
/* do it */
...
...
@@ -118,7 +116,7 @@ int main(int argc, char **argv)
return
1
;
}
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
}
ret
=
encoder_end
(
encoder
,
&
error
);
...
...
@@ -129,5 +127,5 @@ int main(int argc, char **argv)
return
1
;
}
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
}
test/test_vorbis_encoder.cxx
View file @
9a0061c5
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "EncoderList.hxx"
#include "
encoder_plugin.h
"
#include "
EncoderPlugin.hxx
"
#include "audio_format.h"
#include "conf.h"
#include "stdbin.h"
...
...
@@ -33,12 +33,12 @@
static
uint8_t
zero
[
256
];
static
void
encoder_to_stdout
(
struct
encoder
*
encoder
)
encoder_to_stdout
(
Encoder
&
encoder
)
{
size_t
length
;
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
);
}
}
...
...
@@ -50,13 +50,13 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
/* create the encoder */
const
struct
encoder_plugin
*
plugin
=
encoder_plugin_get
(
"vorbis"
);
const
auto
plugin
=
encoder_plugin_get
(
"vorbis"
);
assert
(
plugin
!=
NULL
);
config_param
param
;
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
);
/* open the encoder */
...
...
@@ -67,21 +67,21 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
success
=
encoder_open
(
encoder
,
&
audio_format
,
NULL
);
assert
(
success
);
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
/* write a block of data */
success
=
encoder_write
(
encoder
,
zero
,
sizeof
(
zero
),
NULL
);
assert
(
success
);
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
/* write a tag */
success
=
encoder_pre_tag
(
encoder
,
NULL
);
assert
(
success
);
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
struct
tag
*
tag
=
tag_new
();
tag_add_item
(
tag
,
TAG_ARTIST
,
"Foo"
);
...
...
@@ -92,7 +92,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
tag_free
(
tag
);
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
/* write another block of data */
...
...
@@ -104,7 +104,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
success
=
encoder_end
(
encoder
,
NULL
);
assert
(
success
);
encoder_to_stdout
(
encoder
);
encoder_to_stdout
(
*
encoder
);
encoder_close
(
encoder
);
encoder_finish
(
encoder
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment