summaryrefslogtreecommitdiff
path: root/src/mixer
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-05-08 14:44:49 +0200
committerMax Kellermann <max@musicpd.org>2017-05-08 14:44:49 +0200
commit71f0ed8b7499011b53f90998ebfbd3250fd80948 (patch)
treee9c2f66fbef231858f46d878864199d46e6ce21c /src/mixer
parentac2e4e593d407e41db49fdb9ae2da6bc1557f618 (diff)
*: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to consider these functions throwing.
Diffstat (limited to 'src/mixer')
-rw-r--r--src/mixer/MixerAll.cxx15
-rw-r--r--src/mixer/MixerType.cxx2
-rw-r--r--src/mixer/MixerType.hxx5
-rw-r--r--src/mixer/Volume.cxx6
-rw-r--r--src/mixer/Volume.hxx6
-rw-r--r--src/mixer/plugins/AlsaMixerPlugin.cxx3
-rw-r--r--src/mixer/plugins/SoftwareMixerPlugin.cxx2
7 files changed, 22 insertions, 17 deletions
diff --git a/src/mixer/MixerAll.cxx b/src/mixer/MixerAll.cxx
index e9bcde93a..d45e51ae4 100644
--- a/src/mixer/MixerAll.cxx
+++ b/src/mixer/MixerAll.cxx
@@ -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);
diff --git a/src/mixer/MixerType.cxx b/src/mixer/MixerType.cxx
index cfc0edab9..e792123df 100644
--- a/src/mixer/MixerType.cxx
+++ b/src/mixer/MixerType.cxx
@@ -24,7 +24,7 @@
#include <string.h>
MixerType
-mixer_type_parse(const char *input)
+mixer_type_parse(const char *input) noexcept
{
assert(input != NULL);
diff --git a/src/mixer/MixerType.hxx b/src/mixer/MixerType.hxx
index 0c5b55031..6c6d4cb47 100644
--- a/src/mixer/MixerType.hxx
+++ b/src/mixer/MixerType.hxx
@@ -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
diff --git a/src/mixer/Volume.cxx b/src/mixer/Volume.cxx
index 365136240..c85dc8b8f 100644
--- a/src/mixer/Volume.cxx
+++ b/src/mixer/Volume.cxx
@@ -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;
}
diff --git a/src/mixer/Volume.hxx b/src/mixer/Volume.hxx
index c74786469..5ca467d77 100644
--- a/src/mixer/Volume.hxx
+++ b/src/mixer/Volume.hxx
@@ -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
diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx
index 85ccdf8dd..8012ca2fb 100644
--- a/src/mixer/plugins/AlsaMixerPlugin.cxx
+++ b/src/mixer/plugins/AlsaMixerPlugin.cxx
@@ -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)) {
diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx
index 69491390d..14c35e7f1 100644
--- a/src/mixer/plugins/SoftwareMixerPlugin.cxx
+++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx
@@ -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);