encoder/Interface: add noexcept
This commit is contained in:
parent
07080574a2
commit
8480b834b3
@ -33,11 +33,11 @@ class Encoder {
|
||||
const bool implements_tag;
|
||||
|
||||
public:
|
||||
explicit Encoder(bool _implements_tag)
|
||||
explicit Encoder(bool _implements_tag) noexcept
|
||||
:implements_tag(_implements_tag) {}
|
||||
virtual ~Encoder() {}
|
||||
virtual ~Encoder() noexcept {}
|
||||
|
||||
bool ImplementsTag() const {
|
||||
bool ImplementsTag() const noexcept {
|
||||
return implements_tag;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
|
||||
class PreparedEncoder {
|
||||
public:
|
||||
virtual ~PreparedEncoder() {}
|
||||
virtual ~PreparedEncoder() noexcept {}
|
||||
|
||||
/**
|
||||
* Opens the object. You must call this prior to using it.
|
||||
@ -134,7 +134,7 @@ public:
|
||||
*
|
||||
* @return an constant string, nullptr on failure
|
||||
*/
|
||||
virtual const char *GetMimeType() const {
|
||||
virtual const char *GetMimeType() const noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ class FlacEncoder final : public Encoder {
|
||||
public:
|
||||
FlacEncoder(AudioFormat _audio_format, FLAC__StreamEncoder *_fse);
|
||||
|
||||
~FlacEncoder() override {
|
||||
~FlacEncoder() noexcept override {
|
||||
FLAC__stream_encoder_delete(fse);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public:
|
||||
|
||||
void Write(const void *data, size_t length) override;
|
||||
|
||||
size_t Read(void *dest, size_t length) override {
|
||||
size_t Read(void *dest, size_t length) noexcept override {
|
||||
return output_buffer.Read((uint8_t *)dest, length);
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ private:
|
||||
size_t bytes,
|
||||
gcc_unused unsigned samples,
|
||||
gcc_unused unsigned current_frame,
|
||||
void *client_data) {
|
||||
void *client_data) noexcept {
|
||||
auto &encoder = *(FlacEncoder *)client_data;
|
||||
encoder.output_buffer.Append((const uint8_t *)data, bytes);
|
||||
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
||||
@ -88,7 +88,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/flac";
|
||||
}
|
||||
};
|
||||
@ -185,7 +185,7 @@ PreparedFlacEncoder::Open(AudioFormat &audio_format)
|
||||
}
|
||||
|
||||
static inline void
|
||||
pcm8_to_flac(int32_t *out, const int8_t *in, unsigned num_samples)
|
||||
pcm8_to_flac(int32_t *out, const int8_t *in, unsigned num_samples) noexcept
|
||||
{
|
||||
while (num_samples > 0) {
|
||||
*out++ = *in++;
|
||||
@ -194,7 +194,7 @@ pcm8_to_flac(int32_t *out, const int8_t *in, unsigned num_samples)
|
||||
}
|
||||
|
||||
static inline void
|
||||
pcm16_to_flac(int32_t *out, const int16_t *in, unsigned num_samples)
|
||||
pcm16_to_flac(int32_t *out, const int16_t *in, unsigned num_samples) noexcept
|
||||
{
|
||||
while (num_samples > 0) {
|
||||
*out++ = *in++;
|
||||
|
@ -42,15 +42,15 @@ class LameEncoder final : public Encoder {
|
||||
|
||||
public:
|
||||
LameEncoder(const AudioFormat _audio_format,
|
||||
lame_global_flags *_gfp)
|
||||
lame_global_flags *_gfp) noexcept
|
||||
:Encoder(false),
|
||||
audio_format(_audio_format), gfp(_gfp) {}
|
||||
|
||||
~LameEncoder() override;
|
||||
~LameEncoder() noexcept override;
|
||||
|
||||
/* virtual methods from class Encoder */
|
||||
void Write(const void *data, size_t length) override;
|
||||
size_t Read(void *dest, size_t length) override;
|
||||
size_t Read(void *dest, size_t length) noexcept override;
|
||||
};
|
||||
|
||||
class PreparedLameEncoder final : public PreparedEncoder {
|
||||
@ -63,7 +63,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/mpeg";
|
||||
}
|
||||
};
|
||||
@ -159,7 +159,7 @@ PreparedLameEncoder::Open(AudioFormat &audio_format)
|
||||
return new LameEncoder(audio_format, gfp);
|
||||
}
|
||||
|
||||
LameEncoder::~LameEncoder()
|
||||
LameEncoder::~LameEncoder() noexcept
|
||||
{
|
||||
lame_close(gfp);
|
||||
}
|
||||
@ -193,7 +193,7 @@ LameEncoder::Write(const void *data, size_t length)
|
||||
}
|
||||
|
||||
size_t
|
||||
LameEncoder::Read(void *dest, size_t length)
|
||||
LameEncoder::Read(void *dest, size_t length) noexcept
|
||||
{
|
||||
const auto begin = output_begin;
|
||||
assert(begin <= output_end);
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
flush = true;
|
||||
}
|
||||
|
||||
size_t Read(void *dest, size_t length) override {
|
||||
size_t Read(void *dest, size_t length) noexcept override {
|
||||
ogg_page page;
|
||||
bool success = stream.PageOut(page);
|
||||
if (!success) {
|
||||
|
@ -55,7 +55,7 @@ class OpusEncoder final : public OggEncoder {
|
||||
|
||||
public:
|
||||
OpusEncoder(AudioFormat &_audio_format, ::OpusEncoder *_enc, bool _chaining);
|
||||
~OpusEncoder() override;
|
||||
~OpusEncoder() noexcept override;
|
||||
|
||||
/* virtual methods from class Encoder */
|
||||
void End() override;
|
||||
@ -68,9 +68,9 @@ private:
|
||||
void DoEncode(bool eos);
|
||||
void WriteSilence(unsigned fill_frames);
|
||||
|
||||
void GenerateHeaders(const Tag *tag);
|
||||
void GenerateHead();
|
||||
void GenerateTags(const Tag *tag);
|
||||
void GenerateHeaders(const Tag *tag) noexcept;
|
||||
void GenerateHead() noexcept;
|
||||
void GenerateTags(const Tag *tag) noexcept;
|
||||
};
|
||||
|
||||
class PreparedOpusEncoder final : public PreparedEncoder {
|
||||
@ -85,7 +85,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/ogg";
|
||||
}
|
||||
};
|
||||
@ -178,7 +178,7 @@ PreparedOpusEncoder::Open(AudioFormat &audio_format)
|
||||
return new OpusEncoder(audio_format, enc, chaining);
|
||||
}
|
||||
|
||||
OpusEncoder::~OpusEncoder()
|
||||
OpusEncoder::~OpusEncoder() noexcept
|
||||
{
|
||||
delete[] buffer;
|
||||
opus_encoder_destroy(enc);
|
||||
@ -277,14 +277,14 @@ OpusEncoder::Write(const void *_data, size_t length)
|
||||
}
|
||||
|
||||
void
|
||||
OpusEncoder::GenerateHeaders(const Tag *tag)
|
||||
OpusEncoder::GenerateHeaders(const Tag *tag) noexcept
|
||||
{
|
||||
GenerateHead();
|
||||
GenerateTags(tag);
|
||||
}
|
||||
|
||||
void
|
||||
OpusEncoder::GenerateHead()
|
||||
OpusEncoder::GenerateHead() noexcept
|
||||
{
|
||||
unsigned char header[19];
|
||||
memcpy(header, "OpusHead", 8);
|
||||
@ -308,7 +308,7 @@ OpusEncoder::GenerateHead()
|
||||
}
|
||||
|
||||
void
|
||||
OpusEncoder::GenerateTags(const Tag *tag)
|
||||
OpusEncoder::GenerateTags(const Tag *tag) noexcept
|
||||
{
|
||||
const char *version = opus_get_version_string();
|
||||
size_t version_length = strlen(version);
|
||||
|
@ -48,14 +48,14 @@ class ShineEncoder final : public Encoder {
|
||||
DynamicFifoBuffer<uint8_t> output_buffer;
|
||||
|
||||
public:
|
||||
ShineEncoder(AudioFormat _audio_format, shine_t _shine)
|
||||
ShineEncoder(AudioFormat _audio_format, shine_t _shine) noexcept
|
||||
:Encoder(false),
|
||||
audio_format(_audio_format), shine(_shine),
|
||||
frame_size(shine_samples_per_pass(shine)),
|
||||
stereo{new int16_t[frame_size], new int16_t[frame_size]},
|
||||
output_buffer(BUFFER_INIT_SIZE) {}
|
||||
|
||||
~ShineEncoder() override {
|
||||
~ShineEncoder() noexcept override {
|
||||
if (input_pos > SHINE_MAX_SAMPLES) {
|
||||
/* write zero chunk */
|
||||
input_pos = 0;
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
void Write(const void *data, size_t length) override;
|
||||
|
||||
size_t Read(void *dest, size_t length) override {
|
||||
size_t Read(void *dest, size_t length) noexcept override {
|
||||
return output_buffer.Read((uint8_t *)dest, length);
|
||||
}
|
||||
};
|
||||
@ -92,7 +92,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/mpeg";
|
||||
}
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
twolame_options *_options)
|
||||
:Encoder(false),
|
||||
audio_format(_audio_format), options(_options) {}
|
||||
~TwolameEncoder() override;
|
||||
~TwolameEncoder() noexcept override;
|
||||
|
||||
/* virtual methods from class Encoder */
|
||||
|
||||
@ -66,7 +66,7 @@ public:
|
||||
}
|
||||
|
||||
void Write(const void *data, size_t length) override;
|
||||
size_t Read(void *dest, size_t length) override;
|
||||
size_t Read(void *dest, size_t length) noexcept override;
|
||||
};
|
||||
|
||||
class PreparedTwolameEncoder final : public PreparedEncoder {
|
||||
@ -79,7 +79,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/mpeg";
|
||||
}
|
||||
};
|
||||
@ -179,7 +179,7 @@ PreparedTwolameEncoder::Open(AudioFormat &audio_format)
|
||||
return new TwolameEncoder(audio_format, options);
|
||||
}
|
||||
|
||||
TwolameEncoder::~TwolameEncoder()
|
||||
TwolameEncoder::~TwolameEncoder() noexcept
|
||||
{
|
||||
twolame_close(&options);
|
||||
}
|
||||
@ -205,7 +205,7 @@ TwolameEncoder::Write(const void *data, size_t length)
|
||||
}
|
||||
|
||||
size_t
|
||||
TwolameEncoder::Read(void *dest, size_t length)
|
||||
TwolameEncoder::Read(void *dest, size_t length) noexcept
|
||||
{
|
||||
assert(output_buffer_position <= output_buffer_length);
|
||||
|
||||
|
@ -38,7 +38,7 @@ class VorbisEncoder final : public OggEncoder {
|
||||
public:
|
||||
VorbisEncoder(float quality, int bitrate, AudioFormat &_audio_format);
|
||||
|
||||
virtual ~VorbisEncoder() {
|
||||
~VorbisEncoder() noexcept override {
|
||||
vorbis_block_clear(&vb);
|
||||
vorbis_dsp_clear(&vd);
|
||||
vorbis_info_clear(&vi);
|
||||
@ -70,7 +70,7 @@ public:
|
||||
/* virtual methods from class PreparedEncoder */
|
||||
Encoder *Open(AudioFormat &audio_format) override;
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/ogg";
|
||||
}
|
||||
};
|
||||
|
@ -33,12 +33,12 @@ class WaveEncoder final : public Encoder {
|
||||
DynamicFifoBuffer<uint8_t> buffer;
|
||||
|
||||
public:
|
||||
WaveEncoder(AudioFormat &audio_format);
|
||||
WaveEncoder(AudioFormat &audio_format) noexcept;
|
||||
|
||||
/* virtual methods from class Encoder */
|
||||
void Write(const void *data, size_t length) override;
|
||||
|
||||
size_t Read(void *dest, size_t length) override {
|
||||
size_t Read(void *dest, size_t length) noexcept override {
|
||||
return buffer.Read((uint8_t *)dest, length);
|
||||
}
|
||||
};
|
||||
@ -49,7 +49,7 @@ class PreparedWaveEncoder final : public PreparedEncoder {
|
||||
return new WaveEncoder(audio_format);
|
||||
}
|
||||
|
||||
const char *GetMimeType() const override {
|
||||
const char *GetMimeType() const noexcept override {
|
||||
return "audio/wav";
|
||||
}
|
||||
};
|
||||
@ -72,7 +72,7 @@ struct WaveHeader {
|
||||
|
||||
static void
|
||||
fill_wave_header(WaveHeader *header, int channels, int bits,
|
||||
int freq, int block_size)
|
||||
int freq, int block_size) noexcept
|
||||
{
|
||||
int data_size = 0x0FFFFFFF;
|
||||
|
||||
@ -102,7 +102,7 @@ wave_encoder_init(gcc_unused const ConfigBlock &block)
|
||||
return new PreparedWaveEncoder();
|
||||
}
|
||||
|
||||
WaveEncoder::WaveEncoder(AudioFormat &audio_format)
|
||||
WaveEncoder::WaveEncoder(AudioFormat &audio_format) noexcept
|
||||
:Encoder(false),
|
||||
buffer(8192)
|
||||
{
|
||||
@ -157,7 +157,7 @@ pcm16_to_wave(uint16_t *dst16, const uint16_t *src16, size_t length)
|
||||
}
|
||||
|
||||
static size_t
|
||||
pcm32_to_wave(uint32_t *dst32, const uint32_t *src32, size_t length)
|
||||
pcm32_to_wave(uint32_t *dst32, const uint32_t *src32, size_t length) noexcept
|
||||
{
|
||||
size_t cnt = length >> 2;
|
||||
while (cnt > 0){
|
||||
@ -168,7 +168,7 @@ pcm32_to_wave(uint32_t *dst32, const uint32_t *src32, size_t length)
|
||||
}
|
||||
|
||||
static size_t
|
||||
pcm24_to_wave(uint8_t *dst8, const uint32_t *src32, size_t length)
|
||||
pcm24_to_wave(uint8_t *dst8, const uint32_t *src32, size_t length) noexcept
|
||||
{
|
||||
uint32_t value;
|
||||
uint8_t *dst_old = dst8;
|
||||
|
Loading…
Reference in New Issue
Block a user