*: 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:
@@ -30,8 +30,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
gcc_pure
|
||||
static int
|
||||
output_mixer_get_volume(const AudioOutput &ao)
|
||||
output_mixer_get_volume(const AudioOutput &ao) noexcept
|
||||
{
|
||||
if (!ao.enabled)
|
||||
return -1;
|
||||
@@ -51,7 +52,7 @@ output_mixer_get_volume(const AudioOutput &ao)
|
||||
}
|
||||
|
||||
int
|
||||
MultipleOutputs::GetVolume() const
|
||||
MultipleOutputs::GetVolume() const noexcept
|
||||
{
|
||||
unsigned ok = 0;
|
||||
int total = 0;
|
||||
@@ -71,7 +72,7 @@ MultipleOutputs::GetVolume() const
|
||||
}
|
||||
|
||||
static bool
|
||||
output_mixer_set_volume(AudioOutput &ao, unsigned volume)
|
||||
output_mixer_set_volume(AudioOutput &ao, unsigned volume) noexcept
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
@@ -94,7 +95,7 @@ output_mixer_set_volume(AudioOutput &ao, unsigned volume)
|
||||
}
|
||||
|
||||
bool
|
||||
MultipleOutputs::SetVolume(unsigned volume)
|
||||
MultipleOutputs::SetVolume(unsigned volume) noexcept
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
@@ -107,7 +108,7 @@ MultipleOutputs::SetVolume(unsigned volume)
|
||||
}
|
||||
|
||||
static int
|
||||
output_mixer_get_software_volume(const AudioOutput &ao)
|
||||
output_mixer_get_software_volume(const AudioOutput &ao) noexcept
|
||||
{
|
||||
if (!ao.enabled)
|
||||
return -1;
|
||||
@@ -120,7 +121,7 @@ output_mixer_get_software_volume(const AudioOutput &ao)
|
||||
}
|
||||
|
||||
int
|
||||
MultipleOutputs::GetSoftwareVolume() const
|
||||
MultipleOutputs::GetSoftwareVolume() const noexcept
|
||||
{
|
||||
unsigned ok = 0;
|
||||
int total = 0;
|
||||
@@ -140,7 +141,7 @@ MultipleOutputs::GetSoftwareVolume() const
|
||||
}
|
||||
|
||||
void
|
||||
MultipleOutputs::SetSoftwareVolume(unsigned volume)
|
||||
MultipleOutputs::SetSoftwareVolume(unsigned volume) noexcept
|
||||
{
|
||||
assert(volume <= PCM_VOLUME_1);
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include <string.h>
|
||||
|
||||
MixerType
|
||||
mixer_type_parse(const char *input)
|
||||
mixer_type_parse(const char *input) noexcept
|
||||
{
|
||||
assert(input != NULL);
|
||||
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#ifndef MPD_MIXER_TYPE_HXX
|
||||
#define MPD_MIXER_TYPE_HXX
|
||||
|
||||
#include "Compiler.h"
|
||||
|
||||
enum class MixerType {
|
||||
/** parser error */
|
||||
UNKNOWN,
|
||||
@@ -44,7 +46,8 @@ enum class MixerType {
|
||||
* a #MixerType value; #MixerType::UNKNOWN means #input could not be
|
||||
* parsed
|
||||
*/
|
||||
gcc_pure
|
||||
MixerType
|
||||
mixer_type_parse(const char *input);
|
||||
mixer_type_parse(const char *input) noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -42,14 +42,14 @@ static int last_hardware_volume = -1;
|
||||
static PeriodClock hardware_volume_clock;
|
||||
|
||||
void
|
||||
InvalidateHardwareVolume()
|
||||
InvalidateHardwareVolume() noexcept
|
||||
{
|
||||
/* flush the hardware volume cache */
|
||||
last_hardware_volume = -1;
|
||||
}
|
||||
|
||||
int
|
||||
volume_level_get(const MultipleOutputs &outputs)
|
||||
volume_level_get(const MultipleOutputs &outputs) noexcept
|
||||
{
|
||||
if (last_hardware_volume >= 0 &&
|
||||
!hardware_volume_clock.CheckUpdate(std::chrono::seconds(1)))
|
||||
@@ -118,7 +118,7 @@ save_sw_volume_state(BufferedOutputStream &os)
|
||||
}
|
||||
|
||||
unsigned
|
||||
sw_volume_state_get_hash(void)
|
||||
sw_volume_state_get_hash() noexcept
|
||||
{
|
||||
return volume_software_set;
|
||||
}
|
||||
|
@@ -26,11 +26,11 @@ class MultipleOutputs;
|
||||
class BufferedOutputStream;
|
||||
|
||||
void
|
||||
InvalidateHardwareVolume();
|
||||
InvalidateHardwareVolume() noexcept;
|
||||
|
||||
gcc_pure
|
||||
int
|
||||
volume_level_get(const MultipleOutputs &outputs);
|
||||
volume_level_get(const MultipleOutputs &outputs) noexcept;
|
||||
|
||||
bool
|
||||
volume_level_change(MultipleOutputs &outputs, unsigned volume);
|
||||
@@ -49,6 +49,6 @@ save_sw_volume_state(BufferedOutputStream &os);
|
||||
*/
|
||||
gcc_pure
|
||||
unsigned
|
||||
sw_volume_state_get_hash();
|
||||
sw_volume_state_get_hash() noexcept;
|
||||
|
||||
#endif
|
||||
|
@@ -201,7 +201,8 @@ AlsaMixer::~AlsaMixer()
|
||||
|
||||
gcc_pure
|
||||
static snd_mixer_elem_t *
|
||||
alsa_mixer_lookup_elem(snd_mixer_t *handle, const char *name, unsigned idx)
|
||||
alsa_mixer_lookup_elem(snd_mixer_t *handle,
|
||||
const char *name, unsigned idx) noexcept
|
||||
{
|
||||
for (snd_mixer_elem_t *elem = snd_mixer_first_elem(handle);
|
||||
elem != nullptr; elem = snd_mixer_elem_next(elem)) {
|
||||
|
@@ -71,7 +71,7 @@ software_mixer_init(gcc_unused EventLoop &event_loop,
|
||||
|
||||
gcc_const
|
||||
static unsigned
|
||||
PercentVolumeToSoftwareVolume(unsigned volume)
|
||||
PercentVolumeToSoftwareVolume(unsigned volume) noexcept
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
|
Reference in New Issue
Block a user