diff --git a/src/decoder/plugins/FlacCommon.cxx b/src/decoder/plugins/FlacCommon.cxx index 8e3bbce31..e2ebde08c 100644 --- a/src/decoder/plugins/FlacCommon.cxx +++ b/src/decoder/plugins/FlacCommon.cxx @@ -30,7 +30,7 @@ bool FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample, - unsigned channels, FLAC__uint64 total_frames) + unsigned channels, FLAC__uint64 total_frames) noexcept { assert(!initialized); assert(!unsupported); @@ -60,7 +60,7 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample, } inline void -FlacDecoder::OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info) +FlacDecoder::OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info) noexcept { if (initialized) return; @@ -72,7 +72,7 @@ FlacDecoder::OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info) } inline void -FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc) +FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc) noexcept { ReplayGainInfo rgi; if (flac_parse_replay_gain(rgi, vc)) @@ -86,7 +86,7 @@ FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc) } void -FlacDecoder::OnMetadata(const FLAC__StreamMetadata &metadata) +FlacDecoder::OnMetadata(const FLAC__StreamMetadata &metadata) noexcept { if (unsupported) return; @@ -106,7 +106,7 @@ FlacDecoder::OnMetadata(const FLAC__StreamMetadata &metadata) } inline bool -FlacDecoder::OnFirstFrame(const FLAC__FrameHeader &header) +FlacDecoder::OnFirstFrame(const FLAC__FrameHeader &header) noexcept { if (unsupported) return false; @@ -139,7 +139,7 @@ FlacDecoder::GetDeltaPosition(const FLAC__StreamDecoder &sd) FLAC__StreamDecoderWriteStatus FlacDecoder::OnWrite(const FLAC__Frame &frame, const FLAC__int32 *const buf[], - FLAC__uint64 nbytes) + FLAC__uint64 nbytes) noexcept { if (!initialized && !OnFirstFrame(frame.header)) return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; diff --git a/src/decoder/plugins/FlacCommon.hxx b/src/decoder/plugins/FlacCommon.hxx index 533c38307..032d25364 100644 --- a/src/decoder/plugins/FlacCommon.hxx +++ b/src/decoder/plugins/FlacCommon.hxx @@ -65,20 +65,21 @@ struct FlacDecoder : public FlacInput { */ ConstBuffer chunk = nullptr; - FlacDecoder(DecoderClient &_client, InputStream &_input_stream) + FlacDecoder(DecoderClient &_client, + InputStream &_input_stream) noexcept :FlacInput(_input_stream, &_client) {} /** * Wrapper for DecoderClient::Ready(). */ bool Initialize(unsigned sample_rate, unsigned bits_per_sample, - unsigned channels, FLAC__uint64 total_frames); + unsigned channels, FLAC__uint64 total_frames) noexcept; - void OnMetadata(const FLAC__StreamMetadata &metadata); + void OnMetadata(const FLAC__StreamMetadata &metadata) noexcept; FLAC__StreamDecoderWriteStatus OnWrite(const FLAC__Frame &frame, const FLAC__int32 *const buf[], - FLAC__uint64 nbytes); + FLAC__uint64 nbytes) noexcept; /** * Calculate the delta (in bytes) between the last frame and @@ -87,8 +88,8 @@ struct FlacDecoder : public FlacInput { FLAC__uint64 GetDeltaPosition(const FLAC__StreamDecoder &sd); private: - void OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info); - void OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc); + void OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info) noexcept; + void OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc) noexcept; /** * This function attempts to call DecoderClient::Ready() in case there @@ -97,7 +98,7 @@ private: * providing the STREAMINFO block from the beginning of the file * (e.g. when seeking with SqueezeBox Server). */ - bool OnFirstFrame(const FLAC__FrameHeader &header); + bool OnFirstFrame(const FLAC__FrameHeader &header) noexcept; }; #endif /* _FLAC_COMMON_H */ diff --git a/src/decoder/plugins/FlacDecoderPlugin.cxx b/src/decoder/plugins/FlacDecoderPlugin.cxx index 80d124127..da0374f7a 100644 --- a/src/decoder/plugins/FlacDecoderPlugin.cxx +++ b/src/decoder/plugins/FlacDecoderPlugin.cxx @@ -32,7 +32,8 @@ #error libFLAC is too old #endif -static void flacPrintErroredState(FLAC__StreamDecoderState state) +static void +flacPrintErroredState(FLAC__StreamDecoderState state) noexcept { switch (state) { case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: @@ -53,8 +54,9 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state) LogError(flac_domain, FLAC__StreamDecoderStateString[state]); } -static void flacMetadata([[maybe_unused]] const FLAC__StreamDecoder * dec, - const FLAC__StreamMetadata * block, void *vdata) +static void +flacMetadata([[maybe_unused]] const FLAC__StreamDecoder * dec, + const FLAC__StreamMetadata * block, void *vdata) noexcept { auto &fd = *(FlacDecoder *)vdata; fd.OnMetadata(*block); @@ -62,14 +64,14 @@ static void flacMetadata([[maybe_unused]] const FLAC__StreamDecoder * dec, static FLAC__StreamDecoderWriteStatus flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame, - const FLAC__int32 *const buf[], void *vdata) + const FLAC__int32 *const buf[], void *vdata) noexcept { auto &fd = *(FlacDecoder *)vdata; return fd.OnWrite(*frame, buf, fd.GetDeltaPosition(*dec)); } static bool -flac_scan_file(Path path_fs, TagHandler &handler) +flac_scan_file(Path path_fs, TagHandler &handler) noexcept { FlacMetadataChain chain; if (!chain.Read(NarrowPath(path_fs))) { @@ -84,7 +86,7 @@ flac_scan_file(Path path_fs, TagHandler &handler) } static bool -flac_scan_stream(InputStream &is, TagHandler &handler) +flac_scan_stream(InputStream &is, TagHandler &handler) noexcept { FlacMetadataChain chain; if (!chain.Read(is)) { @@ -102,7 +104,7 @@ flac_scan_stream(InputStream &is, TagHandler &handler) * Some glue code around FLAC__stream_decoder_new(). */ static FlacStreamDecoder -flac_decoder_new() +flac_decoder_new() noexcept { FlacStreamDecoder sd; if(!FLAC__stream_decoder_set_metadata_respond(sd.get(), FLAC__METADATA_TYPE_VORBIS_COMMENT)) @@ -113,7 +115,7 @@ flac_decoder_new() } static bool -flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd) +flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd) noexcept { if (!FLAC__stream_decoder_process_until_end_of_metadata(sd)) { if (FLAC__stream_decoder_get_state(sd) != FLAC__STREAM_DECODER_END_OF_STREAM) @@ -231,7 +233,7 @@ flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec) } static FLAC__StreamDecoderInitStatus -stream_init_oggflac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) +stream_init_oggflac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) noexcept { return FLAC__stream_decoder_init_ogg_stream(flac_dec, FlacInput::Read, @@ -246,7 +248,7 @@ stream_init_oggflac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) } static FLAC__StreamDecoderInitStatus -stream_init_flac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) +stream_init_flac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) noexcept { return FLAC__stream_decoder_init_stream(flac_dec, FlacInput::Read, @@ -261,7 +263,8 @@ stream_init_flac(FLAC__StreamDecoder *flac_dec, FlacDecoder *data) } static FLAC__StreamDecoderInitStatus -stream_init(FLAC__StreamDecoder *flac_dec, FlacDecoder *data, bool is_ogg) +stream_init(FLAC__StreamDecoder *flac_dec, FlacDecoder *data, + bool is_ogg) noexcept { return is_ogg ? stream_init_oggflac(flac_dec, data) @@ -307,7 +310,7 @@ flac_decode(DecoderClient &client, InputStream &input_stream) } static bool -oggflac_init([[maybe_unused]] const ConfigBlock &block) +oggflac_init([[maybe_unused]] const ConfigBlock &block) noexcept { return !!FLAC_API_SUPPORTS_OGG_FLAC; } diff --git a/src/decoder/plugins/FlacInput.cxx b/src/decoder/plugins/FlacInput.cxx index caea926e7..df1a51360 100644 --- a/src/decoder/plugins/FlacInput.cxx +++ b/src/decoder/plugins/FlacInput.cxx @@ -22,12 +22,11 @@ #include "../DecoderAPI.hxx" #include "input/InputStream.hxx" #include "Log.hxx" -#include "util/Compiler.h" #include -FLAC__StreamDecoderReadStatus -FlacInput::Read(FLAC__byte buffer[], size_t *bytes) +inline FLAC__StreamDecoderReadStatus +FlacInput::Read(FLAC__byte buffer[], size_t *bytes) noexcept { size_t r = decoder_read(client, input_stream, (void *)buffer, *bytes); *bytes = r; @@ -44,8 +43,8 @@ FlacInput::Read(FLAC__byte buffer[], size_t *bytes) return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; } -FLAC__StreamDecoderSeekStatus -FlacInput::Seek(FLAC__uint64 absolute_byte_offset) +inline FLAC__StreamDecoderSeekStatus +FlacInput::Seek(FLAC__uint64 absolute_byte_offset) noexcept { if (!input_stream.IsSeekable()) return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; @@ -59,8 +58,8 @@ FlacInput::Seek(FLAC__uint64 absolute_byte_offset) } } -FLAC__StreamDecoderTellStatus -FlacInput::Tell(FLAC__uint64 *absolute_byte_offset) +inline FLAC__StreamDecoderTellStatus +FlacInput::Tell(FLAC__uint64 *absolute_byte_offset) noexcept { if (!input_stream.IsSeekable()) return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED; @@ -69,8 +68,8 @@ FlacInput::Tell(FLAC__uint64 *absolute_byte_offset) return FLAC__STREAM_DECODER_TELL_STATUS_OK; } -FLAC__StreamDecoderLengthStatus -FlacInput::Length(FLAC__uint64 *stream_length) +inline FLAC__StreamDecoderLengthStatus +FlacInput::Length(FLAC__uint64 *stream_length) noexcept { if (!input_stream.KnownSize()) return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; @@ -79,8 +78,8 @@ FlacInput::Length(FLAC__uint64 *stream_length) return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; } -FLAC__bool -FlacInput::Eof() +inline FLAC__bool +FlacInput::Eof() noexcept { return (client != nullptr && client->GetCommand() != DecoderCommand::NONE && @@ -88,8 +87,8 @@ FlacInput::Eof() input_stream.LockIsEOF(); } -void -FlacInput::Error(FLAC__StreamDecoderErrorStatus status) +inline void +FlacInput::Error(FLAC__StreamDecoderErrorStatus status) noexcept { if (client == nullptr || client->GetCommand() != DecoderCommand::STOP) @@ -100,7 +99,7 @@ FlacInput::Error(FLAC__StreamDecoderErrorStatus status) FLAC__StreamDecoderReadStatus FlacInput::Read([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, FLAC__byte buffer[], size_t *bytes, - void *client_data) + void *client_data) noexcept { auto *i = (FlacInput *)client_data; @@ -109,7 +108,7 @@ FlacInput::Read([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, FLAC__StreamDecoderSeekStatus FlacInput::Seek([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 absolute_byte_offset, void *client_data) + FLAC__uint64 absolute_byte_offset, void *client_data) noexcept { auto *i = (FlacInput *)client_data; @@ -118,7 +117,7 @@ FlacInput::Seek([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, FLAC__StreamDecoderTellStatus FlacInput::Tell([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 *absolute_byte_offset, void *client_data) + FLAC__uint64 *absolute_byte_offset, void *client_data) noexcept { auto *i = (FlacInput *)client_data; @@ -127,7 +126,7 @@ FlacInput::Tell([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, FLAC__StreamDecoderLengthStatus FlacInput::Length([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 *stream_length, void *client_data) + FLAC__uint64 *stream_length, void *client_data) noexcept { auto *i = (FlacInput *)client_data; @@ -136,7 +135,7 @@ FlacInput::Length([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, FLAC__bool FlacInput::Eof([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, - void *client_data) + void *client_data) noexcept { auto *i = (FlacInput *)client_data; @@ -145,7 +144,8 @@ FlacInput::Eof([[maybe_unused]] const FLAC__StreamDecoder *flac_decoder, void FlacInput::Error([[maybe_unused]] const FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderErrorStatus status, void *client_data) + FLAC__StreamDecoderErrorStatus status, + void *client_data) noexcept { auto *i = (FlacInput *)client_data; diff --git a/src/decoder/plugins/FlacInput.hxx b/src/decoder/plugins/FlacInput.hxx index 87b7fc027..bdc31b840 100644 --- a/src/decoder/plugins/FlacInput.hxx +++ b/src/decoder/plugins/FlacInput.hxx @@ -48,36 +48,38 @@ public: } protected: - FLAC__StreamDecoderReadStatus Read(FLAC__byte buffer[], size_t *bytes); - FLAC__StreamDecoderSeekStatus Seek(FLAC__uint64 absolute_byte_offset); - FLAC__StreamDecoderTellStatus Tell(FLAC__uint64 *absolute_byte_offset); - FLAC__StreamDecoderLengthStatus Length(FLAC__uint64 *stream_length); - FLAC__bool Eof(); - void Error(FLAC__StreamDecoderErrorStatus status); + FLAC__StreamDecoderReadStatus Read(FLAC__byte buffer[], size_t *bytes) noexcept; + FLAC__StreamDecoderSeekStatus Seek(FLAC__uint64 absolute_byte_offset) noexcept; + FLAC__StreamDecoderTellStatus Tell(FLAC__uint64 *absolute_byte_offset) noexcept; + FLAC__StreamDecoderLengthStatus Length(FLAC__uint64 *stream_length) noexcept; + FLAC__bool Eof() noexcept; + void Error(FLAC__StreamDecoderErrorStatus status) noexcept; public: static FLAC__StreamDecoderReadStatus Read(const FLAC__StreamDecoder *flac_decoder, - FLAC__byte buffer[], size_t *bytes, void *client_data); + FLAC__byte buffer[], size_t *bytes, void *client_data) noexcept; static FLAC__StreamDecoderSeekStatus Seek(const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 absolute_byte_offset, void *client_data); + FLAC__uint64 absolute_byte_offset, void *client_data) noexcept; static FLAC__StreamDecoderTellStatus Tell(const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 *absolute_byte_offset, void *client_data); + FLAC__uint64 *absolute_byte_offset, void *client_data) noexcept; static FLAC__StreamDecoderLengthStatus Length(const FLAC__StreamDecoder *flac_decoder, - FLAC__uint64 *stream_length, void *client_data); + FLAC__uint64 *stream_length, void *client_data) noexcept; static FLAC__bool - Eof(const FLAC__StreamDecoder *flac_decoder, void *client_data); + Eof(const FLAC__StreamDecoder *flac_decoder, + void *client_data) noexcept; static void Error(const FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderErrorStatus status, void *client_data); + FLAC__StreamDecoderErrorStatus status, + void *client_data) noexcept; }; #endif diff --git a/src/decoder/plugins/FlacPcm.cxx b/src/decoder/plugins/FlacPcm.cxx index 94e4c2ac2..315d6c5ee 100644 --- a/src/decoder/plugins/FlacPcm.cxx +++ b/src/decoder/plugins/FlacPcm.cxx @@ -39,7 +39,8 @@ FlacPcmImport::Open(unsigned sample_rate, unsigned bits_per_sample, template static void -FlacImportStereo(T *dest, const FLAC__int32 *const src[], size_t n_frames) +FlacImportStereo(T *dest, const FLAC__int32 *const src[], + size_t n_frames) noexcept { for (size_t i = 0; i != n_frames; ++i) { *dest++ = (T)src[0][i]; @@ -50,7 +51,7 @@ FlacImportStereo(T *dest, const FLAC__int32 *const src[], size_t n_frames) template static void FlacImportAny(T *dest, const FLAC__int32 *const src[], size_t n_frames, - unsigned n_channels) + unsigned n_channels) noexcept { for (size_t i = 0; i != n_frames; ++i) for (unsigned c = 0; c != n_channels; ++c) @@ -60,7 +61,7 @@ FlacImportAny(T *dest, const FLAC__int32 *const src[], size_t n_frames, template static void FlacImport(T *dest, const FLAC__int32 *const src[], size_t n_frames, - unsigned n_channels) + unsigned n_channels) noexcept { if (n_channels == 2) FlacImportStereo(dest, src, n_frames); @@ -71,7 +72,7 @@ FlacImport(T *dest, const FLAC__int32 *const src[], size_t n_frames, template static ConstBuffer FlacImport(PcmBuffer &buffer, const FLAC__int32 *const src[], size_t n_frames, - unsigned n_channels) + unsigned n_channels) noexcept { size_t n_samples = n_frames * n_channels; size_t dest_size = n_samples * sizeof(T); diff --git a/src/decoder/plugins/FlacPcm.hxx b/src/decoder/plugins/FlacPcm.hxx index ea0363d04..5f5bcf493 100644 --- a/src/decoder/plugins/FlacPcm.hxx +++ b/src/decoder/plugins/FlacPcm.hxx @@ -43,7 +43,7 @@ public: void Open(unsigned sample_rate, unsigned bits_per_sample, unsigned channels); - const AudioFormat &GetAudioFormat() const { + const AudioFormat &GetAudioFormat() const noexcept { return audio_format; }