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
1cb7fe12
Commit
1cb7fe12
authored
Aug 26, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pcm/AudioFormat: add `noexcept`
parent
8a298057
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
AudioFormat.hxx
src/pcm/AudioFormat.hxx
+17
-17
No files found.
src/pcm/AudioFormat.hxx
View file @
1cb7fe12
...
@@ -63,14 +63,14 @@ struct AudioFormat {
...
@@ -63,14 +63,14 @@ struct AudioFormat {
*/
*/
uint8_t
channels
;
uint8_t
channels
;
AudioFormat
()
=
default
;
AudioFormat
()
noexcept
=
default
;
constexpr
AudioFormat
(
uint32_t
_sample_rate
,
constexpr
AudioFormat
(
uint32_t
_sample_rate
,
SampleFormat
_format
,
uint8_t
_channels
)
SampleFormat
_format
,
uint8_t
_channels
)
noexcept
:
sample_rate
(
_sample_rate
),
:
sample_rate
(
_sample_rate
),
format
(
_format
),
channels
(
_channels
)
{}
format
(
_format
),
channels
(
_channels
)
{}
static
constexpr
AudioFormat
Undefined
()
{
static
constexpr
AudioFormat
Undefined
()
noexcept
{
return
AudioFormat
(
0
,
SampleFormat
::
UNDEFINED
,
0
);
return
AudioFormat
(
0
,
SampleFormat
::
UNDEFINED
,
0
);
}
}
...
@@ -78,7 +78,7 @@ struct AudioFormat {
...
@@ -78,7 +78,7 @@ struct AudioFormat {
* Clears the object, i.e. sets all attributes to an undefined
* Clears the object, i.e. sets all attributes to an undefined
* (invalid) value.
* (invalid) value.
*/
*/
void
Clear
()
{
void
Clear
()
noexcept
{
sample_rate
=
0
;
sample_rate
=
0
;
format
=
SampleFormat
::
UNDEFINED
;
format
=
SampleFormat
::
UNDEFINED
;
channels
=
0
;
channels
=
0
;
...
@@ -87,7 +87,7 @@ struct AudioFormat {
...
@@ -87,7 +87,7 @@ struct AudioFormat {
/**
/**
* Checks whether the object has a defined value.
* Checks whether the object has a defined value.
*/
*/
constexpr
bool
IsDefined
()
const
{
constexpr
bool
IsDefined
()
const
noexcept
{
return
sample_rate
!=
0
;
return
sample_rate
!=
0
;
}
}
...
@@ -96,7 +96,7 @@ struct AudioFormat {
...
@@ -96,7 +96,7 @@ struct AudioFormat {
* defined. This is more complete than IsDefined(), but
* defined. This is more complete than IsDefined(), but
* slower.
* slower.
*/
*/
constexpr
bool
IsFullyDefined
()
const
{
constexpr
bool
IsFullyDefined
()
const
noexcept
{
return
sample_rate
!=
0
&&
format
!=
SampleFormat
::
UNDEFINED
&&
return
sample_rate
!=
0
&&
format
!=
SampleFormat
::
UNDEFINED
&&
channels
!=
0
;
channels
!=
0
;
}
}
...
@@ -104,21 +104,21 @@ struct AudioFormat {
...
@@ -104,21 +104,21 @@ struct AudioFormat {
/**
/**
* Checks whether the object has at least one defined value.
* Checks whether the object has at least one defined value.
*/
*/
constexpr
bool
IsMaskDefined
()
const
{
constexpr
bool
IsMaskDefined
()
const
noexcept
{
return
sample_rate
!=
0
||
format
!=
SampleFormat
::
UNDEFINED
||
return
sample_rate
!=
0
||
format
!=
SampleFormat
::
UNDEFINED
||
channels
!=
0
;
channels
!=
0
;
}
}
bool
IsValid
()
const
;
bool
IsValid
()
const
noexcept
;
bool
IsMaskValid
()
const
;
bool
IsMaskValid
()
const
noexcept
;
constexpr
bool
operator
==
(
const
AudioFormat
other
)
const
{
constexpr
bool
operator
==
(
const
AudioFormat
other
)
const
noexcept
{
return
sample_rate
==
other
.
sample_rate
&&
return
sample_rate
==
other
.
sample_rate
&&
format
==
other
.
format
&&
format
==
other
.
format
&&
channels
==
other
.
channels
;
channels
==
other
.
channels
;
}
}
constexpr
bool
operator
!=
(
const
AudioFormat
other
)
const
{
constexpr
bool
operator
!=
(
const
AudioFormat
other
)
const
noexcept
{
return
!
(
*
this
==
other
);
return
!
(
*
this
==
other
);
}
}
...
@@ -139,12 +139,12 @@ struct AudioFormat {
...
@@ -139,12 +139,12 @@ struct AudioFormat {
/**
/**
* Returns the size of each (mono) sample in bytes.
* Returns the size of each (mono) sample in bytes.
*/
*/
unsigned
GetSampleSize
()
const
;
unsigned
GetSampleSize
()
const
noexcept
;
/**
/**
* Returns the size of each full frame in bytes.
* Returns the size of each full frame in bytes.
*/
*/
unsigned
GetFrameSize
()
const
;
unsigned
GetFrameSize
()
const
noexcept
;
template
<
typename
D
>
template
<
typename
D
>
constexpr
auto
TimeToFrames
(
D
t
)
const
noexcept
{
constexpr
auto
TimeToFrames
(
D
t
)
const
noexcept
{
...
@@ -186,7 +186,7 @@ audio_valid_sample_rate(unsigned sample_rate) noexcept
...
@@ -186,7 +186,7 @@ audio_valid_sample_rate(unsigned sample_rate) noexcept
* This function performs some basic validity checks.
* This function performs some basic validity checks.
*/
*/
inline
bool
inline
bool
AudioFormat
::
IsValid
()
const
AudioFormat
::
IsValid
()
const
noexcept
{
{
return
audio_valid_sample_rate
(
sample_rate
)
&&
return
audio_valid_sample_rate
(
sample_rate
)
&&
audio_valid_sample_format
(
format
)
&&
audio_valid_sample_format
(
format
)
&&
...
@@ -198,7 +198,7 @@ AudioFormat::IsValid() const
...
@@ -198,7 +198,7 @@ AudioFormat::IsValid() const
* MPD. This function performs some basic validity checks.
* MPD. This function performs some basic validity checks.
*/
*/
inline
bool
inline
bool
AudioFormat
::
IsMaskValid
()
const
AudioFormat
::
IsMaskValid
()
const
noexcept
{
{
return
(
sample_rate
==
0
||
return
(
sample_rate
==
0
||
audio_valid_sample_rate
(
sample_rate
))
&&
audio_valid_sample_rate
(
sample_rate
))
&&
...
@@ -208,13 +208,13 @@ AudioFormat::IsMaskValid() const
...
@@ -208,13 +208,13 @@ AudioFormat::IsMaskValid() const
}
}
inline
unsigned
inline
unsigned
AudioFormat
::
GetSampleSize
()
const
AudioFormat
::
GetSampleSize
()
const
noexcept
{
{
return
sample_format_size
(
format
);
return
sample_format_size
(
format
);
}
}
inline
unsigned
inline
unsigned
AudioFormat
::
GetFrameSize
()
const
AudioFormat
::
GetFrameSize
()
const
noexcept
{
{
return
GetSampleSize
()
*
channels
;
return
GetSampleSize
()
*
channels
;
}
}
...
...
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