*: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to consider these functions throwing.
This commit is contained in:
@@ -57,7 +57,7 @@ PcmChannelsConverter::Close()
|
||||
}
|
||||
|
||||
ConstBuffer<void>
|
||||
PcmChannelsConverter::Convert(ConstBuffer<void> src)
|
||||
PcmChannelsConverter::Convert(ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
|
@@ -75,7 +75,7 @@ public:
|
||||
* @return the destination buffer
|
||||
*/
|
||||
gcc_pure
|
||||
ConstBuffer<void> Convert(ConstBuffer<void> src);
|
||||
ConstBuffer<void> Convert(ConstBuffer<void> src) noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -37,7 +37,7 @@ struct FloatToIntegerSampleConvert {
|
||||
static constexpr SV factor = 1 << (DstTraits::BITS - 1);
|
||||
|
||||
gcc_const
|
||||
static DV Convert(SV src) {
|
||||
static DV Convert(SV src) noexcept {
|
||||
return PcmClamp<F, Traits>(SL(src * factor));
|
||||
}
|
||||
};
|
||||
@@ -56,7 +56,7 @@ struct IntegerToFloatSampleConvert {
|
||||
static constexpr DV factor = 0.5 / (1 << (SrcTraits::BITS - 2));
|
||||
|
||||
gcc_const
|
||||
static DV Convert(SV src) {
|
||||
static DV Convert(SV src) noexcept {
|
||||
return DV(src) * factor;
|
||||
}
|
||||
};
|
||||
|
@@ -54,7 +54,7 @@ PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format)
|
||||
}
|
||||
|
||||
void
|
||||
PcmFormatConverter::Close()
|
||||
PcmFormatConverter::Close() noexcept
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
src_format = SampleFormat::UNDEFINED;
|
||||
@@ -63,7 +63,7 @@ PcmFormatConverter::Close()
|
||||
}
|
||||
|
||||
ConstBuffer<void>
|
||||
PcmFormatConverter::Convert(ConstBuffer<void> src)
|
||||
PcmFormatConverter::Convert(ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (dest_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
|
@@ -65,18 +65,16 @@ public:
|
||||
/**
|
||||
* Closes the object. After that, you may call Open() again.
|
||||
*/
|
||||
void Close();
|
||||
void Close() noexcept;
|
||||
|
||||
/**
|
||||
* Convert a block of PCM data.
|
||||
*
|
||||
* Throws std::runtime_error on error.
|
||||
*
|
||||
* @param src the input buffer
|
||||
* @return the destination buffer
|
||||
*/
|
||||
gcc_pure
|
||||
ConstBuffer<void> Convert(ConstBuffer<void> src);
|
||||
ConstBuffer<void> Convert(ConstBuffer<void> src) noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -84,7 +84,7 @@ PcmExport::Open(SampleFormat sample_format, unsigned _channels,
|
||||
}
|
||||
|
||||
size_t
|
||||
PcmExport::GetFrameSize(const AudioFormat &audio_format) const
|
||||
PcmExport::GetFrameSize(const AudioFormat &audio_format) const noexcept
|
||||
{
|
||||
if (pack24)
|
||||
/* packed 24 bit samples (3 bytes per sample) */
|
||||
@@ -109,7 +109,7 @@ PcmExport::GetFrameSize(const AudioFormat &audio_format) const
|
||||
}
|
||||
|
||||
unsigned
|
||||
PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const
|
||||
PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const noexcept
|
||||
{
|
||||
#ifdef ENABLE_DSD
|
||||
if (dsd_u16)
|
||||
@@ -132,7 +132,7 @@ PcmExport::Params::CalcOutputSampleRate(unsigned sample_rate) const
|
||||
}
|
||||
|
||||
unsigned
|
||||
PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const
|
||||
PcmExport::Params::CalcInputSampleRate(unsigned sample_rate) const noexcept
|
||||
{
|
||||
#ifdef ENABLE_DSD
|
||||
if (dsd_u16)
|
||||
@@ -209,7 +209,7 @@ PcmExport::Export(ConstBuffer<void> data)
|
||||
}
|
||||
|
||||
size_t
|
||||
PcmExport::CalcSourceSize(size_t size) const
|
||||
PcmExport::CalcSourceSize(size_t size) const noexcept
|
||||
{
|
||||
if (pack24)
|
||||
/* 32 bit to 24 bit conversion (4 to 3 bytes) */
|
||||
|
@@ -135,13 +135,13 @@ public:
|
||||
* one output word (32 bits), dividing the sample rate by 4.
|
||||
*/
|
||||
gcc_pure
|
||||
unsigned CalcOutputSampleRate(unsigned input_sample_rate) const;
|
||||
unsigned CalcOutputSampleRate(unsigned input_sample_rate) const noexcept;
|
||||
|
||||
/**
|
||||
* The inverse of CalcOutputSampleRate().
|
||||
*/
|
||||
gcc_pure
|
||||
unsigned CalcInputSampleRate(unsigned output_sample_rate) const;
|
||||
unsigned CalcInputSampleRate(unsigned output_sample_rate) const noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
* Calculate the size of one output frame.
|
||||
*/
|
||||
gcc_pure
|
||||
size_t GetFrameSize(const AudioFormat &audio_format) const;
|
||||
size_t GetFrameSize(const AudioFormat &audio_format) const noexcept;
|
||||
|
||||
/**
|
||||
* Export a PCM buffer.
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
* pcm_export() source buffer.
|
||||
*/
|
||||
gcc_pure
|
||||
size_t CalcSourceSize(size_t dest_size) const;
|
||||
size_t CalcSourceSize(size_t dest_size) const noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -161,7 +161,7 @@ pcm_allocate_float_to_16(PcmBuffer &buffer, ConstBuffer<float> src)
|
||||
|
||||
ConstBuffer<int16_t>
|
||||
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
|
||||
SampleFormat src_format, ConstBuffer<void> src)
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (src_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
@@ -229,7 +229,7 @@ pcm_allocate_float_to_24(PcmBuffer &buffer, ConstBuffer<float> src)
|
||||
|
||||
ConstBuffer<int32_t>
|
||||
pcm_convert_to_24(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src)
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (src_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
@@ -297,7 +297,7 @@ pcm_allocate_float_to_32(PcmBuffer &buffer, ConstBuffer<float> src)
|
||||
|
||||
ConstBuffer<int32_t>
|
||||
pcm_convert_to_32(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src)
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (src_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
@@ -365,7 +365,7 @@ pcm_allocate_32_to_float(PcmBuffer &buffer, ConstBuffer<int32_t> src)
|
||||
|
||||
ConstBuffer<float>
|
||||
pcm_convert_to_float(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src)
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept
|
||||
{
|
||||
switch (src_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
|
@@ -40,7 +40,7 @@ class PcmDither;
|
||||
gcc_pure
|
||||
ConstBuffer<int16_t>
|
||||
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
|
||||
SampleFormat src_format, ConstBuffer<void> src);
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept;
|
||||
|
||||
/**
|
||||
* Converts PCM samples to 24 bit (32 bit alignment).
|
||||
@@ -52,7 +52,7 @@ pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
|
||||
gcc_pure
|
||||
ConstBuffer<int32_t>
|
||||
pcm_convert_to_24(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src);
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept;
|
||||
|
||||
/**
|
||||
* Converts PCM samples to 32 bit.
|
||||
@@ -64,7 +64,7 @@ pcm_convert_to_24(PcmBuffer &buffer,
|
||||
gcc_pure
|
||||
ConstBuffer<int32_t>
|
||||
pcm_convert_to_32(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src);
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept;
|
||||
|
||||
/**
|
||||
* Converts PCM samples to 32 bit floating point.
|
||||
@@ -76,6 +76,6 @@ pcm_convert_to_32(PcmBuffer &buffer,
|
||||
gcc_pure
|
||||
ConstBuffer<float>
|
||||
pcm_convert_to_float(PcmBuffer &buffer,
|
||||
SampleFormat src_format, ConstBuffer<void> src);
|
||||
SampleFormat src_format, ConstBuffer<void> src) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -36,7 +36,7 @@ template<SampleFormat F> struct SampleTraits;
|
||||
template<SampleFormat F, class Traits=SampleTraits<F>>
|
||||
gcc_const
|
||||
static inline typename Traits::value_type
|
||||
PcmClamp(typename Traits::long_type x)
|
||||
PcmClamp(typename Traits::long_type x) noexcept
|
||||
{
|
||||
typedef typename Traits::value_type T;
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
const char *
|
||||
sample_format_to_string(SampleFormat format)
|
||||
sample_format_to_string(SampleFormat format) noexcept
|
||||
{
|
||||
switch (format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
|
@@ -124,6 +124,6 @@ sample_format_size(SampleFormat format)
|
||||
*/
|
||||
gcc_pure gcc_malloc
|
||||
const char *
|
||||
sample_format_to_string(SampleFormat format);
|
||||
sample_format_to_string(SampleFormat format) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -56,7 +56,7 @@ static constexpr struct {
|
||||
|
||||
gcc_const
|
||||
static const char *
|
||||
soxr_quality_name(unsigned long recipe)
|
||||
soxr_quality_name(unsigned long recipe) noexcept
|
||||
{
|
||||
for (const auto *i = soxr_quality_table;; ++i) {
|
||||
assert(i->name != nullptr);
|
||||
@@ -68,7 +68,7 @@ soxr_quality_name(unsigned long recipe)
|
||||
|
||||
gcc_pure
|
||||
static unsigned long
|
||||
soxr_parse_quality(const char *quality)
|
||||
soxr_parse_quality(const char *quality) noexcept
|
||||
{
|
||||
if (quality == nullptr)
|
||||
return SOXR_DEFAULT_RECIPE;
|
||||
|
@@ -123,7 +123,7 @@ PcmVolume::Open(SampleFormat _format)
|
||||
}
|
||||
|
||||
ConstBuffer<void>
|
||||
PcmVolume::Apply(ConstBuffer<void> src)
|
||||
PcmVolume::Apply(ConstBuffer<void> src) noexcept
|
||||
{
|
||||
if (volume == PCM_VOLUME_1)
|
||||
return src;
|
||||
|
@@ -112,7 +112,7 @@ public:
|
||||
* Apply the volume level.
|
||||
*/
|
||||
gcc_pure
|
||||
ConstBuffer<void> Apply(ConstBuffer<void> src);
|
||||
ConstBuffer<void> Apply(ConstBuffer<void> src) noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user