*: 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:
Max Kellermann
2017-05-08 14:44:49 +02:00
parent ac2e4e593d
commit 71f0ed8b74
272 changed files with 873 additions and 846 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ audio_output_detect()
*/
gcc_pure
static MixerType
audio_output_mixer_type(const ConfigBlock &block)
audio_output_mixer_type(const ConfigBlock &block) noexcept
{
/* read the local "mixer_type" setting */
const char *p = block.GetBlockValue("mixer_type");
+1 -1
View File
@@ -21,7 +21,7 @@
#include "Internal.hxx"
bool
AudioOutput::IsChunkConsumed(const MusicChunk &chunk) const
AudioOutput::IsChunkConsumed(const MusicChunk &chunk) const noexcept
{
if (!open)
return true;
+2 -2
View File
@@ -436,10 +436,10 @@ public:
* Caller must lock the mutex.
*/
gcc_pure
bool IsChunkConsumed(const MusicChunk &chunk) const;
bool IsChunkConsumed(const MusicChunk &chunk) const noexcept;
gcc_pure
bool LockIsChunkConsumed(const MusicChunk &chunk) {
bool LockIsChunkConsumed(const MusicChunk &chunk) noexcept {
const std::lock_guard<Mutex> protect(mutex);
return IsChunkConsumed(chunk);
}
+4 -4
View File
@@ -94,7 +94,7 @@ MultipleOutputs::Configure(EventLoop &event_loop,
}
AudioOutput *
MultipleOutputs::FindByName(const char *name) const
MultipleOutputs::FindByName(const char *name) const noexcept
{
for (auto i : outputs)
if (strcmp(i->GetName(), name) == 0)
@@ -120,7 +120,7 @@ MultipleOutputs::EnableDisable()
}
bool
MultipleOutputs::AllFinished() const
MultipleOutputs::AllFinished() const noexcept
{
for (auto ao : outputs) {
const std::lock_guard<Mutex> protect(ao->mutex);
@@ -132,7 +132,7 @@ MultipleOutputs::AllFinished() const
}
void
MultipleOutputs::WaitAll()
MultipleOutputs::WaitAll() noexcept
{
while (!AllFinished())
audio_output_client_notify.Wait();
@@ -243,7 +243,7 @@ MultipleOutputs::Open(const AudioFormat audio_format,
}
bool
MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const
MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const noexcept
{
for (auto ao : outputs)
if (!ao->LockIsChunkConsumed(*chunk))
+8 -8
View File
@@ -109,7 +109,7 @@ public:
* Returns nullptr if the name does not exist.
*/
gcc_pure
AudioOutput *FindByName(const char *name) const;
AudioOutput *FindByName(const char *name) const noexcept;
/**
* Checks the "enabled" flag of all audio outputs, and if one has
@@ -195,7 +195,7 @@ public:
* 0..100). Returns -1 if no mixer can be queried.
*/
gcc_pure
int GetVolume() const;
int GetVolume() const noexcept;
/**
* Sets the volume on all available mixers.
@@ -203,7 +203,7 @@ public:
* @param volume the volume (range 0..100)
* @return true on success, false on failure
*/
bool SetVolume(unsigned volume);
bool SetVolume(unsigned volume) noexcept;
/**
* Similar to GetVolume(), but gets the volume only for
@@ -211,7 +211,7 @@ public:
* function fails if no software mixer is configured.
*/
gcc_pure
int GetSoftwareVolume() const;
int GetSoftwareVolume() const noexcept;
/**
* Similar to SetVolume(), but sets the volume only for
@@ -219,7 +219,7 @@ public:
* function cannot fail, because the underlying software
* mixers cannot fail either.
*/
void SetSoftwareVolume(unsigned volume);
void SetSoftwareVolume(unsigned volume) noexcept;
private:
/**
@@ -227,9 +227,9 @@ private:
* command.
*/
gcc_pure
bool AllFinished() const;
bool AllFinished() const noexcept;
void WaitAll();
void WaitAll() noexcept;
/**
* Signals all audio outputs which are open.
@@ -247,7 +247,7 @@ private:
/**
* Has this chunk been consumed by all audio outputs?
*/
bool IsChunkConsumed(const MusicChunk *chunk) const;
bool IsChunkConsumed(const MusicChunk *chunk) const noexcept;
/**
* There's only one chunk left in the pipe (#pipe), and all
+1 -1
View File
@@ -64,7 +64,7 @@ ao_plugin_close(AudioOutput *ao)
}
std::chrono::steady_clock::duration
ao_plugin_delay(AudioOutput *ao)
ao_plugin_delay(AudioOutput *ao) noexcept
{
return ao->plugin.delay != nullptr
? ao->plugin.delay(ao)
+2 -2
View File
@@ -101,7 +101,7 @@ struct AudioOutputPlugin {
*
* @return the duration to wait
*/
std::chrono::steady_clock::duration (*delay)(AudioOutput *data);
std::chrono::steady_clock::duration (*delay)(AudioOutput *data) noexcept;
/**
* Display metadata for the next chunk. Optional method,
@@ -182,7 +182,7 @@ ao_plugin_close(AudioOutput *ao);
gcc_pure
std::chrono::steady_clock::duration
ao_plugin_delay(AudioOutput *ao);
ao_plugin_delay(AudioOutput *ao) noexcept;
void
ao_plugin_send_tag(AudioOutput *ao, const Tag &tag);
+2 -2
View File
@@ -23,7 +23,7 @@
#include "MusicPipe.hxx"
const MusicChunk *
SharedPipeConsumer::Get()
SharedPipeConsumer::Get() noexcept
{
if (chunk != nullptr) {
if (!consumed)
@@ -42,7 +42,7 @@ SharedPipeConsumer::Get()
}
bool
SharedPipeConsumer::IsConsumed(const MusicChunk &_chunk) const
SharedPipeConsumer::IsConsumed(const MusicChunk &_chunk) const noexcept
{
if (chunk == nullptr)
return false;
+3 -3
View File
@@ -75,7 +75,7 @@ public:
chunk = nullptr;
}
const MusicChunk *Get();
const MusicChunk *Get() noexcept;
void Consume(gcc_unused const MusicChunk &_chunk) {
assert(chunk != nullptr);
@@ -85,9 +85,9 @@ public:
}
gcc_pure
bool IsConsumed(const MusicChunk &_chunk) const;
bool IsConsumed(const MusicChunk &_chunk) const noexcept;
void ClearTail(gcc_unused const MusicChunk &_chunk) {
void ClearTail(gcc_unused const MusicChunk &_chunk) noexcept {
assert(chunk == &_chunk);
assert(consumed);
chunk = nullptr;
+3 -3
View File
@@ -60,7 +60,7 @@ AudioOutputSource::Open(AudioFormat audio_format, const MusicPipe &_pipe,
}
void
AudioOutputSource::Close()
AudioOutputSource::Close() noexcept
{
assert(in_audio_format.IsValid());
in_audio_format.Clear();
@@ -71,7 +71,7 @@ AudioOutputSource::Close()
}
void
AudioOutputSource::Cancel()
AudioOutputSource::Cancel() noexcept
{
current_chunk = nullptr;
pipe.Cancel();
@@ -114,7 +114,7 @@ try {
}
void
AudioOutputSource::CloseFilter()
AudioOutputSource::CloseFilter() noexcept
{
delete replay_gain_filter_instance;
replay_gain_filter_instance = nullptr;
+5 -5
View File
@@ -138,8 +138,8 @@ public:
PreparedFilter *prepared_other_replay_gain_filter,
PreparedFilter *prepared_filter);
void Close();
void Cancel();
void Close() noexcept;
void Cancel() noexcept;
/**
* Ensure that ReadTag() or PeekData() return any input.
@@ -181,13 +181,13 @@ public:
*/
void ConsumeData(size_t nbytes) noexcept;
bool IsChunkConsumed(const MusicChunk &chunk) const {
bool IsChunkConsumed(const MusicChunk &chunk) const noexcept {
assert(IsOpen());
return pipe.IsConsumed(chunk);
}
void ClearTailChunk(const MusicChunk &chunk) {
void ClearTailChunk(const MusicChunk &chunk) noexcept {
pipe.ClearTail(chunk);
}
@@ -197,7 +197,7 @@ private:
PreparedFilter *prepared_other_replay_gain_filter,
PreparedFilter *prepared_filter);
void CloseFilter();
void CloseFilter() noexcept;
ConstBuffer<void> GetChunkData(const MusicChunk &chunk,
Filter *replay_gain_filter,
+1 -1
View File
@@ -63,7 +63,7 @@ struct AudioOutputWrapper {
}
gcc_pure
static std::chrono::steady_clock::duration Delay(AudioOutput *ao) {
static std::chrono::steady_clock::duration Delay(AudioOutput *ao) noexcept {
T &t = Cast(*ao);
return t.Delay();
}
+2 -2
View File
@@ -249,7 +249,7 @@ alsa_test_default_device()
*/
gcc_const
static snd_pcm_format_t
ToAlsaPcmFormat(SampleFormat sample_format)
ToAlsaPcmFormat(SampleFormat sample_format) noexcept
{
switch (sample_format) {
case SampleFormat::UNDEFINED:
@@ -287,7 +287,7 @@ ToAlsaPcmFormat(SampleFormat sample_format)
* SND_PCM_FORMAT_UNKNOWN if the format cannot be byte-swapped.
*/
static snd_pcm_format_t
ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt)
ByteSwapAlsaPcmFormat(snd_pcm_format_t fmt) noexcept
{
switch (fmt) {
case SND_PCM_FORMAT_S16_LE: return SND_PCM_FORMAT_S16_BE;
+2 -2
View File
@@ -66,7 +66,7 @@ public:
void Open(AudioFormat &audio_format);
void Close();
std::chrono::steady_clock::duration Delay() const;
std::chrono::steady_clock::duration Delay() const noexcept;
size_t Play(const void *chunk, size_t size);
void Cancel();
};
@@ -205,7 +205,7 @@ FifoOutput::Cancel()
}
inline std::chrono::steady_clock::duration
FifoOutput::Delay() const
FifoOutput::Delay() const noexcept
{
return timer->IsStarted()
? timer->GetDelay()
+3 -3
View File
@@ -119,7 +119,7 @@ struct JackOutput {
* on all channels.
*/
gcc_pure
jack_nframes_t GetAvailable() const;
jack_nframes_t GetAvailable() const noexcept;
void Process(jack_nframes_t nframes);
@@ -128,7 +128,7 @@ struct JackOutput {
*/
size_t WriteSamples(const float *src, size_t n_frames);
std::chrono::steady_clock::duration Delay() const {
std::chrono::steady_clock::duration Delay() const noexcept {
return base.pause && pause && !shutdown
? std::chrono::seconds(1)
: std::chrono::steady_clock::duration::zero();
@@ -215,7 +215,7 @@ JackOutput::JackOutput(const ConfigBlock &block)
}
inline jack_nframes_t
JackOutput::GetAvailable() const
JackOutput::GetAvailable() const noexcept
{
size_t min = jack_ringbuffer_read_space(ringbuffer[0]);
+1 -1
View File
@@ -49,7 +49,7 @@ public:
delete timer;
}
std::chrono::steady_clock::duration Delay() const {
std::chrono::steady_clock::duration Delay() const noexcept {
return sync && timer->IsStarted()
? timer->GetDelay()
: std::chrono::steady_clock::duration::zero();
+1 -1
View File
@@ -58,7 +58,7 @@ class OpenALOutput {
void Close();
gcc_pure
std::chrono::steady_clock::duration Delay() const {
std::chrono::steady_clock::duration Delay() const noexcept {
return filled < NUM_BUFFERS || HasProcessed()
? std::chrono::steady_clock::duration::zero()
/* we don't know exactly how long we must wait
+2 -2
View File
@@ -391,7 +391,7 @@ oss_setup_sample_rate(int fd, AudioFormat &audio_format)
*/
gcc_const
static int
sample_format_to_oss(SampleFormat format)
sample_format_to_oss(SampleFormat format) noexcept
{
switch (format) {
case SampleFormat::UNDEFINED:
@@ -430,7 +430,7 @@ sample_format_to_oss(SampleFormat format)
*/
gcc_const
static SampleFormat
sample_format_from_oss(int format)
sample_format_from_oss(int format) noexcept
{
switch (format) {
case AFMT_S8:
-1
View File
@@ -90,7 +90,6 @@ public:
Signal();
}
gcc_const
static bool TestDefaultDevice();
static PulseOutput *Create(const ConfigBlock &block);
+1 -1
View File
@@ -73,7 +73,7 @@ static constexpr Domain roar_output_domain("roar_output");
gcc_pure
static int
GetConfiguredRole(const ConfigBlock &block)
GetConfiguredRole(const ConfigBlock &block) noexcept
{
const char *role = block.GetBlockValue("role");
return role != nullptr
+2 -2
View File
@@ -63,7 +63,7 @@ struct ShoutOutput final {
void Open(AudioFormat &audio_format);
void Close();
std::chrono::steady_clock::duration Delay() const;
std::chrono::steady_clock::duration Delay() const noexcept;
void SendTag(const Tag &tag);
size_t Play(const void *chunk, size_t size);
void Cancel();
@@ -361,7 +361,7 @@ ShoutOutput::Open(AudioFormat &audio_format)
}
std::chrono::steady_clock::duration
ShoutOutput::Delay() const
ShoutOutput::Delay() const noexcept
{
int delay = shout_delay(shout_conn);
if (delay < 0)
+1 -1
View File
@@ -260,7 +260,7 @@ HttpdClient::TryWritePageN(const Page &page, size_t position, ssize_t n)
}
ssize_t
HttpdClient::GetBytesTillMetaData() const
HttpdClient::GetBytesTillMetaData() const noexcept
{
if (metadata_requested &&
current_page->size - current_position > metaint - metadata_fill)
+1 -1
View File
@@ -168,7 +168,7 @@ public:
bool SendResponse();
gcc_pure
ssize_t GetBytesTillMetaData() const;
ssize_t GetBytesTillMetaData() const noexcept;
ssize_t TryWritePage(const Page &page, size_t position);
ssize_t TryWritePageN(const Page &page, size_t position, ssize_t n);
+1 -1
View File
@@ -218,7 +218,7 @@ public:
void SendHeader(HttpdClient &client) const;
gcc_pure
std::chrono::steady_clock::duration Delay() const;
std::chrono::steady_clock::duration Delay() const noexcept;
/**
* Reads data from the encoder (as much as available) and
@@ -345,7 +345,7 @@ HttpdOutput::SendHeader(HttpdClient &client) const
}
inline std::chrono::steady_clock::duration
HttpdOutput::Delay() const
HttpdOutput::Delay() const noexcept
{
if (!LockHasClients() && base.pause) {
/* if there's no client and this output is paused,
@@ -366,7 +366,7 @@ HttpdOutput::Delay() const
}
static std::chrono::steady_clock::duration
httpd_output_delay(AudioOutput *ao)
httpd_output_delay(AudioOutput *ao) noexcept
{
HttpdOutput *httpd = HttpdOutput::Cast(ao);