summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-01 19:07:33 +0100
committerMax Kellermann <max@musicpd.org>2018-01-01 19:07:33 +0100
commit3bb9c704de1d0dffe0a3d3f3dac42e59299b4cf6 (patch)
tree90bf541b06ececf9372713892a9f28380efdb8d3
parent10537c5095258b88cdc13beac06577b335bbf6ee (diff)
pcm/*: add "noexcept"
-rw-r--r--src/pcm/ChannelsConverter.cxx2
-rw-r--r--src/pcm/ChannelsConverter.hxx6
-rw-r--r--src/pcm/ConfiguredResampler.cxx6
-rw-r--r--src/pcm/FallbackResampler.cxx6
-rw-r--r--src/pcm/FallbackResampler.hxx2
-rw-r--r--src/pcm/FormatConverter.hxx4
-rw-r--r--src/pcm/GlueResampler.cxx6
-rw-r--r--src/pcm/GlueResampler.hxx8
-rw-r--r--src/pcm/Interleave.cxx12
-rw-r--r--src/pcm/Interleave.hxx6
-rw-r--r--src/pcm/LibsamplerateResampler.cxx4
-rw-r--r--src/pcm/LibsamplerateResampler.hxx4
-rw-r--r--src/pcm/Neon.hxx3
-rw-r--r--src/pcm/PcmBuffer.cxx2
-rw-r--r--src/pcm/PcmBuffer.hxx6
-rw-r--r--src/pcm/PcmChannels.cxx22
-rw-r--r--src/pcm/PcmChannels.hxx8
-rw-r--r--src/pcm/PcmConvert.cxx8
-rw-r--r--src/pcm/PcmConvert.hxx8
-rw-r--r--src/pcm/PcmDither.cxx12
-rw-r--r--src/pcm/PcmDither.hxx14
-rw-r--r--src/pcm/PcmDsd.cxx8
-rw-r--r--src/pcm/PcmDsd.hxx8
-rw-r--r--src/pcm/PcmMix.cxx24
-rw-r--r--src/pcm/PcmMix.hxx2
-rw-r--r--src/pcm/PcmPrng.hxx2
-rw-r--r--src/pcm/Resampler.hxx4
-rw-r--r--src/pcm/SampleFormat.hxx4
-rw-r--r--src/pcm/ShiftConvert.hxx4
-rw-r--r--src/pcm/Silence.cxx2
-rw-r--r--src/pcm/Silence.hxx2
-rw-r--r--src/pcm/SoxrResampler.cxx2
-rw-r--r--src/pcm/SoxrResampler.hxx2
-rw-r--r--src/pcm/Volume.cxx14
-rw-r--r--src/pcm/Volume.hxx16
35 files changed, 123 insertions, 120 deletions
diff --git a/src/pcm/ChannelsConverter.cxx b/src/pcm/ChannelsConverter.cxx
index c03c3e7ed..479551989 100644
--- a/src/pcm/ChannelsConverter.cxx
+++ b/src/pcm/ChannelsConverter.cxx
@@ -49,7 +49,7 @@ PcmChannelsConverter::Open(SampleFormat _format,
}
void
-PcmChannelsConverter::Close()
+PcmChannelsConverter::Close() noexcept
{
#ifndef NDEBUG
format = SampleFormat::UNDEFINED;
diff --git a/src/pcm/ChannelsConverter.hxx b/src/pcm/ChannelsConverter.hxx
index b14958ea1..510f72cfd 100644
--- a/src/pcm/ChannelsConverter.hxx
+++ b/src/pcm/ChannelsConverter.hxx
@@ -41,10 +41,10 @@ class PcmChannelsConverter {
public:
#ifndef NDEBUG
- PcmChannelsConverter()
+ PcmChannelsConverter() noexcept
:format(SampleFormat::UNDEFINED) {}
- ~PcmChannelsConverter() {
+ ~PcmChannelsConverter() noexcept {
assert(format == SampleFormat::UNDEFINED);
}
#endif
@@ -64,7 +64,7 @@ public:
/**
* Closes the object. After that, you may call Open() again.
*/
- void Close();
+ void Close() noexcept;
/**
* Convert a block of PCM data.
diff --git a/src/pcm/ConfiguredResampler.cxx b/src/pcm/ConfiguredResampler.cxx
index bd44a95f3..d2093a188 100644
--- a/src/pcm/ConfiguredResampler.cxx
+++ b/src/pcm/ConfiguredResampler.cxx
@@ -52,7 +52,7 @@ enum class SelectedResampler {
static SelectedResampler selected_resampler = SelectedResampler::FALLBACK;
static const ConfigBlock *
-MakeResamplerDefaultConfig(ConfigBlock &block)
+MakeResamplerDefaultConfig(ConfigBlock &block) noexcept
{
assert(block.IsEmpty());
@@ -71,7 +71,7 @@ MakeResamplerDefaultConfig(ConfigBlock &block)
* "resampler" block.
*/
static const ConfigBlock *
-MigrateResamplerConfig(const ConfigParam &param, ConfigBlock &block)
+MigrateResamplerConfig(const ConfigParam &param, ConfigBlock &block) noexcept
{
assert(block.IsEmpty());
@@ -102,7 +102,7 @@ MigrateResamplerConfig(const ConfigParam &param, ConfigBlock &block)
}
static const ConfigBlock *
-MigrateResamplerConfig(const ConfigParam *param, ConfigBlock &buffer)
+MigrateResamplerConfig(const ConfigParam *param, ConfigBlock &buffer) noexcept
{
assert(buffer.IsEmpty());
diff --git a/src/pcm/FallbackResampler.cxx b/src/pcm/FallbackResampler.cxx
index ead8fcfa1..8a41fa4d9 100644
--- a/src/pcm/FallbackResampler.cxx
+++ b/src/pcm/FallbackResampler.cxx
@@ -57,7 +57,7 @@ FallbackPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
}
void
-FallbackPcmResampler::Close()
+FallbackPcmResampler::Close() noexcept
{
}
@@ -67,7 +67,7 @@ pcm_resample_fallback(PcmBuffer &buffer,
unsigned channels,
unsigned src_rate,
ConstBuffer<T> src,
- unsigned dest_rate)
+ unsigned dest_rate) noexcept
{
unsigned dest_pos = 0;
unsigned src_frames = src.size / channels;
@@ -107,7 +107,7 @@ pcm_resample_fallback_void(PcmBuffer &buffer,
unsigned channels,
unsigned src_rate,
ConstBuffer<void> src,
- unsigned dest_rate)
+ unsigned dest_rate) noexcept
{
const auto typed_src = ConstBuffer<T>::FromVoid(src);
return pcm_resample_fallback(buffer, channels, src_rate, typed_src,
diff --git a/src/pcm/FallbackResampler.hxx b/src/pcm/FallbackResampler.hxx
index 283bc46eb..ec82b301d 100644
--- a/src/pcm/FallbackResampler.hxx
+++ b/src/pcm/FallbackResampler.hxx
@@ -37,7 +37,7 @@ class FallbackPcmResampler final : public PcmResampler {
public:
AudioFormat Open(AudioFormat &af, unsigned new_sample_rate) override;
- void Close() override;
+ void Close() noexcept override;
ConstBuffer<void> Resample(ConstBuffer<void> src) override;
};
diff --git a/src/pcm/FormatConverter.hxx b/src/pcm/FormatConverter.hxx
index 082dd4f1c..e723179dc 100644
--- a/src/pcm/FormatConverter.hxx
+++ b/src/pcm/FormatConverter.hxx
@@ -42,11 +42,11 @@ class PcmFormatConverter {
public:
#ifndef NDEBUG
- PcmFormatConverter()
+ PcmFormatConverter() noexcept
:src_format(SampleFormat::UNDEFINED),
dest_format(SampleFormat::UNDEFINED) {}
- ~PcmFormatConverter() {
+ ~PcmFormatConverter() noexcept {
assert(src_format == SampleFormat::UNDEFINED);
assert(dest_format == SampleFormat::UNDEFINED);
}
diff --git a/src/pcm/GlueResampler.cxx b/src/pcm/GlueResampler.cxx
index 9b48eb5ff..36ee4648b 100644
--- a/src/pcm/GlueResampler.cxx
+++ b/src/pcm/GlueResampler.cxx
@@ -27,7 +27,7 @@
GluePcmResampler::GluePcmResampler()
:resampler(pcm_resampler_create()) {}
-GluePcmResampler::~GluePcmResampler()
+GluePcmResampler::~GluePcmResampler() noexcept
{
delete resampler;
}
@@ -57,7 +57,7 @@ GluePcmResampler::Open(AudioFormat src_format, unsigned new_sample_rate)
}
void
-GluePcmResampler::Close()
+GluePcmResampler::Close() noexcept
{
if (requested_sample_format != src_sample_format)
format_converter.Close();
@@ -66,7 +66,7 @@ GluePcmResampler::Close()
}
void
-GluePcmResampler::Reset()
+GluePcmResampler::Reset() noexcept
{
resampler->Reset();
}
diff --git a/src/pcm/GlueResampler.hxx b/src/pcm/GlueResampler.hxx
index e2afa30ce..6c81d1886 100644
--- a/src/pcm/GlueResampler.hxx
+++ b/src/pcm/GlueResampler.hxx
@@ -46,19 +46,19 @@ class GluePcmResampler {
public:
GluePcmResampler();
- ~GluePcmResampler();
+ ~GluePcmResampler() noexcept;
void Open(AudioFormat src_format, unsigned new_sample_rate);
- void Close();
+ void Close() noexcept;
- SampleFormat GetOutputSampleFormat() const {
+ SampleFormat GetOutputSampleFormat() const noexcept {
return output_sample_format;
}
/**
* @see PcmResampler::Reset()
*/
- void Reset();
+ void Reset() noexcept;
ConstBuffer<void> Resample(ConstBuffer<void> src);
};
diff --git a/src/pcm/Interleave.cxx b/src/pcm/Interleave.cxx
index 3c6beb91c..c428c8f36 100644
--- a/src/pcm/Interleave.cxx
+++ b/src/pcm/Interleave.cxx
@@ -25,7 +25,7 @@
static void
GenericPcmInterleave(uint8_t *gcc_restrict dest,
ConstBuffer<const uint8_t *> src,
- size_t n_frames, size_t sample_size)
+ size_t n_frames, size_t sample_size) noexcept
{
for (size_t frame = 0; frame < n_frames; ++frame) {
for (size_t channel = 0; channel < src.size; ++channel) {
@@ -41,7 +41,7 @@ static void
PcmInterleaveStereo(T *gcc_restrict dest,
const T *gcc_restrict src1,
const T *gcc_restrict src2,
- size_t n_frames)
+ size_t n_frames) noexcept
{
for (size_t i = 0; i != n_frames; ++i) {
*dest++ = *src1++;
@@ -53,7 +53,7 @@ template<typename T>
static void
PcmInterleaveT(T *gcc_restrict dest,
const ConstBuffer<const T *> src,
- size_t n_frames)
+ size_t n_frames) noexcept
{
switch (src.size) {
case 2:
@@ -73,7 +73,7 @@ PcmInterleaveT(T *gcc_restrict dest,
static void
PcmInterleave16(int16_t *gcc_restrict dest,
const ConstBuffer<const int16_t *> src,
- size_t n_frames)
+ size_t n_frames) noexcept
{
PcmInterleaveT(dest, src, n_frames);
}
@@ -81,7 +81,7 @@ PcmInterleave16(int16_t *gcc_restrict dest,
void
PcmInterleave32(int32_t *gcc_restrict dest,
const ConstBuffer<const int32_t *> src,
- size_t n_frames)
+ size_t n_frames) noexcept
{
PcmInterleaveT(dest, src, n_frames);
}
@@ -89,7 +89,7 @@ PcmInterleave32(int32_t *gcc_restrict dest,
void
PcmInterleave(void *gcc_restrict dest,
ConstBuffer<const void *> src,
- size_t n_frames, size_t sample_size)
+ size_t n_frames, size_t sample_size) noexcept
{
switch (sample_size) {
case 2:
diff --git a/src/pcm/Interleave.hxx b/src/pcm/Interleave.hxx
index 902a6b651..a94bc67f6 100644
--- a/src/pcm/Interleave.hxx
+++ b/src/pcm/Interleave.hxx
@@ -31,7 +31,7 @@
*/
void
PcmInterleave(void *gcc_restrict dest, ConstBuffer<const void *> src,
- size_t n_frames, size_t sample_size);
+ size_t n_frames, size_t sample_size) noexcept;
/**
* A variant of PcmInterleave() that assumes 32 bit samples (4 bytes
@@ -39,11 +39,11 @@ PcmInterleave(void *gcc_restrict dest, ConstBuffer<const void *> src,
*/
void
PcmInterleave32(int32_t *gcc_restrict dest, ConstBuffer<const int32_t *> src,
- size_t n_frames);
+ size_t n_frames) noexcept;
static inline void
PcmInterleaveFloat(float *gcc_restrict dest, ConstBuffer<const float *> src,
- size_t n_frames)
+ size_t n_frames) noexcept
{
PcmInterleave32((int32_t *)dest,
ConstBuffer<const int32_t *>((const int32_t *const*)src.data,
diff --git a/src/pcm/LibsamplerateResampler.cxx b/src/pcm/LibsamplerateResampler.cxx
index 957bea03f..ef01aad65 100644
--- a/src/pcm/LibsamplerateResampler.cxx
+++ b/src/pcm/LibsamplerateResampler.cxx
@@ -109,13 +109,13 @@ LibsampleratePcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
}
void
-LibsampleratePcmResampler::Close()
+LibsampleratePcmResampler::Close() noexcept
{
state = src_delete(state);
}
void
-LibsampleratePcmResampler::Reset()
+LibsampleratePcmResampler::Reset() noexcept
{
src_reset(state);
}
diff --git a/src/pcm/LibsamplerateResampler.hxx b/src/pcm/LibsamplerateResampler.hxx
index 3660bfd84..988a0575d 100644
--- a/src/pcm/LibsamplerateResampler.hxx
+++ b/src/pcm/LibsamplerateResampler.hxx
@@ -43,8 +43,8 @@ class LibsampleratePcmResampler final : public PcmResampler {
public:
AudioFormat Open(AudioFormat &af, unsigned new_sample_rate) override;
- void Close() override;
- void Reset() override;
+ void Close() noexcept override;
+ void Reset() noexcept override;
ConstBuffer<void> Resample(ConstBuffer<void> src) override;
private:
diff --git a/src/pcm/Neon.hxx b/src/pcm/Neon.hxx
index 1205409cc..3aa7f6d47 100644
--- a/src/pcm/Neon.hxx
+++ b/src/pcm/Neon.hxx
@@ -66,7 +66,8 @@ struct NeonFloatTo16 {
static constexpr size_t BLOCK_SIZE = 16;
- void Convert(int16_t *dst, const float *src, const size_t n) const {
+ void Convert(int16_t *dst, const float *src,
+ const size_t n) const noexcept {
for (unsigned i = 0; i < n / BLOCK_SIZE;
++i, src += BLOCK_SIZE, dst += BLOCK_SIZE) {
/* load 16 float samples into 4 quad
diff --git a/src/pcm/PcmBuffer.cxx b/src/pcm/PcmBuffer.cxx
index bc9d86c88..3eb016f73 100644
--- a/src/pcm/PcmBuffer.cxx
+++ b/src/pcm/PcmBuffer.cxx
@@ -21,7 +21,7 @@
#include "PcmBuffer.hxx"
void *
-PcmBuffer::Get(size_t new_size)
+PcmBuffer::Get(size_t new_size) noexcept
{
if (new_size == 0)
/* never return nullptr, because nullptr would be
diff --git a/src/pcm/PcmBuffer.hxx b/src/pcm/PcmBuffer.hxx
index 68b169eb3..f7917554c 100644
--- a/src/pcm/PcmBuffer.hxx
+++ b/src/pcm/PcmBuffer.hxx
@@ -34,7 +34,7 @@ class PcmBuffer {
ReusableArray<uint8_t, 8192> buffer;
public:
- void Clear() {
+ void Clear() noexcept {
buffer.Clear();
}
@@ -48,11 +48,11 @@ public:
* always an error.
*/
gcc_malloc gcc_returns_nonnull
- void *Get(size_t size);
+ void *Get(size_t size) noexcept;
template<typename T>
gcc_malloc gcc_returns_nonnull
- T *GetT(size_t n) {
+ T *GetT(size_t n) noexcept {
return (T *)Get(n * sizeof(T));
}
};
diff --git a/src/pcm/PcmChannels.cxx b/src/pcm/PcmChannels.cxx
index 1105e7412..27c85acc7 100644
--- a/src/pcm/PcmChannels.cxx
+++ b/src/pcm/PcmChannels.cxx
@@ -33,7 +33,7 @@
template<typename D, typename S>
static void
-MonoToStereo(D dest, S src, S end)
+MonoToStereo(D dest, S src, S end) noexcept
{
while (src != end) {
const auto value = *src++;
@@ -47,7 +47,7 @@ MonoToStereo(D dest, S src, S end)
template<SampleFormat F, class Traits=SampleTraits<F>>
static typename Traits::value_type
StereoToMono(typename Traits::value_type _a,
- typename Traits::value_type _b)
+ typename Traits::value_type _b) noexcept
{
typename Traits::sum_type a(_a);
typename Traits::sum_type b(_b);
@@ -59,7 +59,7 @@ template<SampleFormat F, class Traits=SampleTraits<F>>
static typename Traits::pointer_type
StereoToMono(typename Traits::pointer_type dest,
typename Traits::const_pointer_type src,
- typename Traits::const_pointer_type end)
+ typename Traits::const_pointer_type end) noexcept
{
while (src != end) {
const auto a = *src++;
@@ -76,7 +76,7 @@ static typename Traits::pointer_type
NToStereo(typename Traits::pointer_type dest,
unsigned src_channels,
typename Traits::const_pointer_type src,
- typename Traits::const_pointer_type end)
+ typename Traits::const_pointer_type end) noexcept
{
assert((end - src) % src_channels == 0);
@@ -105,7 +105,7 @@ static typename Traits::pointer_type
StereoToN(typename Traits::pointer_type dest,
unsigned dest_channels,
typename Traits::const_pointer_type src,
- typename Traits::const_pointer_type end)
+ typename Traits::const_pointer_type end) noexcept
{
assert(dest_channels > 2);
assert((end - src) % 2 == 0);
@@ -133,7 +133,7 @@ NToM(typename Traits::pointer_type dest,
unsigned dest_channels,
unsigned src_channels,
typename Traits::const_pointer_type src,
- typename Traits::const_pointer_type end)
+ typename Traits::const_pointer_type end) noexcept
{
assert((end - src) % src_channels == 0);
@@ -157,7 +157,7 @@ static ConstBuffer<typename Traits::value_type>
ConvertChannels(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<typename Traits::value_type> src)
+ ConstBuffer<typename Traits::value_type> src) noexcept
{
assert(src.size % src_channels == 0);
@@ -184,7 +184,7 @@ ConstBuffer<int16_t>
pcm_convert_channels_16(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int16_t> src)
+ ConstBuffer<int16_t> src) noexcept
{
return ConvertChannels<SampleFormat::S16>(buffer, dest_channels,
src_channels, src);
@@ -194,7 +194,7 @@ ConstBuffer<int32_t>
pcm_convert_channels_24(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int32_t> src)
+ ConstBuffer<int32_t> src) noexcept
{
return ConvertChannels<SampleFormat::S24_P32>(buffer, dest_channels,
src_channels, src);
@@ -204,7 +204,7 @@ ConstBuffer<int32_t>
pcm_convert_channels_32(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int32_t> src)
+ ConstBuffer<int32_t> src) noexcept
{
return ConvertChannels<SampleFormat::S32>(buffer, dest_channels,
src_channels, src);
@@ -214,7 +214,7 @@ ConstBuffer<float>
pcm_convert_channels_float(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<float> src)
+ ConstBuffer<float> src) noexcept
{
return ConvertChannels<SampleFormat::FLOAT>(buffer, dest_channels,
src_channels, src);
diff --git a/src/pcm/PcmChannels.hxx b/src/pcm/PcmChannels.hxx
index 48b9bae31..b963c9e97 100644
--- a/src/pcm/PcmChannels.hxx
+++ b/src/pcm/PcmChannels.hxx
@@ -38,7 +38,7 @@ ConstBuffer<int16_t>
pcm_convert_channels_16(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int16_t> src);
+ ConstBuffer<int16_t> src) noexcept;
/**
* Changes the number of channels in 24 bit PCM data (aligned at 32
@@ -54,7 +54,7 @@ ConstBuffer<int32_t>
pcm_convert_channels_24(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int32_t> src);
+ ConstBuffer<int32_t> src) noexcept;
/**
* Changes the number of channels in 32 bit PCM data.
@@ -69,7 +69,7 @@ ConstBuffer<int32_t>
pcm_convert_channels_32(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<int32_t> src);
+ ConstBuffer<int32_t> src) noexcept;
/**
* Changes the number of channels in 32 bit float PCM data.
@@ -84,6 +84,6 @@ ConstBuffer<float>
pcm_convert_channels_float(PcmBuffer &buffer,
unsigned dest_channels,
unsigned src_channels,
- ConstBuffer<float> src);
+ ConstBuffer<float> src) noexcept;
#endif
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx
index 0752b1db8..a63e92a7c 100644
--- a/src/pcm/PcmConvert.cxx
+++ b/src/pcm/PcmConvert.cxx
@@ -30,7 +30,7 @@ pcm_convert_global_init()
pcm_resampler_global_init();
}
-PcmConvert::PcmConvert()
+PcmConvert::PcmConvert() noexcept
{
#ifndef NDEBUG
src_format.Clear();
@@ -38,7 +38,7 @@ PcmConvert::PcmConvert()
#endif
}
-PcmConvert::~PcmConvert()
+PcmConvert::~PcmConvert() noexcept
{
assert(!src_format.IsValid());
assert(!dest_format.IsValid());
@@ -97,7 +97,7 @@ PcmConvert::Open(const AudioFormat _src_format, const AudioFormat _dest_format)
}
void
-PcmConvert::Close()
+PcmConvert::Close() noexcept
{
if (enable_channels)
channels_converter.Close();
@@ -117,7 +117,7 @@ PcmConvert::Close()
}
void
-PcmConvert::Reset()
+PcmConvert::Reset() noexcept
{
if (enable_resampler)
resampler.Reset();
diff --git a/src/pcm/PcmConvert.hxx b/src/pcm/PcmConvert.hxx
index 617348cac..264179635 100644
--- a/src/pcm/PcmConvert.hxx
+++ b/src/pcm/PcmConvert.hxx
@@ -51,8 +51,8 @@ class PcmConvert {
bool enable_resampler, enable_format, enable_channels;
public:
- PcmConvert();
- ~PcmConvert();
+ PcmConvert() noexcept;
+ ~PcmConvert() noexcept;
/**
* Prepare the object. Call Close() when done.
@@ -65,12 +65,12 @@ public:
* Close the object after it was prepared with Open(). After
* that, it may be reused by calling Open() again.
*/
- void Close();
+ void Close() noexcept;
/**
* Reset the filter's state, e.g. drop/flush buffers.
*/
- void Reset();
+ void Reset() noexcept;
/**
* Converts PCM data between two audio formats.
diff --git a/src/pcm/PcmDither.cxx b/src/pcm/PcmDither.cxx
index 55389e8c9..71616c2e4 100644
--- a/src/pcm/PcmDither.cxx
+++ b/src/pcm/PcmDither.cxx
@@ -24,7 +24,7 @@
template<typename T, T MIN, T MAX, unsigned scale_bits>
inline T
-PcmDither::Dither(T sample)
+PcmDither::Dither(T sample) noexcept
{
constexpr T round = 1 << (scale_bits - 1);
constexpr T mask = (1 << scale_bits) - 1;
@@ -64,7 +64,7 @@ PcmDither::Dither(T sample)
template<typename ST, unsigned SBITS, unsigned DBITS>
inline ST
-PcmDither::DitherShift(ST sample)
+PcmDither::DitherShift(ST sample) noexcept
{
static_assert(sizeof(ST) * 8 > SBITS, "Source type too small");
static_assert(SBITS > DBITS, "Non-positive scale_bits");
@@ -77,7 +77,7 @@ PcmDither::DitherShift(ST sample)
template<typename ST, typename DT>
inline typename DT::value_type
-PcmDither::DitherConvert(typename ST::value_type sample)
+PcmDither::DitherConvert(typename ST::value_type sample) noexcept
{
static_assert(ST::BITS > DT::BITS,
"Sample formats cannot be dithered");
@@ -92,7 +92,7 @@ template<typename ST, typename DT>
inline void
PcmDither::DitherConvert(typename DT::pointer_type dest,
typename ST::const_pointer_type src,
- typename ST::const_pointer_type src_end)
+ typename ST::const_pointer_type src_end) noexcept
{
while (src < src_end)
*dest++ = DitherConvert<ST, DT>(*src++);
@@ -100,7 +100,7 @@ PcmDither::DitherConvert(typename DT::pointer_type dest,
inline void
PcmDither::Dither24To16(int16_t *dest, const int32_t *src,
- const int32_t *src_end)
+ const int32_t *src_end) noexcept
{
typedef SampleTraits<SampleFormat::S24_P32> ST;
typedef SampleTraits<SampleFormat::S16> DT;
@@ -109,7 +109,7 @@ PcmDither::Dither24To16(int16_t *dest, const int32_t *src,
inline void
PcmDither::Dither32To16(int16_t *dest, const int32_t *src,
- const int32_t *src_end)
+ const int32_t *src_end) noexcept
{
typedef SampleTraits<SampleFormat::S32> ST;
typedef SampleTraits<SampleFormat::S16> DT;
diff --git a/src/pcm/PcmDither.hxx b/src/pcm/PcmDither.hxx
index cf64b8534..21e86a5f3 100644
--- a/src/pcm/PcmDither.hxx
+++ b/src/pcm/PcmDither.hxx
@@ -29,7 +29,7 @@ class PcmDither {
int32_t random;
public:
- constexpr PcmDither()
+ constexpr PcmDither() noexcept
:error{0, 0, 0}, random(0) {}
/**
@@ -42,13 +42,13 @@ public:
* @param sample the input sample value
*/
template<typename ST, unsigned SBITS, unsigned DBITS>
- ST DitherShift(ST sample);
+ ST DitherShift(ST sample) noexcept;
void Dither24To16(int16_t *dest, const int32_t *src,
- const int32_t *src_end);
+ const int32_t *src_end) noexcept;
void Dither32To16(int16_t *dest, const int32_t *src,
- const int32_t *src_end);
+ const int32_t *src_end) noexcept;
private:
/**
@@ -62,7 +62,7 @@ private:
* @param sample the input sample value
*/
template<typename T, T MIN, T MAX, unsigned scale_bits>
- T Dither(T sample);
+ T Dither(T sample) noexcept;
/**
* Convert the given sample from one sample format to another,
@@ -73,12 +73,12 @@ private:
* @param sample the input sample value
*/
template<typename ST, typename DT>
- typename DT::value_type DitherConvert(typename ST::value_type sample);
+ typename DT::value_type DitherConvert(typename ST::value_type sample) noexcept;
template<typename ST, typename DT>
void DitherConvert(typename DT::pointer_type dest,
typename ST::const_pointer_type src,
- typename ST::const_pointer_type src_end);
+ typename ST::const_pointer_type src_end) noexcept;
};
#endif
diff --git a/src/pcm/PcmDsd.cxx b/src/pcm/PcmDsd.cxx
index 6e6b24c1e..7c46c5456 100644
--- a/src/pcm/PcmDsd.cxx
+++ b/src/pcm/PcmDsd.cxx
@@ -24,12 +24,12 @@
#include <assert.h>
-PcmDsd::PcmDsd()
+PcmDsd::PcmDsd() noexcept
{
dsd2pcm.fill(nullptr);
}
-PcmDsd::~PcmDsd()
+PcmDsd::~PcmDsd() noexcept
{
for (auto i : dsd2pcm)
if (i != nullptr)
@@ -37,7 +37,7 @@ PcmDsd::~PcmDsd()
}
void
-PcmDsd::Reset()
+PcmDsd::Reset() noexcept
{
for (auto i : dsd2pcm)
if (i != nullptr)
@@ -45,7 +45,7 @@ PcmDsd::Reset()
}
ConstBuffer<float>
-PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src)
+PcmDsd::ToFloat(unsigned channels, ConstBuffer<uint8_t> src) noexcept
{
assert(!src.IsNull());
assert(!src.empty());
diff --git a/src/pcm/PcmDsd.hxx b/src/pcm/PcmDsd.hxx
index ec6e041f1..64e093a24 100644
--- a/src/pcm/PcmDsd.hxx
+++ b/src/pcm/PcmDsd.hxx
@@ -39,13 +39,13 @@ class PcmDsd {
std::array<struct dsd2pcm_ctx_s *, MAX_CHANNELS> dsd2pcm;
public:
- PcmDsd();
- ~PcmDsd();
+ PcmDsd() noexcept;
+ ~PcmDsd() noexcept;
- void Reset();
+ void Reset() noexcept;
ConstBuffer<float> ToFloat(unsigned channels,
- ConstBuffer<uint8_t> src);
+ ConstBuffer<uint8_t> src) noexcept;
};
#endif
diff --git a/src/pcm/PcmMix.cxx b/src/pcm/PcmMix.cxx
index ae859dbf4..2af4f3dac 100644
--- a/src/pcm/PcmMix.cxx
+++ b/src/pcm/PcmMix.cxx
@@ -33,7 +33,7 @@ template<SampleFormat F, class Traits=SampleTraits<F>>
static typename Traits::value_type
PcmAddVolume(PcmDither &dither,
typename Traits::value_type _a, typename Traits::value_type _b,
- int volume1, int volume2)
+ int volume1, int volume2) noexcept
{
typename Traits::long_type a(_a), b(_b);
typename Traits::long_type c(a * volume1 + b * volume2);
@@ -48,7 +48,7 @@ static void
PcmAddVolume(PcmDither &dither,
typename Traits::pointer_type a,
typename Traits::const_pointer_type b,
- size_t n, int volume1, int volume2)
+ size_t n, int volume1, int volume2) noexcept
{
for (size_t i = 0; i != n; ++i)
a[i] = PcmAddVolume<F, Traits>(dither, a[i], b[i],
@@ -58,7 +58,8 @@ PcmAddVolume(PcmDither &dither,
template<SampleFormat F, class Traits=SampleTraits<F>>
static void
PcmAddVolumeVoid(PcmDither &dither,
- void *a, const void *b, size_t size, int volume1, int volume2)
+ void *a, const void *b, size_t size,
+ int volume1, int volume2) noexcept
{
constexpr size_t sample_size = Traits::SAMPLE_SIZE;
assert(size % sample_size == 0);
@@ -72,7 +73,7 @@ PcmAddVolumeVoid(PcmDither &dither,
static void
pcm_add_vol_float(float *buffer1, const float *buffer2,
- unsigned num_samples, float volume1, float volume2)
+ unsigned num_samples, float volume1, float volume2) noexcept
{
while (num_samples > 0) {
float sample1 = *buffer1;
@@ -87,7 +88,7 @@ pcm_add_vol_float(float *buffer1, const float *buffer2,
static bool
pcm_add_vol(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
int vol1, int vol2,
- SampleFormat format)
+ SampleFormat format) noexcept
{
switch (format) {
case SampleFormat::UNDEFINED:
@@ -133,7 +134,7 @@ pcm_add_vol(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
template<SampleFormat F, class Traits=SampleTraits<F>>
static typename Traits::value_type
-PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b)
+PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b) noexcept
{
typename Traits::sum_type a(_a), b(_b);
@@ -144,7 +145,7 @@ template<SampleFormat F, class Traits=SampleTraits<F>>
static void
PcmAdd(typename Traits::pointer_type a,
typename Traits::const_pointer_type b,
- size_t n)
+ size_t n) noexcept
{
for (size_t i = 0; i != n; ++i)
a[i] = PcmAdd<F, Traits>(a[i], b[i]);
@@ -152,7 +153,7 @@ PcmAdd(typename Traits::pointer_type a,
template<SampleFormat F, class Traits=SampleTraits<F>>
static void
-PcmAddVoid(void *a, const void *b, size_t size)
+PcmAddVoid(void *a, const void *b, size_t size) noexcept
{
constexpr size_t sample_size = Traits::SAMPLE_SIZE;
assert(size % sample_size == 0);
@@ -163,7 +164,8 @@ PcmAddVoid(void *a, const void *b, size_t size)
}
static void
-pcm_add_float(float *buffer1, const float *buffer2, unsigned num_samples)
+pcm_add_float(float *buffer1, const float *buffer2,
+ unsigned num_samples) noexcept
{
while (num_samples > 0) {
float sample1 = *buffer1;
@@ -175,7 +177,7 @@ pcm_add_float(float *buffer1, const float *buffer2, unsigned num_samples)
static bool
pcm_add(void *buffer1, const void *buffer2, size_t size,
- SampleFormat format)
+ SampleFormat format) noexcept
{
switch (format) {
case SampleFormat::UNDEFINED:
@@ -211,7 +213,7 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
bool
pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
- SampleFormat format, float portion1)
+ SampleFormat format, float portion1) noexcept
{
float s;
diff --git a/src/pcm/PcmMix.hxx b/src/pcm/PcmMix.hxx
index 9906d8920..7f08a9409 100644
--- a/src/pcm/PcmMix.hxx
+++ b/src/pcm/PcmMix.hxx
@@ -47,6 +47,6 @@ class PcmDither;
gcc_warn_unused_result
bool
pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
- SampleFormat format, float portion1);
+ SampleFormat format, float portion1) noexcept;
#endif
diff --git a/src/pcm/PcmPrng.hxx b/src/pcm/PcmPrng.hxx
index 103263388..89980c46f 100644
--- a/src/pcm/PcmPrng.hxx
+++ b/src/pcm/PcmPrng.hxx
@@ -25,7 +25,7 @@
* dithering.
*/
constexpr static inline unsigned long
-pcm_prng(unsigned long state)
+pcm_prng(unsigned long state) noexcept
{
return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL;
}
diff --git a/src/pcm/Resampler.hxx b/src/pcm/Resampler.hxx
index 26d5014da..485450acc 100644
--- a/src/pcm/Resampler.hxx
+++ b/src/pcm/Resampler.hxx
@@ -52,12 +52,12 @@ public:
* Closes the resampler. After that, you may call Open()
* again.
*/
- virtual void Close() = 0;
+ virtual void Close() noexcept = 0;
/**
* Reset the filter's state, e.g. drop/flush buffers.
*/
- virtual void Reset() {
+ virtual void Reset() noexcept {
}
/**
diff --git a/src/pcm/SampleFormat.hxx b/src/pcm/SampleFormat.hxx
index 408357825..405add4e5 100644
--- a/src/pcm/SampleFormat.hxx
+++ b/src/pcm/SampleFormat.hxx
@@ -68,7 +68,7 @@ enum class SampleFormat : uint8_t {
constexpr
#endif
static inline bool
-audio_valid_sample_format(SampleFormat format)
+audio_valid_sample_format(SampleFormat format) noexcept
{
switch (format) {
case SampleFormat::S8:
@@ -90,7 +90,7 @@ audio_valid_sample_format(SampleFormat format)
constexpr
#endif
static inline unsigned
-sample_format_size(SampleFormat format)
+sample_format_size(SampleFormat format) noexcept
{
switch (format) {
case SampleFormat::S8:
diff --git a/src/pcm/ShiftConvert.hxx b/src/pcm/ShiftConvert.hxx
index c033a7ac2..ce46d2089 100644
--- a/src/pcm/ShiftConvert.hxx
+++ b/src/pcm/ShiftConvert.hxx
@@ -39,7 +39,7 @@ struct LeftShiftSampleConvert {
static_assert(SrcTraits::BITS < DstTraits::BITS,
"Source format must be smaller than destination format");
- constexpr static DV Convert(SV src) {
+ constexpr static DV Convert(SV src) noexcept {
return DV(src) << (DstTraits::BITS - SrcTraits::BITS);
}
};
@@ -61,7 +61,7 @@ struct RightShiftSampleConvert {
static_assert(SrcTraits::BITS > DstTraits::BITS,
"Source format must be smaller than destination format");
- constexpr static DV Convert(SV src) {
+ constexpr static DV Convert(SV src) noexcept {
return src >> (SrcTraits::BITS - DstTraits::BITS);
}
};
diff --git a/src/pcm/Silence.cxx b/src/pcm/Silence.cxx
index babcb2408..4d4cc345b 100644
--- a/src/pcm/Silence.cxx
+++ b/src/pcm/Silence.cxx
@@ -26,7 +26,7 @@
#include <string.h>
void
-PcmSilence(WritableBuffer<void> dest, SampleFormat format)
+PcmSilence(WritableBuffer<void> dest, SampleFormat format) noexcept
{
uint8_t pattern = 0;
if (format == SampleFormat::DSD)
diff --git a/src/pcm/Silence.hxx b/src/pcm/Silence.hxx
index b225572c2..cadba81b0 100644
--- a/src/pcm/Silence.hxx
+++ b/src/pcm/Silence.hxx
@@ -31,6 +31,6 @@ enum class SampleFormat : uint8_t;
* Fill the given buffer with the format-specific silence pattern.
*/
void
-PcmSilence(WritableBuffer<void> dest, SampleFormat format);
+PcmSilence(WritableBuffer<void> dest, SampleFormat format) noexcept;
#endif
diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx
index 621d3f970..0c887cbdd 100644
--- a/src/pcm/SoxrResampler.cxx
+++ b/src/pcm/SoxrResampler.cxx
@@ -134,7 +134,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
}
void
-SoxrPcmResampler::Close()
+SoxrPcmResampler::Close() noexcept
{
soxr_delete(soxr);
}
diff --git a/src/pcm/SoxrResampler.hxx b/src/pcm/SoxrResampler.hxx
index 0be861179..ee4b98869 100644
--- a/src/pcm/SoxrResampler.hxx
+++ b/src/pcm/SoxrResampler.hxx
@@ -40,7 +40,7 @@ class SoxrPcmResampler final : public PcmResampler {
public:
AudioFormat Open(AudioFormat &af, unsigned new_sample_rate) override;
- void Close() override;
+ void Close() noexcept override;
ConstBuffer<void> Resample(ConstBuffer<void> src) override;
};
diff --git a/src/pcm/Volume.cxx b/src/pcm/Volume.cxx
index 97356e4d1..282135bb6 100644
--- a/src/pcm/Volume.cxx
+++ b/src/pcm/Volume.cxx
@@ -35,7 +35,7 @@ template<SampleFormat F, class Traits=SampleTraits<F>>
static inline typename Traits::value_type
pcm_volume_sample(PcmDither &dither,
typename Traits::value_type _sample,
- int volume)
+ int volume) noexcept
{
typename Traits::long_type sample(_sample);
@@ -50,7 +50,7 @@ pcm_volume_change(PcmDither &dither,
typename Traits::pointer_type dest,
typename Traits::const_pointer_type src,
size_t n,
- int volume)
+ int volume) noexcept
{
for (size_t i = 0; i != n; ++i)
dest[i] = pcm_volume_sample<F, Traits>(dither, src[i], volume);
@@ -59,7 +59,7 @@ pcm_volume_change(PcmDither &dither,
static void
pcm_volume_change_8(PcmDither &dither,
int8_t *dest, const int8_t *src, size_t n,
- int volume)
+ int volume) noexcept
{
pcm_volume_change<SampleFormat::S8>(dither, dest, src, n, volume);
}
@@ -67,7 +67,7 @@ pcm_volume_change_8(PcmDither &dither,
static void
pcm_volume_change_16(PcmDither &dither,
int16_t *dest, const int16_t *src, size_t n,
- int volume)
+ int volume) noexcept
{
pcm_volume_change<SampleFormat::S16>(dither, dest, src, n, volume);
}
@@ -75,7 +75,7 @@ pcm_volume_change_16(PcmDither &dither,
static void
pcm_volume_change_24(PcmDither &dither,
int32_t *dest, const int32_t *src, size_t n,
- int volume)
+ int volume) noexcept
{
pcm_volume_change<SampleFormat::S24_P32>(dither, dest, src, n,
volume);
@@ -84,14 +84,14 @@ pcm_volume_change_24(PcmDither &dither,
static void
pcm_volume_change_32(PcmDither &dither,
int32_t *dest, const int32_t *src, size_t n,
- int volume)
+ int volume) noexcept
{
pcm_volume_change<SampleFormat::S32>(dither, dest, src, n, volume);
}
static void
pcm_volume_change_float(float *dest, const float *src, size_t n,
- float volume)
+ float volume) noexcept
{
for (size_t i = 0; i != n; ++i)
dest[i] = src[i] * volume;
diff --git a/src/pcm/Volume.hxx b/src/pcm/Volume.hxx
index 6a1ffde83..a40852209 100644
--- a/src/pcm/Volume.hxx
+++ b/src/pcm/Volume.hxx
@@ -45,14 +45,14 @@ static constexpr int PCM_VOLUME_1S = PCM_VOLUME_1;
* Converts a float value (0.0 = silence, 1.0 = 100% volume) to an
* integer volume value (1000 = 100%).
*/
-static inline int
-pcm_float_to_volume(float volume)
+static constexpr inline int
+pcm_float_to_volume(float volume) noexcept
{
return volume * PCM_VOLUME_1 + 0.5;
}
-static inline float
-pcm_volume_to_float(int volume)
+static constexpr inline float
+pcm_volume_to_float(int volume) noexcept
{
return (float)volume / (float)PCM_VOLUME_1;
}
@@ -69,14 +69,14 @@ class PcmVolume {
PcmDither dither;
public:
- PcmVolume()
+ PcmVolume() noexcept
:volume(PCM_VOLUME_1) {
#ifndef NDEBUG
format = SampleFormat::UNDEFINED;
#endif
}
- unsigned GetVolume() const {
+ unsigned GetVolume() const noexcept {
return volume;
}
@@ -85,7 +85,7 @@ public:
* [0..#PCM_VOLUME_1]; may be bigger than #PCM_VOLUME_1, but
* then it will most likely clip a lot
*/
- void SetVolume(unsigned _volume) {
+ void SetVolume(unsigned _volume) noexcept {
volume = _volume;
}
@@ -101,7 +101,7 @@ public:
/**
* Closes the object. After that, you may call Open() again.
*/
- void Close() {
+ void Close() noexcept {
#ifndef NDEBUG
assert(format != SampleFormat::UNDEFINED);
format = SampleFormat::UNDEFINED;