aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-15 20:18:54 +0100
committerMax Kellermann <max@duempel.org>2013-01-15 20:20:51 +0100
commit4808c7ef394ff130400a1a0be42f26efa8e953eb (patch)
tree5bd1c61b6bcce06abb70afc9cd8b9c335af4f041 /src
parent707112677065dd59f638764bb9dbd64d200b8a85 (diff)
downloadmpd-4808c7ef394ff130400a1a0be42f26efa8e953eb.tar.gz
mpd-4808c7ef394ff130400a1a0be42f26efa8e953eb.tar.xz
mpd-4808c7ef394ff130400a1a0be42f26efa8e953eb.zip
encoder/{Vorbis,Opus}: use new/delete
Diffstat (limited to 'src')
-rw-r--r--src/encoder/OpusEncoderPlugin.cxx13
-rw-r--r--src/encoder/VorbisEncoderPlugin.cxx11
2 files changed, 14 insertions, 10 deletions
diff --git a/src/encoder/OpusEncoderPlugin.cxx b/src/encoder/OpusEncoderPlugin.cxx
index 9f46e8681..53d16a8e4 100644
--- a/src/encoder/OpusEncoderPlugin.cxx
+++ b/src/encoder/OpusEncoderPlugin.cxx
@@ -67,6 +67,10 @@ struct opus_encoder {
ogg_int64_t packetno;
ogg_int64_t granulepos;
+
+ opus_encoder() {
+ encoder_struct_init(&encoder, &opus_encoder_plugin);
+ }
};
gcc_const
@@ -123,15 +127,12 @@ opus_encoder_configure(struct opus_encoder *encoder,
static struct encoder *
opus_encoder_init(const struct config_param *param, GError **error)
{
- struct opus_encoder *encoder;
-
- encoder = g_new(struct opus_encoder, 1);
- encoder_struct_init(&encoder->encoder, &opus_encoder_plugin);
+ opus_encoder *encoder = new opus_encoder();
/* load configuration from "param" */
if (!opus_encoder_configure(encoder, param, error)) {
/* configuration has failed, roll back and return error */
- g_free(encoder);
+ delete encoder;
return NULL;
}
@@ -145,7 +146,7 @@ opus_encoder_finish(struct encoder *_encoder)
/* the real libopus cleanup was already performed by
opus_encoder_close(), so no real work here */
- g_free(encoder);
+ delete encoder;
}
static bool
diff --git a/src/encoder/VorbisEncoderPlugin.cxx b/src/encoder/VorbisEncoderPlugin.cxx
index bc0f47fd0..74048e0cd 100644
--- a/src/encoder/VorbisEncoderPlugin.cxx
+++ b/src/encoder/VorbisEncoderPlugin.cxx
@@ -55,6 +55,10 @@ struct vorbis_encoder {
vorbis_info vi;
OggStream stream;
+
+ vorbis_encoder() {
+ encoder_struct_init(&encoder, &vorbis_encoder_plugin);
+ }
};
static inline GQuark
@@ -120,13 +124,12 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
static struct encoder *
vorbis_encoder_init(const struct config_param *param, GError **error)
{
- struct vorbis_encoder *encoder = g_new(struct vorbis_encoder, 1);
- encoder_struct_init(&encoder->encoder, &vorbis_encoder_plugin);
+ vorbis_encoder *encoder = new vorbis_encoder();
/* load configuration from "param" */
if (!vorbis_encoder_configure(encoder, param, error)) {
/* configuration has failed, roll back and return error */
- g_free(encoder);
+ delete encoder;
return nullptr;
}
@@ -140,7 +143,7 @@ vorbis_encoder_finish(struct encoder *_encoder)
/* the real libvorbis/libogg cleanup was already performed by
vorbis_encoder_close(), so no real work here */
- g_free(encoder);
+ delete encoder;
}
static bool