diff options
Diffstat (limited to '')
19 files changed, 131 insertions, 133 deletions
diff --git a/src/encoder/plugins/FlacEncoderPlugin.cxx b/src/encoder/plugins/FlacEncoderPlugin.cxx index 26987fe99..afeef3b84 100644 --- a/src/encoder/plugins/FlacEncoderPlugin.cxx +++ b/src/encoder/plugins/FlacEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -56,21 +56,21 @@ struct flac_encoder { static constexpr Domain flac_encoder_domain("vorbis_encoder"); static bool -flac_encoder_configure(struct flac_encoder *encoder, const config_param ¶m, +flac_encoder_configure(struct flac_encoder *encoder, const ConfigBlock &block, gcc_unused Error &error) { - encoder->compression = param.GetBlockValue("compression", 5u); + encoder->compression = block.GetBlockValue("compression", 5u); return true; } static Encoder * -flac_encoder_init(const config_param ¶m, Error &error) +flac_encoder_init(const ConfigBlock &block, Error &error) { flac_encoder *encoder = new flac_encoder(); - /* load configuration from "param" */ - if (!flac_encoder_configure(encoder, param, error)) { + /* load configuration from "block" */ + if (!flac_encoder_configure(encoder, block, error)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; diff --git a/src/encoder/plugins/FlacEncoderPlugin.hxx b/src/encoder/plugins/FlacEncoderPlugin.hxx index 0cdc01600..dcd899974 100644 --- a/src/encoder/plugins/FlacEncoderPlugin.hxx +++ b/src/encoder/plugins/FlacEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/LameEncoderPlugin.cxx b/src/encoder/plugins/LameEncoderPlugin.cxx index 3878b52bb..7c6313109 100644 --- a/src/encoder/plugins/LameEncoderPlugin.cxx +++ b/src/encoder/plugins/LameEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -47,18 +47,18 @@ struct LameEncoder final { LameEncoder():encoder(lame_encoder_plugin) {} - bool Configure(const config_param ¶m, Error &error); + bool Configure(const ConfigBlock &block, Error &error); }; static constexpr Domain lame_encoder_domain("lame_encoder"); bool -LameEncoder::Configure(const config_param ¶m, Error &error) +LameEncoder::Configure(const ConfigBlock &block, Error &error) { const char *value; char *endptr; - value = param.GetBlockValue("quality"); + value = block.GetBlockValue("quality"); if (value != nullptr) { /* a quality was configured (VBR) */ @@ -72,7 +72,7 @@ LameEncoder::Configure(const config_param ¶m, Error &error) return false; } - if (param.GetBlockValue("bitrate") != nullptr) { + if (block.GetBlockValue("bitrate") != nullptr) { error.Set(config_domain, "quality and bitrate are both defined"); return false; @@ -80,7 +80,7 @@ LameEncoder::Configure(const config_param ¶m, Error &error) } else { /* a bit rate was configured */ - value = param.GetBlockValue("bitrate"); + value = block.GetBlockValue("bitrate"); if (value == nullptr) { error.Set(config_domain, "neither bitrate nor quality defined"); @@ -101,12 +101,12 @@ LameEncoder::Configure(const config_param ¶m, Error &error) } static Encoder * -lame_encoder_init(const config_param ¶m, Error &error) +lame_encoder_init(const ConfigBlock &block, Error &error) { LameEncoder *encoder = new LameEncoder(); - /* load configuration from "param" */ - if (!encoder->Configure(param, error)) { + /* load configuration from "block" */ + if (!encoder->Configure(block, error)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; diff --git a/src/encoder/plugins/LameEncoderPlugin.hxx b/src/encoder/plugins/LameEncoderPlugin.hxx index 03e398f67..5a077f7cc 100644 --- a/src/encoder/plugins/LameEncoderPlugin.hxx +++ b/src/encoder/plugins/LameEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/NullEncoderPlugin.cxx b/src/encoder/plugins/NullEncoderPlugin.cxx index 1d571d465..99be7aec4 100644 --- a/src/encoder/plugins/NullEncoderPlugin.cxx +++ b/src/encoder/plugins/NullEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -36,7 +36,7 @@ struct NullEncoder final { }; static Encoder * -null_encoder_init(gcc_unused const config_param ¶m, +null_encoder_init(gcc_unused const ConfigBlock &block, gcc_unused Error &error) { NullEncoder *encoder = new NullEncoder(); diff --git a/src/encoder/plugins/NullEncoderPlugin.hxx b/src/encoder/plugins/NullEncoderPlugin.hxx index 6acf88e49..9fabe81fd 100644 --- a/src/encoder/plugins/NullEncoderPlugin.hxx +++ b/src/encoder/plugins/NullEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/OggSerial.cxx b/src/encoder/plugins/OggSerial.cxx index 677829439..639d2b3c1 100644 --- a/src/encoder/plugins/OggSerial.cxx +++ b/src/encoder/plugins/OggSerial.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/OggSerial.hxx b/src/encoder/plugins/OggSerial.hxx index ceba8ebf9..21ae02804 100644 --- a/src/encoder/plugins/OggSerial.hxx +++ b/src/encoder/plugins/OggSerial.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/OggStream.hxx b/src/encoder/plugins/OggStream.hxx index 805238c1d..376a697a1 100644 --- a/src/encoder/plugins/OggStream.hxx +++ b/src/encoder/plugins/OggStream.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/OpusEncoderPlugin.cxx b/src/encoder/plugins/OpusEncoderPlugin.cxx index 27b614b86..4fd40cd50 100644 --- a/src/encoder/plugins/OpusEncoderPlugin.cxx +++ b/src/encoder/plugins/OpusEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -73,9 +73,9 @@ static constexpr Domain opus_encoder_domain("opus_encoder"); static bool opus_encoder_configure(struct opus_encoder *encoder, - const config_param ¶m, Error &error) + const ConfigBlock &block, Error &error) { - const char *value = param.GetBlockValue("bitrate", "auto"); + const char *value = block.GetBlockValue("bitrate", "auto"); if (strcmp(value, "auto") == 0) encoder->bitrate = OPUS_AUTO; else if (strcmp(value, "max") == 0) @@ -90,13 +90,13 @@ opus_encoder_configure(struct opus_encoder *encoder, } } - encoder->complexity = param.GetBlockValue("complexity", 10u); + encoder->complexity = block.GetBlockValue("complexity", 10u); if (encoder->complexity > 10) { error.Format(config_domain, "Invalid complexity"); return false; } - value = param.GetBlockValue("signal", "auto"); + value = block.GetBlockValue("signal", "auto"); if (strcmp(value, "auto") == 0) encoder->signal = OPUS_AUTO; else if (strcmp(value, "voice") == 0) @@ -112,12 +112,12 @@ opus_encoder_configure(struct opus_encoder *encoder, } static Encoder * -opus_encoder_init(const config_param ¶m, Error &error) +opus_encoder_init(const ConfigBlock &block, Error &error) { opus_encoder *encoder = new opus_encoder(); - /* load configuration from "param" */ - if (!opus_encoder_configure(encoder, param, error)) { + /* load configuration from "block" */ + if (!opus_encoder_configure(encoder, block, error)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; diff --git a/src/encoder/plugins/OpusEncoderPlugin.hxx b/src/encoder/plugins/OpusEncoderPlugin.hxx index 4e71694b9..09067e37d 100644 --- a/src/encoder/plugins/OpusEncoderPlugin.hxx +++ b/src/encoder/plugins/OpusEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/ShineEncoderPlugin.cxx b/src/encoder/plugins/ShineEncoderPlugin.cxx index 61cb8609e..c397906d3 100644 --- a/src/encoder/plugins/ShineEncoderPlugin.cxx +++ b/src/encoder/plugins/ShineEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ struct ShineEncoder { ShineEncoder():encoder(shine_encoder_plugin){} - bool Configure(const config_param ¶m, Error &error); + bool Configure(const ConfigBlock &block, Error &error); bool Setup(Error &error); @@ -63,22 +63,21 @@ struct ShineEncoder { static constexpr Domain shine_encoder_domain("shine_encoder"); inline bool -ShineEncoder::Configure(const config_param ¶m, - gcc_unused Error &error) +ShineEncoder::Configure(const ConfigBlock &block, gcc_unused Error &error) { shine_set_config_mpeg_defaults(&config.mpeg); - config.mpeg.bitr = param.GetBlockValue("bitrate", 128); + config.mpeg.bitr = block.GetBlockValue("bitrate", 128); return true; } static Encoder * -shine_encoder_init(const config_param ¶m, Error &error) +shine_encoder_init(const ConfigBlock &block, Error &error) { ShineEncoder *encoder = new ShineEncoder(); - /* load configuration from "param" */ - if (!encoder->Configure(param, error)) { + /* load configuration from "block" */ + if (!encoder->Configure(block, error)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; diff --git a/src/encoder/plugins/ShineEncoderPlugin.hxx b/src/encoder/plugins/ShineEncoderPlugin.hxx index 8b1520a74..ecde902fb 100644 --- a/src/encoder/plugins/ShineEncoderPlugin.hxx +++ b/src/encoder/plugins/ShineEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/TwolameEncoderPlugin.cxx b/src/encoder/plugins/TwolameEncoderPlugin.cxx index 2eb6b2b1c..262fc6c33 100644 --- a/src/encoder/plugins/TwolameEncoderPlugin.cxx +++ b/src/encoder/plugins/TwolameEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -53,18 +53,18 @@ struct TwolameEncoder final { TwolameEncoder():encoder(twolame_encoder_plugin) {} - bool Configure(const config_param ¶m, Error &error); + bool Configure(const ConfigBlock &block, Error &error); }; static constexpr Domain twolame_encoder_domain("twolame_encoder"); bool -TwolameEncoder::Configure(const config_param ¶m, Error &error) +TwolameEncoder::Configure(const ConfigBlock &block, Error &error) { const char *value; char *endptr; - value = param.GetBlockValue("quality"); + value = block.GetBlockValue("quality"); if (value != nullptr) { /* a quality was configured (VBR) */ @@ -78,7 +78,7 @@ TwolameEncoder::Configure(const config_param ¶m, Error &error) return false; } - if (param.GetBlockValue("bitrate") != nullptr) { + if (block.GetBlockValue("bitrate") != nullptr) { error.Set(config_domain, "quality and bitrate are both defined"); return false; @@ -86,7 +86,7 @@ TwolameEncoder::Configure(const config_param ¶m, Error &error) } else { /* a bit rate was configured */ - value = param.GetBlockValue("bitrate"); + value = block.GetBlockValue("bitrate"); if (value == nullptr) { error.Set(config_domain, "neither bitrate nor quality defined"); @@ -107,15 +107,15 @@ TwolameEncoder::Configure(const config_param ¶m, Error &error) } static Encoder * -twolame_encoder_init(const config_param ¶m, Error &error_r) +twolame_encoder_init(const ConfigBlock &block, Error &error_r) { FormatDebug(twolame_encoder_domain, "libtwolame version %s", get_twolame_version()); TwolameEncoder *encoder = new TwolameEncoder(); - /* load configuration from "param" */ - if (!encoder->Configure(param, error_r)) { + /* load configuration from "block" */ + if (!encoder->Configure(block, error_r)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; diff --git a/src/encoder/plugins/TwolameEncoderPlugin.hxx b/src/encoder/plugins/TwolameEncoderPlugin.hxx index 531dd3e90..2c0b250da 100644 --- a/src/encoder/plugins/TwolameEncoderPlugin.hxx +++ b/src/encoder/plugins/TwolameEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/VorbisEncoderPlugin.cxx b/src/encoder/plugins/VorbisEncoderPlugin.cxx index ecc784a47..11e057eaa 100644 --- a/src/encoder/plugins/VorbisEncoderPlugin.cxx +++ b/src/encoder/plugins/VorbisEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -25,14 +25,13 @@ #include "tag/Tag.hxx" #include "AudioFormat.hxx" #include "config/ConfigError.hxx" +#include "util/StringUtil.hxx" #include "util/NumberParser.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include <vorbis/vorbisenc.h> -#include <glib.h> - struct vorbis_encoder { /** the base class */ Encoder encoder; @@ -58,18 +57,18 @@ struct vorbis_encoder { static constexpr Domain vorbis_encoder_domain("vorbis_encoder"); static bool -vorbis_encoder_configure(struct vorbis_encoder *encoder, - const config_param ¶m, Error &error) +vorbis_encoder_configure(struct vorbis_encoder &encoder, + const ConfigBlock &block, Error &error) { - const char *value = param.GetBlockValue("quality"); + const char *value = block.GetBlockValue("quality"); if (value != nullptr) { /* a quality was configured (VBR) */ char *endptr; - encoder->quality = ParseDouble(value, &endptr); + encoder.quality = ParseDouble(value, &endptr); - if (*endptr != '\0' || encoder->quality < -1.0 || - encoder->quality > 10.0) { + if (*endptr != '\0' || encoder.quality < -1.0 || + encoder.quality > 10.0) { error.Format(config_domain, "quality \"%s\" is not a number in the " "range -1 to 10", @@ -77,7 +76,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder, return false; } - if (param.GetBlockValue("bitrate") != nullptr) { + if (block.GetBlockValue("bitrate") != nullptr) { error.Set(config_domain, "quality and bitrate are both defined"); return false; @@ -85,18 +84,18 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder, } else { /* a bit rate was configured */ - value = param.GetBlockValue("bitrate"); + value = block.GetBlockValue("bitrate"); if (value == nullptr) { error.Set(config_domain, "neither bitrate nor quality defined"); return false; } - encoder->quality = -2.0; + encoder.quality = -2.0; char *endptr; - encoder->bitrate = ParseInt(value, &endptr); - if (*endptr != '\0' || encoder->bitrate <= 0) { + encoder.bitrate = ParseInt(value, &endptr); + if (*endptr != '\0' || encoder.bitrate <= 0) { error.Set(config_domain, "bitrate should be a positive integer"); return false; @@ -107,12 +106,12 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder, } static Encoder * -vorbis_encoder_init(const config_param ¶m, Error &error) +vorbis_encoder_init(const ConfigBlock &block, Error &error) { vorbis_encoder *encoder = new vorbis_encoder(); - /* load configuration from "param" */ - if (!vorbis_encoder_configure(encoder, param, error)) { + /* load configuration from "block" */ + if (!vorbis_encoder_configure(*encoder, block, error)) { /* configuration has failed, roll back and return error */ delete encoder; return nullptr; @@ -132,63 +131,63 @@ vorbis_encoder_finish(Encoder *_encoder) } static bool -vorbis_encoder_reinit(struct vorbis_encoder *encoder, Error &error) +vorbis_encoder_reinit(struct vorbis_encoder &encoder, Error &error) { - vorbis_info_init(&encoder->vi); + vorbis_info_init(&encoder.vi); - if (encoder->quality >= -1.0) { + if (encoder.quality >= -1.0) { /* a quality was configured (VBR) */ - if (0 != vorbis_encode_init_vbr(&encoder->vi, - encoder->audio_format.channels, - encoder->audio_format.sample_rate, - encoder->quality * 0.1)) { + if (0 != vorbis_encode_init_vbr(&encoder.vi, + encoder.audio_format.channels, + encoder.audio_format.sample_rate, + encoder.quality * 0.1)) { error.Set(vorbis_encoder_domain, "error initializing vorbis vbr"); - vorbis_info_clear(&encoder->vi); + vorbis_info_clear(&encoder.vi); return false; } } else { /* a bit rate was configured */ - if (0 != vorbis_encode_init(&encoder->vi, - encoder->audio_format.channels, - encoder->audio_format.sample_rate, -1.0, - encoder->bitrate * 1000, -1.0)) { + if (0 != vorbis_encode_init(&encoder.vi, + encoder.audio_format.channels, + encoder.audio_format.sample_rate, -1.0, + encoder.bitrate * 1000, -1.0)) { error.Set(vorbis_encoder_domain, "error initializing vorbis encoder"); - vorbis_info_clear(&encoder->vi); + vorbis_info_clear(&encoder.vi); return false; } } - vorbis_analysis_init(&encoder->vd, &encoder->vi); - vorbis_block_init(&encoder->vd, &encoder->vb); - encoder->stream.Initialize(GenerateOggSerial()); + vorbis_analysis_init(&encoder.vd, &encoder.vi); + vorbis_block_init(&encoder.vd, &encoder.vb); + encoder.stream.Initialize(GenerateOggSerial()); return true; } static void -vorbis_encoder_headerout(struct vorbis_encoder *encoder, vorbis_comment *vc) +vorbis_encoder_headerout(struct vorbis_encoder &encoder, vorbis_comment &vc) { ogg_packet packet, comments, codebooks; - vorbis_analysis_headerout(&encoder->vd, vc, + vorbis_analysis_headerout(&encoder.vd, &vc, &packet, &comments, &codebooks); - encoder->stream.PacketIn(packet); - encoder->stream.PacketIn(comments); - encoder->stream.PacketIn(codebooks); + encoder.stream.PacketIn(packet); + encoder.stream.PacketIn(comments); + encoder.stream.PacketIn(codebooks); } static void -vorbis_encoder_send_header(struct vorbis_encoder *encoder) +vorbis_encoder_send_header(struct vorbis_encoder &encoder) { vorbis_comment vc; vorbis_comment_init(&vc); - vorbis_encoder_headerout(encoder, &vc); + vorbis_encoder_headerout(encoder, vc); vorbis_comment_clear(&vc); } @@ -197,11 +196,11 @@ vorbis_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; audio_format.format = SampleFormat::FLOAT; - encoder->audio_format = audio_format; + encoder.audio_format = audio_format; if (!vorbis_encoder_reinit(encoder, error)) return false; @@ -212,78 +211,78 @@ vorbis_encoder_open(Encoder *_encoder, } static void -vorbis_encoder_clear(struct vorbis_encoder *encoder) +vorbis_encoder_clear(struct vorbis_encoder &encoder) { - encoder->stream.Deinitialize(); - vorbis_block_clear(&encoder->vb); - vorbis_dsp_clear(&encoder->vd); - vorbis_info_clear(&encoder->vi); + encoder.stream.Deinitialize(); + vorbis_block_clear(&encoder.vb); + vorbis_dsp_clear(&encoder.vd); + vorbis_info_clear(&encoder.vi); } static void vorbis_encoder_close(Encoder *_encoder) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; vorbis_encoder_clear(encoder); } static void -vorbis_encoder_blockout(struct vorbis_encoder *encoder) +vorbis_encoder_blockout(struct vorbis_encoder &encoder) { - while (vorbis_analysis_blockout(&encoder->vd, &encoder->vb) == 1) { - vorbis_analysis(&encoder->vb, nullptr); - vorbis_bitrate_addblock(&encoder->vb); + while (vorbis_analysis_blockout(&encoder.vd, &encoder.vb) == 1) { + vorbis_analysis(&encoder.vb, nullptr); + vorbis_bitrate_addblock(&encoder.vb); ogg_packet packet; - while (vorbis_bitrate_flushpacket(&encoder->vd, &packet)) - encoder->stream.PacketIn(packet); + while (vorbis_bitrate_flushpacket(&encoder.vd, &packet)) + encoder.stream.PacketIn(packet); } } static bool vorbis_encoder_flush(Encoder *_encoder, gcc_unused Error &error) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; - encoder->stream.Flush(); + encoder.stream.Flush(); return true; } static bool vorbis_encoder_pre_tag(Encoder *_encoder, gcc_unused Error &error) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; - vorbis_analysis_wrote(&encoder->vd, 0); + vorbis_analysis_wrote(&encoder.vd, 0); vorbis_encoder_blockout(encoder); /* reinitialize vorbis_dsp_state and vorbis_block to reset the end-of-stream marker */ - vorbis_block_clear(&encoder->vb); - vorbis_dsp_clear(&encoder->vd); - vorbis_analysis_init(&encoder->vd, &encoder->vi); - vorbis_block_init(&encoder->vd, &encoder->vb); + vorbis_block_clear(&encoder.vb); + vorbis_dsp_clear(&encoder.vd); + vorbis_analysis_init(&encoder.vd, &encoder.vi); + vorbis_block_init(&encoder.vd, &encoder.vb); - encoder->stream.Flush(); + encoder.stream.Flush(); return true; } static void -copy_tag_to_vorbis_comment(vorbis_comment *vc, const Tag *tag) +copy_tag_to_vorbis_comment(vorbis_comment *vc, const Tag &tag) { - for (const auto &item : *tag) { - char *name = g_ascii_strup(tag_item_names[item.type], -1); + for (const auto &item : tag) { + char name[64]; + ToUpperASCII(name, tag_item_names[item.type], sizeof(name)); vorbis_comment_add_tag(vc, name, item.value); - g_free(name); } } static bool -vorbis_encoder_tag(Encoder *_encoder, const Tag *tag, +vorbis_encoder_tag(Encoder *_encoder, const Tag &tag, gcc_unused Error &error) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; vorbis_comment comment; /* write the vorbis_comment object */ @@ -293,11 +292,11 @@ vorbis_encoder_tag(Encoder *_encoder, const Tag *tag, /* reset ogg_stream_state and begin a new stream */ - encoder->stream.Reinitialize(GenerateOggSerial()); + encoder.stream.Reinitialize(GenerateOggSerial()); /* send that vorbis_comment to the ogg_stream_state */ - vorbis_encoder_headerout(encoder, &comment); + vorbis_encoder_headerout(encoder, comment); vorbis_comment_clear(&comment); return true; @@ -317,19 +316,19 @@ vorbis_encoder_write(Encoder *_encoder, const void *data, size_t length, gcc_unused Error &error) { - struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; + struct vorbis_encoder &encoder = *(struct vorbis_encoder *)_encoder; - unsigned num_frames = length / encoder->audio_format.GetFrameSize(); + unsigned num_frames = length / encoder.audio_format.GetFrameSize(); /* this is for only 16-bit audio */ - interleaved_to_vorbis_buffer(vorbis_analysis_buffer(&encoder->vd, + interleaved_to_vorbis_buffer(vorbis_analysis_buffer(&encoder.vd, num_frames), (const float *)data, num_frames, - encoder->audio_format.channels); + encoder.audio_format.channels); - vorbis_analysis_wrote(&encoder->vd, num_frames); + vorbis_analysis_wrote(&encoder.vd, num_frames); vorbis_encoder_blockout(encoder); return true; } @@ -337,9 +336,9 @@ vorbis_encoder_write(Encoder *_encoder, static size_t 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; - return encoder->stream.PageOut(dest, length); + return encoder.stream.PageOut(dest, length); } static const char * diff --git a/src/encoder/plugins/VorbisEncoderPlugin.hxx b/src/encoder/plugins/VorbisEncoderPlugin.hxx index 80703bf88..a6d1c46d2 100644 --- a/src/encoder/plugins/VorbisEncoderPlugin.hxx +++ b/src/encoder/plugins/VorbisEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify diff --git a/src/encoder/plugins/WaveEncoderPlugin.cxx b/src/encoder/plugins/WaveEncoderPlugin.cxx index 97a26e821..3493bed3a 100644 --- a/src/encoder/plugins/WaveEncoderPlugin.cxx +++ b/src/encoder/plugins/WaveEncoderPlugin.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -79,7 +79,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits, } static Encoder * -wave_encoder_init(gcc_unused const config_param ¶m, +wave_encoder_init(gcc_unused const ConfigBlock &block, gcc_unused Error &error) { WaveEncoder *encoder = new WaveEncoder(); diff --git a/src/encoder/plugins/WaveEncoderPlugin.hxx b/src/encoder/plugins/WaveEncoderPlugin.hxx index 341b98adc..878985612 100644 --- a/src/encoder/plugins/WaveEncoderPlugin.hxx +++ b/src/encoder/plugins/WaveEncoderPlugin.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify |