Commit 18d3a5c1 authored by Max Kellermann's avatar Max Kellermann

decoder/flac: add `noexcept` and `inline`

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