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