From 3bedd94fc8a6cb4fe767423a88c46929e8045353 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Thu, 20 Apr 2023 21:17:52 +0100 Subject: [PATCH 01/12] doc: Fix syntax error With sphinx-build 5.0.0: doc/user.rst:728: ERROR: Unexpected indentation. doc/user.rst:731: ERROR: Unexpected indentation. --- doc/user.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/user.rst b/doc/user.rst index 489df08ad..a9694bc31 100644 --- a/doc/user.rst +++ b/doc/user.rst @@ -661,9 +661,11 @@ MPD enables MixRamp if: - Cross-fade is enabled - :ref:`mixrampdelay ` is set to a positive value, e.g.:: + mpc mixrampdelay 1 - :ref:`mixrampdb ` is set to a reasonable value, e.g.:: + mpc mixrampdb -17 - both songs have MixRamp tags - both songs have the same audio format (or :ref:`audio_output_format` From fc9626e2f49372e5f3f6716f3fb61a1076f9b542 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 2 Jun 2023 14:15:14 +0200 Subject: [PATCH 02/12] increment version number to 0.23.14 --- NEWS | 2 ++ android/AndroidManifest.xml | 4 ++-- meson.build | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index df45c188a..b82032c82 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.23.14 (not yet released) + ver 0.23.13 (2023/05/22) * input - curl: fix busy loop after connection failed diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 68028d594..cbcc5f893 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="72" + android:versionName="0.23.14"> diff --git a/meson.build b/meson.build index e9925ee39..36869b5b9 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'mpd', ['c', 'cpp'], - version: '0.23.13', + version: '0.23.14', meson_version: '>= 0.56.0', default_options: [ 'c_std=c11', From 6ee3d0102b51798c7f8001948e202a0b3758cd9a Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 27 May 2023 20:13:53 +0100 Subject: [PATCH 03/12] decoder/mad: Fix decode of LAME peak value 6d91b5c7b21926137c63561e313afd1fb72274f8 ("fix double promotions") changed how LAME peak values are decoded, producing large incorrect values that cause some MP3 files to play silently. Restore the original decode from MAD fixed-point format to double and document what it's doing. Fixes #1823 --- NEWS | 2 ++ src/decoder/plugins/MadDecoderPlugin.cxx | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b82032c82..fec18ffb4 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.23.14 (not yet released) +* decoder + - mad: fix calculation of LAME peak values ver 0.23.13 (2023/05/22) * input diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 7e34c25b1..d861e2e6e 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -562,7 +562,21 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept mad_bit_skip(ptr, 16); - lame->peak = MAD_F(mad_bit_read(ptr, 32) << 5); /* peak */ + /* The lame peak value is a float multiplied by 2^23 and stored as an + * unsigned integer (it is always positive). MAD's fixed-point format uses + * 28 bits for the fractional part, so shift the 23 bit fraction up before + * converting to a float. + */ + unsigned long peak_int = mad_bit_read(ptr, 32); + +#define LAME_PEAK_FRACBITS 23 +#if MAD_F_FRACBITS > LAME_PEAK_FRACBITS + peak_int <<= (MAD_F_FRACBITS - LAME_PEAK_FRACBITS); +#elif LAME_PEAK_FRACBITS > MAD_F_FRACBITS + peak_int >>= (LAME_PEAK_FRACBITS - MAD_F_FRACBITS); +#endif + + lame->peak = mad_f_todouble(peak_int); /* peak */ FmtDebug(mad_domain, "LAME peak found: {}", lame->peak); lame->track_gain = 0; From 18d3a5c12bb5f9d4f220ce759813e7c978b6800e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Jul 2022 12:09:13 +0200 Subject: [PATCH 04/12] decoder/flac: add `noexcept` and `inline` --- src/decoder/plugins/FlacCommon.cxx | 12 +++---- src/decoder/plugins/FlacCommon.hxx | 15 ++++----- src/decoder/plugins/FlacDecoderPlugin.cxx | 27 +++++++++------- src/decoder/plugins/FlacInput.cxx | 38 +++++++++++------------ src/decoder/plugins/FlacInput.hxx | 26 +++++++++------- src/decoder/plugins/FlacPcm.cxx | 9 +++--- src/decoder/plugins/FlacPcm.hxx | 2 +- 7 files changed, 68 insertions(+), 61 deletions(-) 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; } From bcb393628eae10c4cd44380fac0c3158d5e55776 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 02:13:25 +0800 Subject: [PATCH 05/12] win32/ComWorker: rename variable name to prevent ambiguous --- src/win32/ComWorker.hxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32/ComWorker.hxx b/src/win32/ComWorker.hxx index 4016d9939..58d53dc85 100644 --- a/src/win32/ComWorker.hxx +++ b/src/win32/ComWorker.hxx @@ -52,17 +52,17 @@ public: using R = std::invoke_result_t>; auto promise = std::make_shared>(); auto future = promise->get_future(); - Push([function = std::forward(function), - promise = std::move(promise)]() mutable { + Push([func = std::forward(function), + prom = std::move(promise)]() mutable { try { if constexpr (std::is_void_v) { - std::invoke(std::forward(function)); - promise->set_value(); + std::invoke(std::forward(func)); + prom->set_value(); } else { - promise->set_value(std::invoke(std::forward(function))); + prom->set_value(std::invoke(std::forward(func))); } } catch (...) { - promise->set_exception(std::current_exception()); + prom->set_exception(std::current_exception()); } }); return future; From 70879f0abc582cb01468c2f553b26d37fe883d58 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 02:16:26 +0800 Subject: [PATCH 06/12] thread/WindowsFuture: remove wrong address_of operator --- NEWS | 2 ++ src/thread/WindowsFuture.hxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fec18ffb4..feecefca8 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.23.14 (not yet released) * decoder - mad: fix calculation of LAME peak values +* mixer + - wasapi: fix problem setting volume ver 0.23.13 (2023/05/22) * input diff --git a/src/thread/WindowsFuture.hxx b/src/thread/WindowsFuture.hxx index e9082a63c..dd2543cf4 100644 --- a/src/thread/WindowsFuture.hxx +++ b/src/thread/WindowsFuture.hxx @@ -130,7 +130,7 @@ public: void set_value(const T &value) { std::unique_lock lock(mutex); - if (!std::holds_alternative(&result)) { + if (!std::holds_alternative(result)) { throw WinFutureError(WinFutureErrc::promise_already_satisfied); } result.template emplace(value); From d52eac66dbad9ffe59c2dc47dc602edaf38e1816 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 12:36:43 +0800 Subject: [PATCH 07/12] doc/mpdconf.example: add hardware mixer example config for wasapi --- doc/mpdconf.example | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/mpdconf.example b/doc/mpdconf.example index 9d14bd642..4fc00dacd 100644 --- a/doc/mpdconf.example +++ b/doc/mpdconf.example @@ -314,6 +314,7 @@ input { ## device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional # or ## device "0" # optional +## mixer_type "hardware" # optional ## Exclusive mode blocks all other audio source, and get best audio quality without resampling. ## exclusive "no" # optional ## Enumerate all devices in log. From fef6b9df807779579ec60874a4e1bace67ea02df Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 02:22:37 +0800 Subject: [PATCH 08/12] flac: Try `InputStream` interface if flac failed to read through a `wchar_t` path --- NEWS | 1 + src/decoder/plugins/FlacDecoderPlugin.cxx | 25 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index feecefca8..c2ffcccfa 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ver 0.23.14 (not yet released) * decoder + - flac: fix scanning files with non-ASCII names on Windows - mad: fix calculation of LAME peak values * mixer - wasapi: fix problem setting volume diff --git a/src/decoder/plugins/FlacDecoderPlugin.cxx b/src/decoder/plugins/FlacDecoderPlugin.cxx index da0374f7a..0094906b6 100644 --- a/src/decoder/plugins/FlacDecoderPlugin.cxx +++ b/src/decoder/plugins/FlacDecoderPlugin.cxx @@ -24,6 +24,7 @@ #include "lib/xiph/FlacMetadataChain.hxx" #include "OggCodec.hxx" #include "input/InputStream.hxx" +#include "input/LocalOpen.hxx" #include "fs/Path.hxx" #include "fs/NarrowPath.hxx" #include "Log.hxx" @@ -71,16 +72,32 @@ flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame, } static bool -flac_scan_file(Path path_fs, TagHandler &handler) noexcept -{ +flac_scan_file(Path path_fs, TagHandler &handler) noexcept { FlacMetadataChain chain; - if (!chain.Read(NarrowPath(path_fs))) { + const bool succeed = [&chain, &path_fs]() noexcept { + // read by NarrowPath + if (chain.Read(NarrowPath(path_fs))) { + return true; + } + if (std::is_same_v || + chain.GetStatus() != FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE) { + return false; + } + // read by InputStream + Mutex mutex; + auto is = OpenLocalInputStream(path_fs, mutex); + if (is && chain.Read(*is)) { + return true; + } + return false; + }(); + + if (!succeed) { FmtDebug(flac_domain, "Failed to read FLAC tags: {}", chain.GetStatusString()); return false; } - chain.Scan(handler); return true; } From 8df77122e5480243350e8c21e07873e4671836ea Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 02:39:09 +0800 Subject: [PATCH 09/12] python/build/libs.py: use right cmake variable to disable SDL --- python/build/libs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/build/libs.py b/python/build/libs.py index 1f89df53e..53b8316bd 100644 --- a/python/build/libs.py +++ b/python/build/libs.py @@ -149,7 +149,7 @@ gme = CmakeProject( '-DBUILD_SHARED_LIBS=OFF', '-DENABLE_UBSAN=OFF', '-DZLIB_INCLUDE_DIR=OFF', - '-DSDL2_DIR=OFF', + '-DCMAKE_DISABLE_FIND_PACKAGE_SDL2=ON', ], ) From 38f1237d492c0cb5367f9780ddc15344eaf16e08 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Tue, 30 May 2023 14:06:48 +0800 Subject: [PATCH 10/12] output/wasapi: cast to `const char *` for fmt 10 compatible --- NEWS | 1 + src/output/plugins/wasapi/WasapiOutputPlugin.cxx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c2ffcccfa..61dfa96d0 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ ver 0.23.14 (not yet released) - mad: fix calculation of LAME peak values * mixer - wasapi: fix problem setting volume +* more libfmt 10 fixes ver 0.23.13 (2023/05/22) * input diff --git a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx index 992dc2e67..eda76f2b7 100644 --- a/src/output/plugins/wasapi/WasapiOutputPlugin.cxx +++ b/src/output/plugins/wasapi/WasapiOutputPlugin.cxx @@ -1026,7 +1026,7 @@ WasapiOutput::EnumerateDevices(IMMDeviceEnumerator &enumerator) continue; FmtNotice(wasapi_output_domain, - "Device \"{}\" \"{}\"", i, name); + "Device \"{}\" \"{}\"", i, name.c_str()); } } From 42a01822bfdf83eb9bae7096b3cebb793d9587b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Mon, 22 May 2023 22:23:38 +0200 Subject: [PATCH 11/12] meson: use correct prefix for systemd dirs See https://www.bassi.io/articles/2018/03/15/pkg-config-and-paths/ Fixes the build in nixpkgs --- NEWS | 1 + systemd/system/meson.build | 5 ++++- systemd/user/meson.build | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 61dfa96d0..50e0c3125 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ ver 0.23.14 (not yet released) * mixer - wasapi: fix problem setting volume * more libfmt 10 fixes +* fix auto-detected systemd unit directory ver 0.23.13 (2023/05/22) * input diff --git a/systemd/system/meson.build b/systemd/system/meson.build index f90f93d5a..632ff420e 100644 --- a/systemd/system/meson.build +++ b/systemd/system/meson.build @@ -2,7 +2,10 @@ systemd_system_unit_dir = get_option('systemd_system_unit_dir') if systemd_system_unit_dir == '' systemd = dependency('systemd', required: false) if systemd.found() - systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir') + systemd_system_unit_dir = systemd.get_variable( + pkgconfig: 'systemdsystemunitdir', + pkgconfig_define: ['prefix', get_option('prefix')], + ) endif endif if systemd_system_unit_dir == '' diff --git a/systemd/user/meson.build b/systemd/user/meson.build index 86a1fd933..7a3522ce5 100644 --- a/systemd/user/meson.build +++ b/systemd/user/meson.build @@ -2,7 +2,10 @@ systemd_user_unit_dir = get_option('systemd_user_unit_dir') if systemd_user_unit_dir == '' systemd = dependency('systemd', required: false) if systemd.found() - systemd_user_unit_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir') + systemd_user_unit_dir = systemd.get_variable( + pkgconfig: 'systemduserunitdir', + pkgconfig_define: ['prefix', get_option('prefix')], + ) endif endif if systemd_user_unit_dir == '' From 561d6fd4783632d4cc77023fb3b84660311068a4 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sat, 27 May 2023 20:58:00 +0100 Subject: [PATCH 12/12] meson: Use correct prefix for systemd_system_unit_dir systemd uses "rootprefix", not "prefix" for this value https://github.com/systemd/systemd/blob/059b1b31ade7f1d716f56c5e6fd657ce22ce2032/src/core/systemd.pc.in#L23 --- systemd/system/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/system/meson.build b/systemd/system/meson.build index 632ff420e..c6d676b7c 100644 --- a/systemd/system/meson.build +++ b/systemd/system/meson.build @@ -4,7 +4,7 @@ if systemd_system_unit_dir == '' if systemd.found() systemd_system_unit_dir = systemd.get_variable( pkgconfig: 'systemdsystemunitdir', - pkgconfig_define: ['prefix', get_option('prefix')], + pkgconfig_define: ['rootprefix', get_option('prefix')], ) endif endif