Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3bb9c704
Commit
3bb9c704
authored
Jan 01, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/*: add "noexcept"
parent
10537c50
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
123 additions
and
120 deletions
+123
-120
ChannelsConverter.cxx
src/pcm/ChannelsConverter.cxx
+1
-1
ChannelsConverter.hxx
src/pcm/ChannelsConverter.hxx
+3
-3
ConfiguredResampler.cxx
src/pcm/ConfiguredResampler.cxx
+3
-3
FallbackResampler.cxx
src/pcm/FallbackResampler.cxx
+3
-3
FallbackResampler.hxx
src/pcm/FallbackResampler.hxx
+1
-1
FormatConverter.hxx
src/pcm/FormatConverter.hxx
+2
-2
GlueResampler.cxx
src/pcm/GlueResampler.cxx
+3
-3
GlueResampler.hxx
src/pcm/GlueResampler.hxx
+4
-4
Interleave.cxx
src/pcm/Interleave.cxx
+6
-6
Interleave.hxx
src/pcm/Interleave.hxx
+3
-3
LibsamplerateResampler.cxx
src/pcm/LibsamplerateResampler.cxx
+2
-2
LibsamplerateResampler.hxx
src/pcm/LibsamplerateResampler.hxx
+2
-2
Neon.hxx
src/pcm/Neon.hxx
+2
-1
PcmBuffer.cxx
src/pcm/PcmBuffer.cxx
+1
-1
PcmBuffer.hxx
src/pcm/PcmBuffer.hxx
+3
-3
PcmChannels.cxx
src/pcm/PcmChannels.cxx
+11
-11
PcmChannels.hxx
src/pcm/PcmChannels.hxx
+4
-4
PcmConvert.cxx
src/pcm/PcmConvert.cxx
+4
-4
PcmConvert.hxx
src/pcm/PcmConvert.hxx
+4
-4
PcmDither.cxx
src/pcm/PcmDither.cxx
+6
-6
PcmDither.hxx
src/pcm/PcmDither.hxx
+7
-7
PcmDsd.cxx
src/pcm/PcmDsd.cxx
+4
-4
PcmDsd.hxx
src/pcm/PcmDsd.hxx
+4
-4
PcmMix.cxx
src/pcm/PcmMix.cxx
+13
-11
PcmMix.hxx
src/pcm/PcmMix.hxx
+1
-1
PcmPrng.hxx
src/pcm/PcmPrng.hxx
+1
-1
Resampler.hxx
src/pcm/Resampler.hxx
+2
-2
SampleFormat.hxx
src/pcm/SampleFormat.hxx
+2
-2
ShiftConvert.hxx
src/pcm/ShiftConvert.hxx
+2
-2
Silence.cxx
src/pcm/Silence.cxx
+1
-1
Silence.hxx
src/pcm/Silence.hxx
+1
-1
SoxrResampler.cxx
src/pcm/SoxrResampler.cxx
+1
-1
SoxrResampler.hxx
src/pcm/SoxrResampler.hxx
+1
-1
Volume.cxx
src/pcm/Volume.cxx
+7
-7
Volume.hxx
src/pcm/Volume.hxx
+8
-8
No files found.
src/pcm/ChannelsConverter.cxx
View file @
3bb9c704
...
...
@@ -49,7 +49,7 @@ PcmChannelsConverter::Open(SampleFormat _format,
}
void
PcmChannelsConverter
::
Close
()
PcmChannelsConverter
::
Close
()
noexcept
{
#ifndef NDEBUG
format
=
SampleFormat
::
UNDEFINED
;
...
...
src/pcm/ChannelsConverter.hxx
View file @
3bb9c704
...
...
@@ -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.
...
...
src/pcm/ConfiguredResampler.cxx
View file @
3bb9c704
...
...
@@ -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 ¶m, ConfigBlock &block)
}
static
const
ConfigBlock
*
MigrateResamplerConfig
(
const
ConfigParam
*
param
,
ConfigBlock
&
buffer
)
MigrateResamplerConfig
(
const
ConfigParam
*
param
,
ConfigBlock
&
buffer
)
noexcept
{
assert
(
buffer
.
IsEmpty
());
...
...
src/pcm/FallbackResampler.cxx
View file @
3bb9c704
...
...
@@ -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
,
...
...
src/pcm/FallbackResampler.hxx
View file @
3bb9c704
...
...
@@ -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
;
};
...
...
src/pcm/FormatConverter.hxx
View file @
3bb9c704
...
...
@@ -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
);
}
...
...
src/pcm/GlueResampler.cxx
View file @
3bb9c704
...
...
@@ -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
();
}
...
...
src/pcm/GlueResampler.hxx
View file @
3bb9c704
...
...
@@ -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
);
};
...
...
src/pcm/Interleave.cxx
View file @
3bb9c704
...
...
@@ -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
:
...
...
src/pcm/Interleave.hxx
View file @
3bb9c704
...
...
@@ -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
,
...
...
src/pcm/LibsamplerateResampler.cxx
View file @
3bb9c704
...
...
@@ -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
);
}
...
...
src/pcm/LibsamplerateResampler.hxx
View file @
3bb9c704
...
...
@@ -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
:
...
...
src/pcm/Neon.hxx
View file @
3bb9c704
...
...
@@ -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
...
...
src/pcm/PcmBuffer.cxx
View file @
3bb9c704
...
...
@@ -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
...
...
src/pcm/PcmBuffer.hxx
View file @
3bb9c704
...
...
@@ -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
));
}
};
...
...
src/pcm/PcmChannels.cxx
View file @
3bb9c704
...
...
@@ -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
);
...
...
src/pcm/PcmChannels.hxx
View file @
3bb9c704
...
...
@@ -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
src/pcm/PcmConvert.cxx
View file @
3bb9c704
...
...
@@ -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
();
...
...
src/pcm/PcmConvert.hxx
View file @
3bb9c704
...
...
@@ -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.
...
...
src/pcm/PcmDither.cxx
View file @
3bb9c704
...
...
@@ -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
;
...
...
src/pcm/PcmDither.hxx
View file @
3bb9c704
...
...
@@ -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
src/pcm/PcmDsd.cxx
View file @
3bb9c704
...
...
@@ -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
());
...
...
src/pcm/PcmDsd.hxx
View file @
3bb9c704
...
...
@@ -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
src/pcm/PcmMix.cxx
View file @
3bb9c704
...
...
@@ -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
;
...
...
src/pcm/PcmMix.hxx
View file @
3bb9c704
...
...
@@ -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
src/pcm/PcmPrng.hxx
View file @
3bb9c704
...
...
@@ -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
;
}
...
...
src/pcm/Resampler.hxx
View file @
3bb9c704
...
...
@@ -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
{
}
/**
...
...
src/pcm/SampleFormat.hxx
View file @
3bb9c704
...
...
@@ -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
:
...
...
src/pcm/ShiftConvert.hxx
View file @
3bb9c704
...
...
@@ -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
);
}
};
...
...
src/pcm/Silence.cxx
View file @
3bb9c704
...
...
@@ -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
)
...
...
src/pcm/Silence.hxx
View file @
3bb9c704
...
...
@@ -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
src/pcm/SoxrResampler.cxx
View file @
3bb9c704
...
...
@@ -134,7 +134,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
}
void
SoxrPcmResampler
::
Close
()
SoxrPcmResampler
::
Close
()
noexcept
{
soxr_delete
(
soxr
);
}
...
...
src/pcm/SoxrResampler.hxx
View file @
3bb9c704
...
...
@@ -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
;
};
...
...
src/pcm/Volume.cxx
View file @
3bb9c704
...
...
@@ -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
;
...
...
src/pcm/Volume.hxx
View file @
3bb9c704
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment