decoder/flac: add noexcept and inline

This commit is contained in:
Max Kellermann
2022-07-12 12:09:13 +02:00
parent 6ee3d0102b
commit 18d3a5c12b
7 changed files with 68 additions and 61 deletions

View File

@@ -22,12 +22,11 @@
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "Log.hxx"
#include "util/Compiler.h"
#include <exception>
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;