pcm/Order: add "noexcept"

This commit is contained in:
Max Kellermann 2017-10-26 12:25:38 +02:00
parent e2a74051dc
commit 54dd1ad09b
2 changed files with 13 additions and 12 deletions

View File

@ -27,16 +27,16 @@ struct TwoPointers {
V *dest; V *dest;
const V *src; const V *src;
TwoPointers<V> &CopyOne() { TwoPointers<V> &CopyOne() noexcept {
*dest++ = *src++; *dest++ = *src++;
return *this; return *this;
} }
TwoPointers<V> &CopyTwo() { TwoPointers<V> &CopyTwo() noexcept {
return CopyOne().CopyOne(); return CopyOne().CopyOne();
} }
TwoPointers<V> &SwapTwoPairs() { TwoPointers<V> &SwapTwoPairs() noexcept {
*dest++ = src[2]; *dest++ = src[2];
*dest++ = src[3]; *dest++ = src[3];
*dest++ = src[0]; *dest++ = src[0];
@ -45,12 +45,12 @@ struct TwoPointers {
return *this; return *this;
} }
TwoPointers<V> &ToAlsa51() { TwoPointers<V> &ToAlsa51() noexcept {
return CopyTwo() // left+right return CopyTwo() // left+right
.SwapTwoPairs(); // center, LFE, surround left+right .SwapTwoPairs(); // center, LFE, surround left+right
} }
TwoPointers<V> &ToAlsa71() { TwoPointers<V> &ToAlsa71() noexcept {
return ToAlsa51() return ToAlsa51()
.CopyTwo(); // side left+right .CopyTwo(); // side left+right
} }
@ -58,7 +58,7 @@ struct TwoPointers {
template<typename V> template<typename V>
static void static void
ToAlsaChannelOrder51(V *dest, const V *src, size_t n) ToAlsaChannelOrder51(V *dest, const V *src, size_t n) noexcept
{ {
TwoPointers<V> p{dest, src}; TwoPointers<V> p{dest, src};
for (size_t i = 0; i != n; ++i) for (size_t i = 0; i != n; ++i)
@ -67,7 +67,7 @@ ToAlsaChannelOrder51(V *dest, const V *src, size_t n)
template<typename V> template<typename V>
static inline ConstBuffer<V> static inline ConstBuffer<V>
ToAlsaChannelOrder51(PcmBuffer &buffer, ConstBuffer<V> src) ToAlsaChannelOrder51(PcmBuffer &buffer, ConstBuffer<V> src) noexcept
{ {
auto dest = buffer.GetT<V>(src.size); auto dest = buffer.GetT<V>(src.size);
ToAlsaChannelOrder51(dest, src.data, src.size / 6); ToAlsaChannelOrder51(dest, src.data, src.size / 6);
@ -76,7 +76,7 @@ ToAlsaChannelOrder51(PcmBuffer &buffer, ConstBuffer<V> src)
template<typename V> template<typename V>
static void static void
ToAlsaChannelOrder71(V *dest, const V *src, size_t n) ToAlsaChannelOrder71(V *dest, const V *src, size_t n) noexcept
{ {
TwoPointers<V> p{dest, src}; TwoPointers<V> p{dest, src};
for (size_t i = 0; i != n; ++i) for (size_t i = 0; i != n; ++i)
@ -85,7 +85,7 @@ ToAlsaChannelOrder71(V *dest, const V *src, size_t n)
template<typename V> template<typename V>
static inline ConstBuffer<V> static inline ConstBuffer<V>
ToAlsaChannelOrder71(PcmBuffer &buffer, ConstBuffer<V> src) ToAlsaChannelOrder71(PcmBuffer &buffer, ConstBuffer<V> src) noexcept
{ {
auto dest = buffer.GetT<V>(src.size); auto dest = buffer.GetT<V>(src.size);
ToAlsaChannelOrder71(dest, src.data, src.size / 6); ToAlsaChannelOrder71(dest, src.data, src.size / 6);
@ -94,7 +94,8 @@ ToAlsaChannelOrder71(PcmBuffer &buffer, ConstBuffer<V> src)
template<typename V> template<typename V>
static ConstBuffer<V> static ConstBuffer<V>
ToAlsaChannelOrderT(PcmBuffer &buffer, ConstBuffer<V> src, unsigned channels) ToAlsaChannelOrderT(PcmBuffer &buffer, ConstBuffer<V> src,
unsigned channels) noexcept
{ {
switch (channels) { switch (channels) {
case 6: // 5.1 case 6: // 5.1
@ -110,7 +111,7 @@ ToAlsaChannelOrderT(PcmBuffer &buffer, ConstBuffer<V> src, unsigned channels)
ConstBuffer<void> ConstBuffer<void>
ToAlsaChannelOrder(PcmBuffer &buffer, ConstBuffer<void> src, ToAlsaChannelOrder(PcmBuffer &buffer, ConstBuffer<void> src,
SampleFormat sample_format, unsigned channels) SampleFormat sample_format, unsigned channels) noexcept
{ {
switch (sample_format) { switch (sample_format) {
case SampleFormat::UNDEFINED: case SampleFormat::UNDEFINED:

View File

@ -32,6 +32,6 @@ template<typename T> struct ConstBuffer;
*/ */
ConstBuffer<void> ConstBuffer<void>
ToAlsaChannelOrder(PcmBuffer &buffer, ConstBuffer<void> src, ToAlsaChannelOrder(PcmBuffer &buffer, ConstBuffer<void> src,
SampleFormat sample_format, unsigned channels); SampleFormat sample_format, unsigned channels) noexcept;
#endif #endif