Compare commits

...

172 Commits

Author SHA1 Message Date
Max Kellermann
0341ca1b6a release v0.23.7 2022-05-09 23:04:30 +02:00
Max Kellermann
7581ea55db python/build/libs.py: update CURL to 7.83.0 2022-05-09 23:03:14 +02:00
Max Kellermann
fc9cee38d8 python/build/libs.py: update OpenSSL to 3.0.3 2022-05-09 23:03:14 +02:00
Max Kellermann
b175e4128d encoder/meson.build: always generate encoder/Features.h
Fixes regression from commit 85f9863e0a
2022-05-09 22:52:59 +02:00
Max Kellermann
97b07798b0 doc/protocol.rst: clarify repeat/single/random side effects 2022-05-09 22:50:57 +02:00
Max Kellermann
112fcd206d Merge branch 'fix-hls-seeking' of https://github.com/burrocargado/MPD into v0.23.x 2022-05-09 22:44:53 +02:00
BurroCargado
11d1f56062 Fix seeking HLS on-demand streaming not working
This issue occurs when playing HLS streaming delivered
from a server that does not support partial requests.
The issue is reproduced as follows(using Ubuntu 20.04 PC):

1. Prepare HLS example content.

$ mkdir test
$ ffmpeg -i example.flac -vn -c:a aac -b:a 128000 -f hls -hls_list_size 0 test/output.m3u8
(ffmpeg 4.2.4 is used)

2. Prepare web server without partial requests support.
(Docker version 20.10.12 and NGINX official Docker image is used)

$ docker run --name tmp-nginx-container -d nginx
$ docker cp tmp-nginx-container:/etc/nginx/conf.d/default.conf .
$ docker rm -f tmp-nginx-container

Edit default.conf and add "max_ranges 0;" to "location / {...}".
This disables partial requests support,
removes 'Accept-Ranges: bytes' header from the server response.
Then, run the server:

$ docker run --name test-nginx -v $PWD/test:/usr/share/nginx/html:ro -v $PWD/default.conf:/etc/nginx/conf.d/default.conf -d -p 8080:80 nginx

3. Setup MPD to Play the next URL.

http://address-of-the-server:8080/output.m3u8

Seeking this stream results in "exception: Not seekable".
2022-05-07 12:18:56 +09:00
BurroCargado
bd840d4638 decoder/plugins/FFmpegDecoder: fix IsSeekable()
AVFMTCTX_UNSEEKABLE signals the stream is not seekable
according to FFmpeg source code description:
8e98dfc57f/libavformat/avformat.h (L1181)
2022-05-07 09:48:04 +09:00
Max Kellermann
c3d393f214 tag/Id3Picture: fix unaligned access 2022-04-26 21:03:48 +02:00
Max Kellermann
f88fc0ca1a util/ByteOrder: add class PackedBE32 2022-04-26 21:03:05 +02:00
Max Kellermann
fb8d8242ab tag/ApeLoader: fix unaligned access
Fixes part 4 of https://github.com/MusicPlayerDaemon/MPD/issues/1490
2022-04-26 21:00:41 +02:00
Max Kellermann
f2a3dfd700 decoder/ffmpeg: add missing nullptr checks
Fixes part 1 of https://github.com/MusicPlayerDaemon/MPD/issues/1490
2022-04-26 20:51:57 +02:00
Max Kellermann
85f9863e0a meson.build: always enable Wave encoder for Snapcast
Even if the "wave_encoder" option is disabled (and no other encoder
plugins are enabled), forcefully enable the Wave encoder (if Snapcast
is enabled).

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1500
2022-04-26 20:13:43 +02:00
Max Kellermann
83572701f4 python/build/libs.py: update Boost to 1.79.0 2022-04-26 18:27:51 +02:00
Max Kellermann
fa7d7e9187 python/build/libs.py: update OpenSSL to 3.0.2 2022-04-26 18:27:51 +02:00
Max Kellermann
f818cde32c python/build/libs.py: update FFmpeg to 5.0.1 2022-04-26 18:27:51 +02:00
Max Kellermann
9da93cd887 python/build/libs.py: update zlib to 1.2.12 2022-04-26 18:27:51 +02:00
Rosen Penev
026e7ea32a update all subprojecs
Done with meson wrap update

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-04-26 18:01:53 +02:00
Max Kellermann
9659d19718 lib/upnp/Init: use if with initalizer 2022-04-26 17:58:33 +02:00
Rosen Penev
50d35c9677 upnp: use UpnpInit2 always
libupnp 1.14 removes the non 2 function. Fixes compilation there.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1499
2022-04-26 17:57:48 +02:00
Thomas Guillem
4260e78861 android: add gdb.sh
This script setup a dummy android native app folder and call ndk-gdb from it.

It needs a modification in ANDROID_NDK since ndk-gdb may attach to the wrong
pid, cf. comments in the script.
2022-04-26 17:47:54 +02:00
Thomas Guillem
7342ae2e33 android: set application debuggable
This debuggable flag should not be set with release builds. Generally, graddle
is taking care of that.
2022-04-26 17:46:51 +02:00
Arsen Arsenović
35dbc1a90c mixer,output: prevent setting volume before outputs are really enabled
Previous versions of MPD would call SetVolume on enabled outputs before
they are ready, causing all of MPD to crash. Checking the really_enabled
flag prevents this, though it also prevents setting volume before the
player starts.

Before (with the PipeWire output):
  [i] ~$ mpc clear
  volume: 81%   repeat: off   random: off   single: off   consume: off
  [i] ~$ systemctl --user restart mpd.service
  [i] ~$ mpc volume 100
  MPD error: Connection closed by the server
  [i] ~ 1 $

After:
  [i] ~$ # mpd is freshly started w/o anything in the queue
  [i] ~$ mpc
  volume:100%   repeat: off   random: off   single: off   consume: off
  [i] ~$ mpc volume 80
  MPD error: problems setting volume
  [i] ~ 1 $ mpc
  volume:100%   repeat: off   random: off   single: off   consume: off
  [i] ~$
2022-04-26 17:45:29 +02:00
Arsen Arsenović
c7a4355153 outputs/pipewire: fix ParamChanged incorrectly setting volume
Previous versions of MPD would, on parameter change, set the PipeWire
volume before clearing the restore_volume flag, causing the call to
short circuit and do nothing. Instead, clear the flag before the call.
2022-04-26 17:44:19 +02:00
Max Kellermann
33a84a8ca2 output/shout: use shout_set_metadata_utf8() 2022-04-26 17:41:21 +02:00
Max Kellermann
1d04490ed3 output/shout: use shout_set_content_format() 2022-04-26 17:38:43 +02:00
Max Kellermann
4a30c2d79c output/shout: use shout_set_meta() 2022-04-26 17:24:49 +02:00
Max Kellermann
83072d6b9c output/shout: pass reference to Setup() 2022-04-26 16:49:18 +02:00
Max Kellermann
c779fc37eb output/shout: declare minimum version 2.4.0
This version was released 7 years ago, and it's reasonable to require
at least this version.
2022-04-26 16:46:36 +02:00
Max Kellermann
e08c13ad7e output/shout: add "noexcept" 2022-04-26 15:57:03 +02:00
Max Kellermann
2c82a6b2e0 output/shout: handle shout_metadata_add() errors
Fixes -Wunused-result
2022-04-26 15:56:55 +02:00
Max Kellermann
3929f17aef NEWS: mention the libiconv fix 2022-04-26 15:56:54 +02:00
Andreas Ziegler
ee39af3419 fix typo in comment 2022-04-24 04:14:17 +00:00
aeolio
3882a5a263 src/lib/icu: fix iconv() detection when libiconv is installed 2022-04-20 16:10:39 +02:00
Vitaly Ostrosablin
ac06088948 Make volume changes to apply to disabled software mixers.
Move audio output state check ahead of mixer check and force volume
applying even for disabled software mixed outputs.

This fixes incorrect software mixer volume that used to occur when
volume was changed while output being disabled.

This is easily reproduced with following sequence of commands on
multi-output software mixed MPD setup.

 mpc volume 38; mpc disable 3; mpc volume 88; mpc enable 3

On current MPD, following commands would result in output 3 playing at
volume 38, while all other enabled outputs would play at volume
88. Moreover, global volume would display average of outputs real
volumes. In my case, it's 75.

After applying this patch, following commands would produce expected
behavior. All outputs play at expected (88) volume. And volume is
correctly displayed as 88.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1423

Signed-off-by: Vitaly Ostrosablin tmp6154@yandex.ru


Signed-off-by: Vitaly Ostrosablin <tmp6154@yandex.ru>
2022-03-26 06:29:18 +01:00
Max Kellermann
a757eebfbb decoder/OggSyncState: allow skipping up to 64 kB after seek
This is more of what we did in commit 70bd35abe2 because it turns
out there are Ogg-Opus files with pages larger than 40 kB.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1487
2022-03-16 16:54:50 +01:00
Max Kellermann
2be4f89555 test/DumpOgg: new debug program 2022-03-16 16:51:44 +01:00
Max Kellermann
4a5c7d8261 increment version number to 0.23.7 2022-03-14 18:55:55 +01:00
Max Kellermann
f591193dda release v0.23.6 2022-03-14 18:55:47 +01:00
Max Kellermann
434869900e android/build.py: fix typo in error message
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1379
2022-03-14 18:49:50 +01:00
Max Kellermann
2aed7378cc TagAny: support CUE tracks
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1482
2022-03-14 18:42:31 +01:00
Max Kellermann
71cd6e6248 lib/xiph/meson.build: define FLAC__NO_DLL for static libFLAC build (Windows)
In libFLAC 0.3.4 (commit c9530118a4), the "dllimport" check has been
changed from "_MSC_VER" to "_WIN32", and now the MPD build is affected
by it.

Defining FLAC__NO_DLL disables the use of "dllimport", which allows
linking properly to the static libFLAC build.
2022-03-14 15:08:59 +01:00
Max Kellermann
c83294916a python/build/libs.py: update Boost to 1.78.0 2022-03-14 14:52:24 +01:00
Max Kellermann
603bbe0afd python/build/libs.py: update libnfs to 5.0.1 2022-03-14 14:52:24 +01:00
Max Kellermann
c361e235eb python/build/libs.py: update CURL to 7.82.0 2022-03-14 14:52:24 +01:00
Max Kellermann
8a59493d96 python/build/libs.py: update OpenSSL to 3.0.1 2022-03-14 14:50:06 +01:00
Max Kellermann
7ef86cbf9f python/build/libs.py: update FFmpeg to 5.0 2022-03-14 14:50:06 +01:00
Max Kellermann
c9530118a4 python/build/libs.py: update FLAC to 1.3.4 2022-03-14 14:31:13 +01:00
Max Kellermann
878d9abeb7 python/build/libs.py: update libogg to 1.3.5 2022-03-14 14:29:59 +01:00
Max Kellermann
2d705efe1c python/build/libs.py: update libmpdclient to 2.20 2022-03-14 14:29:22 +01:00
Richard Schorrig
aeaef85507 WasapiOutputPlugin pause bug fix
Wasapi output plugin won't start playing after being paused

The cause is that the scope guard in the WASAPI work thread
(WasapiOutputPlugin.cxx, function WasapiOutputThread::Work(), in the
while (true) loop) is set up too 'late' in the execution. There is one
condition ("if (data_in_frames >= buffer_size_in_frames)") when it is
hit, the loop will continue without executing the scope guard. This
scope guard is responsible for emptying the buffer again, and if the
buffer is not emptied, the above mentioned condition will stay true.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1451
2022-03-14 14:26:00 +01:00
nick black
ebae25d175 plugins/FfmpegIO: include libavutil/mem.h
ffmpeg from current git master no longer exposes
av_malloc() nor av_free() through other included
headers. directly include libavutil/mem.h to fix
compilation with (as-yet-unreleased) ffmpeg.
2022-03-14 14:11:31 +01:00
jcorporation
5ad1a01d7a Remove bmp, tiff and add webp for coverimage filenames
- supporting bmp and tiff seems outdated
- webp is more widely used for coverimages
2022-03-14 14:09:23 +01:00
Max Kellermann
8f84e1befd decoder/plugins/FfmpegIo: return AVERROR_EOF at end of file
This part of the AVIOContext API is not documented :-(

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1448
2022-03-14 14:00:28 +01:00
Max Kellermann
9975905faf output/PipeWire: initialize field "stream" in Open()
Must be initialized for the check in SetVolume().
2022-03-09 14:29:46 +01:00
Max Kellermann
233184568c doc/protocol.rst: describe the FILTER argument to playlist{find,search} 2022-02-14 09:11:41 +01:00
Wolfgang Müller
59da778009 doc/user.rst: Clarify how MPD reads metadata
The writing and reading of metadata involves lots of different programs
and libraries. Therefore it is prudent to point out how exactly MPD
receives metadata. Ideally this helps to point users to the right place
if their tags are not picked up correctly.
2022-02-14 09:11:11 +01:00
Max Kellermann
108ce95b7c android/Receiver: fix indent 2022-01-26 14:43:47 +01:00
Max Kellermann
86e9ed5f3a decoder/opus: fix "readpicture" on Opus files
Don't return early from ScanOpusTags() if only
TagHandler::WantPicture() is set.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1413
2022-01-26 14:43:45 +01:00
Sam Bazley
fbecb05bf4 Fix Android build error: needs_exe_wrapper
lib/src/libmpdclient-2.19/meson.build:1:0: ERROR: Unknown options: "needs_exe_wrapper"

The "needs_exe_wrapper" option was incorrectly set under
[built-in options] rather than [properties].
2022-01-11 20:33:48 +01:00
Sam Bazley
4983703375 Android: Detect output change with ACTION_AUDIO_BECOMING_NOISY
Improves the changes made in 57687779be by
using AudioManager.ACTION_AUDIO_BECOMING_NOISY rather than listening for
wired headset unplug events or Bluetooth headset disconnect events. This
method is more flexible, allowing the feature to work on other types of
audio output device, as well as Bluetooth devices that don't set their
device class correctly. This change also has the benefit of being more
responsive, pausing the audio before it is rerouted to the built-in
speaker.

https://developer.android.com/guide/topics/media-apps/volume-and-earphones
2022-01-04 16:42:53 +01:00
aeolio
3856224df9 lib/alsa/Error: add missing #include 2021-12-15 11:14:38 +01:00
aeolio
6d4bedfc56 lib/alsa/Error: fix typo 2021-12-15 11:14:34 +01:00
Max Kellermann
bea821f194 doc/user.rst: add MixRamp documentation 2021-12-06 21:32:39 +01:00
Rosen Penev
4e276256c0 more braced init list conversion
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-12-06 09:16:04 +01:00
Tim Siegel
d0f9062b56 mpdconf.example: fix a few spelling typos 2021-12-05 22:58:45 +01:00
Max Kellermann
b9cc036703 .github/workflows/build.yml: rebuild branch v0.23.x 2021-12-03 23:00:42 +01:00
Max Kellermann
4e9b88559b SingleMode: convert "pure" to "const" 2021-12-03 16:09:34 +01:00
Max Kellermann
3452682a42 IcyMetaDataParser: move to tag/ 2021-12-03 16:07:39 +01:00
Max Kellermann
9262b24504 AudioCompress: move to pcm/ 2021-12-03 16:04:59 +01:00
Max Kellermann
a5fa43b526 fs/io: move to io/ 2021-12-03 14:35:41 +01:00
Max Kellermann
8681a3d74c replace TextFile references with LineReader 2021-12-03 14:22:56 +01:00
Max Kellermann
f9c4d88b12 fs/io/TextFile: add interface LineReader 2021-12-03 14:20:29 +01:00
Max Kellermann
799032505e io/uring/Queue: add method RequireSubmitEntry()
Fixes assertion failure when the submit queue is empty.
2021-12-03 13:58:39 +01:00
Max Kellermann
c8f174ac92 io/uring/Operation: disallow copying 2021-12-03 13:52:04 +01:00
Max Kellermann
047e169f3e util/BindMethod: merge MakeBind{Method,Function}Wrapper(), they are identical now 2021-12-03 13:51:56 +01:00
Max Kellermann
687327c9e8 util/BindMethod: merge structs {Method,Function}SignatureHelper into one 2021-12-03 13:51:56 +01:00
Max Kellermann
26dc37bd76 util/BindMethod: merge structs {Method,Function}WrapperGenerator into one 2021-12-03 13:51:55 +01:00
Max Kellermann
c693e4aa64 util/BindMethod: remove unused struct MethodWithSignature 2021-12-03 13:51:55 +01:00
Max Kellermann
acab731fef util/BindMethod: simplify MakeBindFunctionWrapper() 2021-12-03 13:51:55 +01:00
Max Kellermann
7e4ba3cb72 util/BindMethod: add MethodSignatureHelper::function_pointer 2021-12-03 13:51:55 +01:00
Max Kellermann
172c4d9c7d util/BindMethod: remove unnecessary template arguments from BindMethodWrapperGenerator 2021-12-03 13:51:55 +01:00
Max Kellermann
bd5f6cbc7b util/BindMethod: simplify more templates using "auto" template arguments 2021-12-03 13:51:55 +01:00
Max Kellermann
6fcd1c734b util/BindMethod: eliminate struct BindMethodWrapperGenerator2 2021-12-03 13:51:55 +01:00
Max Kellermann
eca097dbfb util/BindMethod: simplify more templates using "auto" template arguments 2021-12-03 13:51:55 +01:00
Max Kellermann
51ffafa011 util/BindMethod: use std::remove_reference_t 2021-12-03 13:51:25 +01:00
Max Kellermann
8dca602346 util/BindMethod: simplify BindMethod() 2021-12-03 13:51:18 +01:00
Max Kellermann
0ed24f3a05 util/IntrusiveList: disallow copying IntrusiveListHook 2021-12-03 13:50:05 +01:00
Max Kellermann
e25e0030e7 increment version number to 0.23.6 2021-12-01 20:01:22 +01:00
Max Kellermann
df4b6b92f2 release v0.23.5 2021-12-01 20:00:00 +01:00
Max Kellermann
1c69913eca decoder/flac: submit MixRamp only if there is actual data 2021-12-01 17:58:51 +01:00
Max Kellermann
cb5c6259fd decoder/mad: submit MixRamp only if there is actual data
Fixes MixRamp failures when a MP3 file has two ID3 tags, one of them
without MixRamp.
2021-12-01 17:19:53 +01:00
Max Kellermann
bf287fefb5 decoder/mad: move parse_id3_mixramp() to tag/Id3MixRamp.cxx 2021-12-01 17:11:36 +01:00
Max Kellermann
20bf1d68e6 MixRampInfo: move to tag/ 2021-12-01 17:09:02 +01:00
Max Kellermann
9bc4c168fd tag/MixRamp: rename to MixRampParser.cxx 2021-12-01 17:07:53 +01:00
Max Kellermann
3415049d1c test/tag/TestMixRampParser: include the header, not the .cxx file 2021-12-01 17:07:39 +01:00
Max Kellermann
a45949b597 tag/MixRamp: [[gnu::...]] attributes 2021-12-01 15:48:33 +01:00
Max Kellermann
6009d4abab tag/MixRamp: use std::string_view 2021-12-01 15:47:54 +01:00
Max Kellermann
16fb843c9b tag/MixRamp: fix typo which broken MixRamp
Fixes regression by commit 8e0d810968 which is 2 years old, and nobody
noticed.  D'oh, how embarassing!
2021-12-01 15:46:31 +01:00
Max Kellermann
36b333459b test/tag/TestMixRampParser: new unit test 2021-12-01 15:46:01 +01:00
Max Kellermann
4d3320233e test/test_mixramp: move to test/tag/ 2021-12-01 15:33:17 +01:00
Max Kellermann
933a1a41e6 lib/upnp/Discovery: use InjectEvent instead of DeferEvent
Fixes regression by commit 774b4313f2
2021-11-30 18:03:27 +01:00
August2111
1ff8626716 MSVC util/StringAPI.hxx add usage of MSVC compiler 2021-11-26 17:30:17 +01:00
Max Kellermann
c30466b84a net/IPv4Address: add method GetPortBE() 2021-11-26 16:25:43 +01:00
Max Kellermann
868f1a4431 net/UniqueSocketDescriptor, ...: include <utility> instead of <algorithm>
Since C++11, std::swap() lives in <utility>.
2021-11-26 16:25:29 +01:00
Max Kellermann
05f529fffd util/StringStrip: use [[gnu::...]] attributes 2021-11-26 16:24:55 +01:00
Max Kellermann
f01388559f .github/workflows/build.yml: fix the ccache.key 2021-11-26 13:32:48 +01:00
Max Kellermann
27edd4a610 .github/workflows: merge build-{linux,macos}.yml into one 2021-11-26 13:32:08 +01:00
Max Kellermann
cc421b04cd test/meson.build: add "protocol:gtest" where appropriate 2021-11-26 08:47:06 +01:00
Max Kellermann
3f2bc325a1 test/meson.build: fix test() indent 2021-11-26 08:40:40 +01:00
Max Kellermann
54686dfd79 test/meson.build: add dependencies on run_input
Fixes spurious unit test failures because run_input has not yet been
built.
2021-11-26 08:35:49 +01:00
Rosen Penev
f22cf02ed8 fix wrong namespace name
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-26 08:08:45 +01:00
Rosen Penev
5b51d0f733 use some auto
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-26 08:08:45 +01:00
Rosen Penev
e03f82636a const reference conversion
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-23 12:33:03 -08:00
Rosen Penev
d53d85bd79 remove unused includes
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-23 12:33:03 -08:00
Max Kellermann
4682ae0898 command/database: support relative offsets for "searchadd"
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1337
2021-11-23 12:17:32 +01:00
Max Kellermann
fd5b195879 .github/workflows/build-macos.yml: use actions/setup-python@v1
Without it, BSFishy/meson-build defaults to /usr/local/bin/python,
which is Python 2.
2021-11-23 12:17:32 +01:00
Max Kellermann
bb5df9839d .github/workflows/build-macos.yml: install Meson, ninja and Boost 2021-11-23 12:17:32 +01:00
Max Kellermann
be34d55291 .github/workflows: add macOS build 2021-11-23 11:41:40 +01:00
Max Kellermann
c13911b171 .github/workflows: auto-build with GitHub Actions 2021-11-23 10:45:14 +01:00
Max Kellermann
6f83bdd6f3 Merge branch '1' of git://github.com/neheb/MPD 2021-11-23 10:39:07 +01:00
Rosen Penev
9bcd425a85 array conversions
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-23 01:38:10 -08:00
Max Kellermann
ec917f70d2 Merge remote-tracking branches 'neheb/2' and 'neheb/3' 2021-11-23 09:23:43 +01:00
Rosen Penev
40ce4eeb43 use cinttypes header
stdint.h is deprecated.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-22 23:30:36 -08:00
Rosen Penev
29ae84e199 manual braced init
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-22 23:30:04 -08:00
Rosen Penev
250011f016 return by braced init list
shorter

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-22 23:28:08 -08:00
Max Kellermann
e08c85ae2d doc/mpd.conf.5.rst: move ReplayGain documentation to user.rst 2021-11-22 22:25:04 +01:00
Max Kellermann
dcb5ca203c db/DatabasePlaylist: increment only one variable
Fixes "searchaddpl" bug emitting bogus error "Bad position".

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1338
2021-11-22 20:47:34 +01:00
Max Kellermann
77df5a8f24 lib/pcre: migrate to PCRE2
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1352
2021-11-22 19:32:45 +01:00
kaliko
d6bebd2507 doc/conf.py: Set sidebar width to 300px to limit wrapping
This enhances readability in sidebar, especially for "User’s Manual" and
"Protocol" pages
2021-11-20 10:49:15 +01:00
Max Kellermann
f74996c02f Merge remote-tracking branches 'neheb/1', 'neheb/2', 'neheb/3', 'neheb/4' and 'neheb/5' 2021-11-20 07:55:24 +01:00
Max Kellermann
eea2d35d3a util/AllocatedString, ...: add missing include for std::exchange()
Fixes building with GCC 12.
2021-11-19 16:06:20 +01:00
Max Kellermann
d94e8bd82d queue/IdTable: include cleanup 2021-11-19 16:03:09 +01:00
Max Kellermann
b0c92e1a34 queue/IdTable: lazy-initialize the "data" array
With large "max_playlist_length" settings, the "data" array can be
very large, and initializing it during MPD startup causes page faults,
resulting in allocation of physical RAM.  This commit postpones the
initialization until the queue is really large, to avoid wasting
memory.
2021-11-19 16:00:39 +01:00
Max Kellermann
ead5bcf048 queue/IdTable: make size const 2021-11-19 15:51:10 +01:00
kaliko
bdd268a524 doc/user.rst: update build dependencies on Debian Bullseye 2021-11-19 11:04:47 +01:00
Shen-Ta Hsieh
e783c2bd2c util/LazyRandomEngine: use std::optional to avoid allocation
Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
2021-11-14 03:53:42 +08:00
Rosen Penev
837fc98638 use const references
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 17:18:33 -08:00
Rosen Penev
5deca66fdc add various nodiscard
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 17:17:26 -08:00
Rosen Penev
cfe2dd4147 use nullptr
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 17:16:19 -08:00
Rosen Penev
00f8d65a17 remove std::move
clang-tidy reports this is trivially copyable and thus std::move has no
effect.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 17:15:21 -08:00
Rosen Penev
4e0e4c00bf treewide: replace lock_guard with scoped_lock
SonarLint reports the latter to be better:

std::scoped_lock basically provides the same feature as std::lock_guard,
but is more generic: It can lock several mutexes at the same time, with a
deadlock prevention mechanism (see {rule:cpp:S5524}). The equivalent code
to perform simultaneous locking with std::lock_guard is significantly more
complex. Therefore, it is simpler to use std::scoped_lock all the time,
even when locking only one mutex (there will be no performance impact).

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 17:13:03 -08:00
Max Kellermann
a8c77a6fba Merge branch '1' of git://github.com/neheb/MPD 2021-11-11 10:33:17 +01:00
Rosen Penev
31aa6d0c4f use auto with make_unique
C arrays can be used with make_unique in C++17.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 01:33:03 -08:00
Max Kellermann
d051c4931d Merge branch '2' of git://github.com/neheb/MPD 2021-11-11 10:32:45 +01:00
Rosen Penev
94b0baceb0 convert address_family_ranking to std::array
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-11-11 01:27:31 -08:00
Max Kellermann
16feb261e2 increment version number to 0.23.5 2021-11-11 10:18:19 +01:00
Max Kellermann
f084bf7872 release v0.23.4 2021-11-11 10:16:36 +01:00
Max Kellermann
1112d3907a Revert "systemd: add "RuntimeDirectory" directive"
This reverts commit 552c30eae4.

It has caused various problems; for example, MPD wasn't able to write
the pid_file (which was already mitigated by commit a4e4217204).

And apparently, the socket file created in the same directory by
mpd.socket disappears when mpd.service (re)creates the directory.  I
could not reproduce this problem with 247.3, but maybe this is a bug
in older systemd versions?

Until we figure out why this happens, let's remove the
RuntimeDirectory directive.  A future MPD version may be launched as
regular user, not as root, which will eliminate one major problem with
RuntimeDirectory.
2021-11-11 10:16:13 +01:00
Max Kellermann
3464497880 command/database: add optional position parameter to "searchaddpl"
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1328
2021-11-11 09:52:49 +01:00
Max Kellermann
651f57bced command/playlist: save only if at least one song was added 2021-11-11 09:50:31 +01:00
Max Kellermann
b4e72aba6c command/playlist: move code to SearchInsertIntoPlaylist() 2021-11-11 09:40:41 +01:00
0xC0ncord
061dd2dfef output/plugins: fix build error with clang and -stdlib=libc++
This fixes this build error observed with clang and -stdlib=libc++:

../mpd-0.23.3/src/output/plugins/PipeWireOutputPlugin.cxx:661:55: error: implicit instantiation of undefined template 'std::array<std::byte, 64>'
        std::array<std::byte, MAX_CHANNELS * MAX_INTERLEAVE> buffer;
                                                             ^
/usr/include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^
2021-11-10 15:35:56 -05:00
Max Kellermann
5f4ec7de5b decoder/ffmpeg, lib/ffmpeg: make AVCodec pointers "const"
For libavcodec 59 support.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1333
2021-11-09 21:09:14 +01:00
Max Audron
6f81bb4b09 upnp: add option to configure interface for db plugin
Add an option to the UPnP database plugin to configure which interface
is used by upnp to discover servers.

upnp by default selects the first interface that is not loopback, which
in some cases might not be the desired interface. For example if wanting
to access a DLNA server over a VPN connection.

The "interface" option can now be set to the name of the desired
interface to achieve this.

The default behaviour remains unchanged.
2021-11-08 23:04:07 +01:00
Max Audron
4ed60a5711 upnp: expose interface configuration on UpnpInit2()
Adds the Interface Name as an argument to the *Init functions to make it
possible to select which interface is used by upnp to detect servers.

Currently "nullptr" is passed in to let the upnp library select an
interface, as before.
2021-11-08 22:53:01 +01:00
Max Kellermann
c93195c94b NEWS: fix typo 2021-11-05 14:45:43 +01:00
Max Kellermann
f30adac4bb doc/mpdconf.example: add comments recommending not to use log_file and pid_file 2021-11-05 09:06:27 +01:00
Max Kellermann
a4e4217204 Main: ignore the "pid_file" setting if started as systemd service
Commit 552c30eae caused problems for those people who still had a
"pid_file" setting (even though that is obsolete with systemd),
because now /run/mpd is owned by root:root (our mpd.service has no
User=mpd directive, so systemd starts MPD as root).

To work around this problem, and to be able to keep
RuntimeDirectory=mpd (which solved a problem of other MPD users), the
best compromise seems to just ignore the "pid_file" setting when it is
of no use.
2021-11-05 09:02:56 +01:00
Max Kellermann
8754d705a1 CommandLine: rename struct options 2021-11-05 08:57:12 +01:00
Max Kellermann
23d4a2d6a5 Main: pass struct options by reference 2021-11-05 08:56:05 +01:00
Max Kellermann
ce77b148d9 CommandLine: add option --systemd
This way, MPD can reliably detect whether it was started as systemd
service, which is better than checking sd_booted(), which only checks
whether systemd manages all services, but still MPD could be started
manually.
2021-11-05 08:51:49 +01:00
Max Kellermann
be3eca39e8 NEWS: add missing lines 2021-11-04 17:59:02 +01:00
Max Kellermann
3413b1aeb4 output/alsa: add option thesycon_dsd_workaround 2021-11-04 17:55:53 +01:00
Max Kellermann
356d13e9dd lib/alsa/HwSetup: add missing include 2021-11-04 17:55:15 +01:00
Max Kellermann
fa34bf0aaf Merge branch 'feature/win32-disable-openmpt123' of git://github.com/ibmibmibm/MPD 2021-11-04 15:11:26 +01:00
Max Kellermann
5d0941476a lib/alsa/Error: a std::system_error category for libasound errors 2021-11-04 14:59:00 +01:00
Max Kellermann
5ff0bbd0f8 lib/fmt/AudioFormatFormatter: add formatter for SampleFormat 2021-11-04 14:55:01 +01:00
Shen-Ta Hsieh
a3764e533c python/build/libs.py: disable building libopenmpt cli
Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
2021-11-04 21:54:12 +08:00
Shen-Ta Hsieh
3e05cba30e python/build/libs.py: update libopenmpt configure flags
Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
2021-11-04 15:23:24 +08:00
Max Kellermann
14b3c0f0af event/Loop: destruct the Uring::Manager in the destructor before assert()
Fixes assertion failure when the EventLoop gets destructed before
Run() was ever called.

Fixes https://bugs.debian.org/998310
2021-11-03 18:32:14 +01:00
Max Kellermann
67aff05051 increment version number to 0.23.4 2021-10-31 18:17:35 +01:00
288 changed files with 2510 additions and 1183 deletions
.github/workflows
NEWS
android
doc
meson.build
python/build
src
CommandLine.cxxCommandLine.hxxLocateUri.cxxLogBackend.cxxMain.cxxMapper.cxxMusicBuffer.cxxMusicBuffer.hxxMusicPipe.cxxMusicPipe.hxxPlaylistDatabase.cxxPlaylistDatabase.hxxPlaylistFile.cxxPlaylistSave.cxxRemoteTagCache.cxxSingleMode.hxxSongSave.cxxSongSave.hxxStateFile.cxxTagAny.cxxTagSave.cxx
archive
client
command
config
db
decoder
encoder
event
filter
fs
input
io
lib
mixer
neighbor
net
output
pcm
player
playlist
protocol
queue
song
sticker
storage
tag
thread
util
subprojects
systemd
test
win32

133
.github/workflows/build.yml vendored Normal file

@@ -0,0 +1,133 @@
---
on:
workflow_dispatch:
push:
paths-ignore:
- 'android/**'
- 'build/**'
- 'doc/**'
- 'python/**'
- 'subprojects/**'
- 'systemd/**'
- 'win32/**'
branches:
- master
- v0.23.x
pull_request:
paths-ignore:
- 'android/**'
- 'build/**'
- 'doc/**'
- 'python/**'
- 'subprojects/**'
- 'systemd/**'
- 'win32/**'
branches:
- master
- v0.23.x
jobs:
build-linux:
runs-on: ubuntu-latest
env:
CC: 'ccache gcc-10'
CXX: 'ccache g++-10'
steps:
- id: checkout
uses: actions/checkout@v2
- id: cache-ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: linux
- name: Install dependencies
run: |
sudo apt install -y --no-install-recommends \
g++-10 libfmt-dev libboost-dev \
libgtest-dev \
libpcre2-dev \
libsystemd-dev libdbus-1-dev \
libicu-dev \
libcurl4-gnutls-dev \
libpcre2-dev \
libavahi-client-dev \
libmad0-dev libmpg123-dev libid3tag0-dev \
libflac-dev libvorbis-dev libopus-dev libogg-dev \
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
libfluidsynth-dev libgme-dev libmikmod-dev libmodplug-dev \
libmpcdec-dev libwavpack-dev libwildmidi-dev \
libsidplay2-dev libsidutils-dev libresid-builder-dev \
libavcodec-dev libavformat-dev \
libmp3lame-dev libtwolame-dev libshine-dev \
libsamplerate0-dev libsoxr-dev \
libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
libzzip-dev \
libyajl-dev libexpat-dev \
libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
libpulse-dev libshout3-dev \
libsndio-dev \
libmpdclient-dev \
libnfs-dev \
libupnp-dev \
libsqlite3-dev \
libchromaprint-dev \
libgcrypt20-dev
- name: Full Build
uses: BSFishy/meson-build@v1.0.3
with:
action: test
directory: output/full
setup-options: -Ddocumentation=disabled -Dtest=true -Dsystemd=enabled -Dpcre=enabled
meson-version: 0.56.0
- name: Mini Build
uses: BSFishy/meson-build@v1.0.3
with:
action: test
directory: output/mini
setup-options: -Dbuildtype=minsize -Dauto_features=disabled -Dtest=true -Ddaemon=false -Dinotify=false -Depoll=false -Deventfd=false -Dsignalfd=false -Dtcp=false -Ddsd=false -Ddatabase=false -Dneighbor=false -Dcue=false -Dfifo=false -Dhttpd=false -Dpipe=false -Drecorder=false -Dsnapcast=false
meson-version: 0.56.0
build-macos:
runs-on: macos-latest
steps:
- id: checkout
uses: actions/checkout@v2
- id: cache-ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: macos
- uses: actions/setup-python@v1
- name: Install dependencies
run: |
brew install \
meson ninja \
fmt \
boost \
googletest \
icu4c \
ffmpeg \
libnfs \
yajl \
libupnp \
libid3tag \
chromaprint \
libsamplerate \
libsoxr \
flac \
opus \
libvorbis \
faad2 \
wavpack \
libmpdclient
- name: Meson Build
uses: BSFishy/meson-build@v1.0.3
with:
action: test
directory: output
setup-options: -Ddocumentation=disabled -Dtest=true
meson-version: 0.56.0

49
NEWS

@@ -1,3 +1,52 @@
ver 0.23.7 (2022/05/09)
* database
- upnp: support pupnp 1.14
* decoder
- ffmpeg: fix HLS seeking
- opus: fix missing song length on high-latency files
* output
- shout: require at least libshout 2.4.0
* mixer
- pipewire: fix volume restore
- software: update volume of disabled outputs
* support libiconv
ver 0.23.6 (2022/03/14)
* protocol
- support filename "cover.webp" for "albumart" command
- support "readcomments" and "readpicture" on CUE tracks
* decoder
- ffmpeg: fix end-of-file check (update stuck at empty files)
- opus: fix "readpicture" on Opus files
* output
- pipewire: fix crash bug if setting volume before playback starts
- wasapi: fix resume after pause
ver 0.23.5 (2021/12/01)
* protocol
- support relative offsets for "searchadd"
- fix "searchaddpl" bug (bogus error "Bad position")
* database
- upnp: fix crash bug
* tags
- fix MixRamp support
* migrate to PCRE2
* GCC 12 build fixes
ver 0.23.4 (2021/11/11)
* protocol
- add optional position parameter to "searchaddpl"
* decoder
- ffmpeg: support libavcodec 59
* output
- alsa: add option "thesycon_dsd_workaround" to work around device bug
* fix crash on debug builds if startup fails
* systemd
- remove "RuntimeDirectory" directive because it caused problems
- ignore the "pid_file" setting if started as systemd service
* Windows
- enable the "openmpt" decoder plugin
ver 0.23.3 (2021/10/31)
* protocol
- add optional position parameter to "add" and "playlistadd"

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.musicpd"
android:installLocation="auto"
android:versionCode="63"
android:versionName="0.23.3">
android:versionCode="66"
android:versionName="0.23.7">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
@@ -17,10 +17,9 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application android:allowBackup="true"
android:debuggable="true"
android:requestLegacyExternalStorage="true"
android:icon="@drawable/icon"
android:banner="@drawable/icon"
@@ -43,7 +42,6 @@
<receiver android:name=".Receiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.HEADSET_PLUG" />
</intent-filter>
</receiver>
<service android:name=".Main" android:process=":main"/>

@@ -13,7 +13,7 @@ android_abi = sys.argv[3]
configure_args = sys.argv[4:]
if not os.path.isfile(os.path.join(sdk_path, 'tools', 'android')):
print("SDK not found in", ndk_path, file=sys.stderr)
print("SDK not found in", sdk_path, file=sys.stderr)
sys.exit(1)
if not os.path.isdir(ndk_path):

54
android/gdb.sh Executable file

@@ -0,0 +1,54 @@
#!/bin/sh
# This script need the following modification in ANDROID_NDK in order to attach
# to the good :main pid
#--- a/prebuilt/linux-x86_64/bin/ndk-gdb.py
#+++ b/prebuilt/linux-x86_64/bin/ndk-gdb.py
#@@ -669,7 +669,7 @@
# log("Sleeping for {} seconds.".format(args.delay))
# time.sleep(args.delay)
#
#- pids = gdbrunner.get_pids(device, pkg_name)
#+ pids = gdbrunner.get_pids(device, pkg_name + ":main")
# if len(pids) == 0:
# error("Failed to find running process '{}'".format(pkg_name))
# if len(pids) > 1:
SCRIPT_PATH=$(dirname $0)
BUILD_PATH="`pwd`"
TMP_PATH="$BUILD_PATH/gdb"
NDK_GDB_ARGS="--force"
ANDROID_NDK=$1
if [ ! -f $ANDROID_NDK/source.properties ];then
echo "usage: $0 ANDROID_NDK"
exit 1
fi
if [ ! -f $BUILD_PATH/libmpd.so ];then
echo "This script need to be executed from the android build directory"
exit 1
fi
rm -rf "$TMP_PATH"
mkdir -p "$TMP_PATH"
ANDROID_MANIFEST="$SCRIPT_PATH/AndroidManifest.xml"
ABI=`ls "$BUILD_PATH/android/apk/apk/lib" --sort=time | head -n 1`
if [ ! -f "$ANDROID_MANIFEST" -o "$ABI" = "" ]; then
echo "Invalid manifest/ABI, did you try building first ?"
exit 1
fi
mkdir -p "$TMP_PATH"/jni
touch "$TMP_PATH"/jni/Android.mk
echo "APP_ABI := $ABI" > "$TMP_PATH"/jni/Application.mk
DEST=obj/local/$ABI
mkdir -p "$TMP_PATH/$DEST"
cp "$BUILD_PATH/libmpd.so" "$TMP_PATH/$DEST"
cp "$ANDROID_MANIFEST" "$TMP_PATH"
(cd "$TMP_PATH" && bash $ANDROID_NDK/ndk-gdb $NDK_GDB_ARGS)

@@ -24,14 +24,13 @@ import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothClass;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.media.AudioManager;
import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
@@ -200,24 +199,14 @@ public class Main extends Service implements Runnable {
return;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_HEADSET_PLUG);
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (!mPauseOnHeadphonesDisconnect) {
if (!mPauseOnHeadphonesDisconnect)
return;
}
if (intent.getAction().equals(Intent.ACTION_HEADSET_PLUG)) {
if (intent.hasExtra("state") && intent.getIntExtra("state", 0) == 0)
pause();
} else {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (device.getBluetoothClass().hasService(BluetoothClass.Service.AUDIO))
pause();
}
if (intent.getAction() == AudioManager.ACTION_AUDIO_BECOMING_NOISY)
pause();
}
}, filter);

@@ -25,16 +25,18 @@ import android.content.Intent;
import android.util.Log;
public class Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Receiver", "onReceive: " + intent);
if (intent.getAction() == "android.intent.action.BOOT_COMPLETED") {
if (Settings.Preferences.getBoolean(context,
Settings.Preferences.KEY_RUN_ON_BOOT, false)) {
final boolean wakelock = Settings.Preferences.getBoolean(context,
Settings.Preferences.KEY_WAKELOCK, false);
Main.start(context, wakelock);
}
}
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d("Receiver", "onReceive: " + intent);
if (intent.getAction() == "android.intent.action.BOOT_COMPLETED") {
if (Settings.Preferences.getBoolean(context,
Settings.Preferences.KEY_RUN_ON_BOOT,
false)) {
final boolean wakelock =
Settings.Preferences.getBoolean(context,
Settings.Preferences.KEY_WAKELOCK, false);
Main.start(context, wakelock);
}
}
}
}

@@ -38,7 +38,7 @@ author = 'Max Kellermann'
# built documents.
#
# The short X.Y version.
version = '0.23.3'
version = '0.23.7'
# The full version, including alpha/beta/rc tags.
#release = version + '~git'
@@ -107,6 +107,7 @@ html_theme = 'classic'
# documentation.
#
# html_theme_options = {}
html_theme_options = {"sidebarwidth": "300px"}
# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []

@@ -128,23 +128,6 @@ audio_output
no audio_output section is specified, then MPD will scan for a usable audio
output.
replaygain <off or album or track or auto>
If specified, mpd will adjust the volume of songs played using ReplayGain
tags (see https://wiki.hydrogenaud.io/index.php?title=Replaygain).
Setting this to "album" will
adjust volume using the album's ReplayGain tags, while setting it to "track"
will adjust it using the track ReplayGain tags. "auto" uses the track
ReplayGain tags if random play is activated otherwise the album ReplayGain
tags. Currently only FLAC, Ogg Vorbis, Musepack, and MP3 (through ID3v2
ReplayGain tags, not APEv2) are supported.
replaygain_preamp <-15 to 15>
This is the gain (in dB) applied to songs with ReplayGain tags.
volume_normalization <yes or no>
If yes, mpd will normalize the volume of songs as they play. The default is
no.
filesystem_charset <charset>
This specifies the character set used for the filesystem. A list of supported
character sets can be obtained by running "iconv -l". The default is

@@ -26,22 +26,25 @@
# files over an accepted protocol.
#
#db_file "~/.mpd/database"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog.
#
#log_file "~/.mpd/log"
# If you use systemd, do not configure a log_file. With systemd, MPD
# defaults to the systemd journal, which is fine.
#
#log_file "~/.mpd/log"
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
#pid_file "~/.mpd/pid"
# If you use systemd, do not configure a pid_file.
#
#pid_file "~/.mpd/pid"
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
@@ -76,7 +79,7 @@
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other than the default, any.
# This setting can deny access to control of the daemon. Not effective if
# systemd socket activiation is in use.
# systemd socket activation is in use.
#
# For network
#bind_to_address "any"
@@ -182,7 +185,7 @@
# cache_directory "~/.local/share/mpd/cache"
#}
#
# An example of database config for a sattelite setup
# An example of database config for a satellite setup
#
#music_directory "nfs://fileserver.local/srv/mp3"
#database {

@@ -61,6 +61,15 @@ upnp
Provides access to UPnP media servers.
.. list-table::
:widths: 20 80
:header-rows: 1
* - Setting
- Description
* - **interface**
- Interface used to discover media servers. Decided by upnp if left unconfigured.
Storage plugins
===============
@@ -841,6 +850,11 @@ The `Advanced Linux Sound Architecture (ALSA) <http://www.alsa-project.org/>`_ p
("stop" or "pause") in DSD mode (native DSD or DoP). This is a
workaround for some DACs which emit noise when stopping DSD
playback.
* - **thesycon_dsd_workaround yes|no**
- If enabled, enables a workaround for a bug in Thesycon USB
audio receivers. On these devices, playing DSD512 or PCM
causes all subsequent attempts to play other DSD rates to fail,
which can be fixed by briefly playing PCM at 44.1 kHz.
* - **allowed_formats F1 F2 ...**
- Specifies a list of allowed audio formats, separated by a space. All items may contain asterisks as a wild card, and may be followed by "=dop" to enable DoP (DSD over PCM) for this particular format. The first matching format is used, and if none matches, MPD chooses the best fallback of this list.

@@ -479,7 +479,7 @@ Querying :program:`MPD`'s status
current song in seconds, but with higher resolution.
- ``duration`` [#since_0_20]_: Duration of the current song in seconds.
- ``bitrate``: instantaneous bitrate in kbps
- ``xfade``: ``crossfade`` in seconds
- ``xfade``: ``crossfade`` in seconds (see :ref:`crossfading`)
- ``mixrampdb``: ``mixramp`` threshold in dB
- ``mixrampdelay``: ``mixrampdelay`` in seconds
- ``audio``: The format emitted by the decoder plugin during
@@ -519,17 +519,19 @@ Playback options
.. _command_crossfade:
:command:`crossfade {SECONDS}`
Sets crossfading between songs.
Sets crossfading between songs. See :ref:`crossfading`.
.. _command_mixrampdb:
:command:`mixrampdb {deciBels}`
Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp
Sets the threshold at which songs will be overlapped.
See :ref:`mixramp`.
.. _command_mixrampdelay:
:command:`mixrampdelay {SECONDS}`
Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.
See :ref:`mixramp`.
.. _command_random:
@@ -543,6 +545,13 @@ Playback options
Sets repeat state to ``STATE``,
``STATE`` should be 0 or 1.
If enabled, MPD keeps repeating the whole queue (:ref:`single mode
<command_single>` disabled) or the current song (:ref:`single mode
<command_single>` enabled).
If :ref:`random mode <command_random>` is also enabled, the
playback order will be shuffled each time the queue gets repeated.
.. _command_setvol:
:command:`setvol {VOL}`
@@ -771,8 +780,8 @@ Whenever possible, ids should be used.
.. _command_playlistfind:
:command:`playlistfind {FILTER}`
Finds songs in the queue with strict
matching.
Search the queue for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`).
.. _command_playlistid:
@@ -792,8 +801,10 @@ Whenever possible, ids should be used.
.. _command_playlistsearch:
:command:`playlistsearch {FILTER}`
Searches case-insensitively for partial matches in the
queue.
Search the queue for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`).
Parameters have the same meaning as for :ref:`find
<command_playlistfind>`, except that search is not case sensitive.
.. _command_plchanges:
@@ -1222,10 +1233,12 @@ The music database
The ``position`` parameter specifies where the songs will be
inserted. [#since_0_23]_
It can be relative to the current song as in :ref:`addid
<command_addid>`. [#since_0_23_5]_
.. _command_searchaddpl:
:command:`searchaddpl {NAME} {FILTER} [sort {TYPE}] [window {START:END}]`
:command:`searchaddpl {NAME} {FILTER} [sort {TYPE}] [window {START:END}] [position POS]`
Search the database for songs matching
``FILTER`` (see :ref:`Filters <filter_syntax>`) and add them to
the playlist named ``NAME``.
@@ -1234,6 +1247,9 @@ The music database
Parameters have the same meaning as for :ref:`search <command_search>`.
The ``position`` parameter specifies where the songs will be
inserted. [#since_0_23_4]_
.. _command_update:
:command:`update [URI]`
@@ -1655,3 +1671,5 @@ client-to-client messages are local to the current partition.
.. [#since_0_23] Since :program:`MPD` 0.23
.. [#since_0_23_1] Since :program:`MPD` 0.23.1
.. [#since_0_23_3] Since :program:`MPD` 0.23.3
.. [#since_0_23_4] Since :program:`MPD` 0.23.4
.. [#since_0_23_5] Since :program:`MPD` 0.23.5

@@ -64,13 +64,13 @@ In any case, you need:
Each plugin usually needs a codec library, which you also need to
install. Check the :doc:`plugins` for details about required libraries
For example, the following installs a fairly complete list of build dependencies on Debian Buster:
For example, the following installs a fairly complete list of build dependencies on Debian Bullseye:
.. code-block:: none
apt install meson g++ \
libfmt-dev \
libpcre3-dev \
libpcre2-dev \
libmad0-dev libmpg123-dev libid3tag0-dev \
libflac-dev libvorbis-dev libopus-dev libogg-dev \
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
@@ -465,6 +465,11 @@ The following table lists the audio_output options valid for all plugins:
implement an external mixer, see :ref:`external_mixer`) or no mixer
(:samp:`none`). By default, the hardware mixer is used for
devices which support it, and none for the others.
* - **replay_gain_handler software|mixer|none**
- Specifies how :ref:`replay_gain` is applied. The default is
``software``, which uses an internal software volume control.
``mixer`` uses the configured (hardware) mixer control.
``none`` disables replay gain on this audio output.
* - **filters "name,...**"
- The specified configured filters are instantiated in the given
order. Each filter name refers to a ``filter`` block, see
@@ -583,6 +588,85 @@ Sometimes, music needs to be resampled before it can be played; for example, CDs
Check the :ref:`resampler_plugins` reference for a list of resamplers
and how to configure them.
Volume Normalization Settings
-----------------------------
.. _replay_gain:
Replay Gain
^^^^^^^^^^^
The setting ``replaygain`` specifies whether MPD shall adjust the
volume of songs played using `ReplayGain
<https://wiki.hydrogenaud.io/index.php?title=Replaygain>`__ tags.
Setting this to ``album`` will adjust volume using the album's
ReplayGain tags, while setting it to ``track`` will adjust it using
the "track" ReplayGain tags. ``auto`` uses the track ReplayGain tags
if random play is activated otherwise the album ReplayGain
tags.
If ReplayGain is enabled, then the setting ``replaygain_preamp`` is
set to a value (in dB) between ``-15`` and ``15``. This is the gain
applied to songs with ReplayGain tags.
ReplayGain is usually implemented with a software volume filter (which
prevents `Bit-perfect playback`_). To use a hardware mixer, set
``replay_gain_handler`` to ``mixer`` in the ``audio_output`` section
(see :ref:`config_audio_output` for details).
Simple Volume Normalization
^^^^^^^^^^^^^^^^^^^^^^^^^^^
MPD implements a very simple volume normalization method which can be
enabled by setting ``volume_normalization`` to ``yes``. It supports
16 bit PCM only.
.. _crossfading:
Cross-Fading
------------
If ``crossfade`` is set to a positive number, then adjacent songs are
cross-faded by this number of seconds. This is a run-time setting
:ref:`which can be controlled by clients <command_crossfade>`,
e.g. with :program:`mpc`::
mpc crossfade 10
mpc crossfade 0
Zero means cross-fading is disabled.
Cross-fading is only possible if both songs have the same audio
format. At the cost of quality loss and higher CPU usage, you can
make sure this is always given by configuring
:ref:`audio_output_format`.
.. _mixramp:
MixRamp
^^^^^^^
MixRamp tags describe the loudness levels at start and end of a song
and can be used by MPD to find the best time to begin cross-fading.
MPD enables MixRamp if:
- Cross-fade is enabled
- :ref:`mixrampdelay <command_mixrampdelay>` is set to a positive
value, e.g.::
mpc mixrampdelay 1
- :ref:`mixrampdb <command_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`
is configured)
The `MixRamp <http://sourceforge.net/projects/mixramp>`__ tool can be
used to add MixRamp tags to your song files.
Client Connections
------------------
@@ -1019,6 +1103,15 @@ See :ref:`tags` for a list of supported tags.
The :ref:`metadata_to_use <metadata_to_use>` setting can be used to
enable or disable certain tags.
Note that :program:`MPD` may not necessarily read metadata itself,
instead relying on data reported by the decoder that was used to read
a file. For example, this is the case for the FFmpeg decoder: both
:program:`MPD` and FFmpeg need to support a given metadata format in
order for metadata to be picked up correctly.
Only if a decoder does not have metadata support will :program:`MPD`
attempt to parse a song's metadata itself.
The queue
---------
@@ -1076,6 +1169,7 @@ Check list for bit-perfect playback:
* Disable sound processing inside ALSA by configuring a "hardware"
device (:samp:`hw:0,0` or similar).
* Don't use software volume (setting :code:`mixer_type`).
* Don't use :ref:`replay_gain`.
* Don't force :program:`MPD` to use a specific audio format (settings
:code:`format`, :ref:`audio_output_format <audio_output_format>`).
* Verify that you are really doing bit-perfect playback using :program:`MPD`'s verbose log and :file:`/proc/asound/card*/pcm*p/sub*/hw_params`. Some DACs can also indicate the audio format.

@@ -1,7 +1,7 @@
project(
'mpd',
['c', 'cpp'],
version: '0.23.3',
version: '0.23.7',
meson_version: '>= 0.56.0',
default_options: [
'c_std=c11',
@@ -44,7 +44,7 @@ version_conf = configuration_data()
version_conf.set_quoted('PACKAGE', meson.project_name())
version_conf.set_quoted('PACKAGE_NAME', meson.project_name())
version_conf.set_quoted('VERSION', meson.project_version())
version_conf.set_quoted('PROTOCOL_VERSION', '0.23.3')
version_conf.set_quoted('PROTOCOL_VERSION', '0.23.5')
configure_file(output: 'Version.h', configuration: version_conf)
conf = configuration_data()

@@ -12,14 +12,14 @@ from build.boost import BoostProject
from build.jack import JackProject
libmpdclient = MesonProject(
'https://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.19.tar.xz',
'158aad4c2278ab08e76a3f2b0166c99b39fae00ee17231bd225c5a36e977a189',
'https://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.20.tar.xz',
'18793f68e939c3301e34d8fcadea1f7daa24143941263cecadb80126194e277d',
'lib/libmpdclient.a',
)
libogg = CmakeProject(
'http://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz',
'c163bc12bc300c401b6aa35907ac682671ea376f13ae0969a220f7ddf71893fe',
'http://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz',
'c4d91be36fc8e54deae7575241e03f4211eb102afb3fc0775fbbc1b740016705',
'lib/libogg.a',
[
'-DBUILD_SHARED_LIBS=OFF',
@@ -43,8 +43,8 @@ opus = AutotoolsProject(
)
flac = AutotoolsProject(
'http://downloads.xiph.org/releases/flac/flac-1.3.3.tar.xz',
'213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748',
'http://downloads.xiph.org/releases/flac/flac-1.3.4.tar.xz',
'8ff0607e75a322dd7cd6ec48f4f225471404ae2730d0ea945127b1355155e737',
'lib/libFLAC.a',
[
'--disable-shared', '--enable-static',
@@ -55,8 +55,8 @@ flac = AutotoolsProject(
)
zlib = ZlibProject(
'http://zlib.net/zlib-1.2.11.tar.xz',
'4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066',
'http://zlib.net/zlib-1.2.12.tar.xz',
'7db46b8d7726232a621befaab4a1c870f00a90805511c0e0090441dac57def18',
'lib/libz.a',
)
@@ -116,8 +116,12 @@ libopenmpt = AutotoolsProject(
'892aea7a599b5d21842bebf463b5aafdad5711be7008dd84401920c6234820af',
'lib/libopenmpt.a',
[
'--disable-shared', '--enable-static'
'--disable-shared', '--enable-static',
'--disable-openmpt123',
'--without-mpg123', '--without-ogg', '--without-vorbis', '--without-vorbisfile',
'--without-portaudio', '--without-portaudiocpp', '--without-sndfile',
],
base='libopenmpt-0.5.12+release.autotools',
)
wildmidi = CmakeProject(
@@ -147,8 +151,8 @@ gme = CmakeProject(
)
ffmpeg = FfmpegProject(
'http://ffmpeg.org/releases/ffmpeg-4.4.1.tar.xz',
'eadbad9e9ab30b25f5520fbfde99fae4a92a1ae3c0257a8d68569a4651e30e02',
'http://ffmpeg.org/releases/ffmpeg-5.0.1.tar.xz',
'ef2efae259ce80a240de48ec85ecb062cecca26e4352ffb3fda562c21a93007b',
'lib/libavcodec.a',
[
'--disable-shared', '--enable-static',
@@ -376,14 +380,14 @@ ffmpeg = FfmpegProject(
)
openssl = OpenSSLProject(
'https://www.openssl.org/source/openssl-3.0.0.tar.gz',
'59eedfcb46c25214c9bd37ed6078297b4df01d012267fe9e9eee31f61bc70536',
'https://www.openssl.org/source/openssl-3.0.3.tar.gz',
'9384a2b0570dd80358841464677115df785edb941c71211f75076d72fe6b438f',
'include/openssl/ossl_typ.h',
)
curl = CmakeProject(
'https://curl.se/download/curl-7.79.1.tar.xz',
'0606f74b1182ab732a17c11613cbbaf7084f2e6cca432642d0e3ad7c224c3689',
'https://curl.se/download/curl-7.83.0.tar.xz',
'bbff0e6b5047e773f3c3b084d80546cc1be4e354c09e419c2d0ef6116253511a',
'lib/libcurl.a',
[
'-DBUILD_CURL_EXE=OFF',
@@ -411,14 +415,14 @@ curl = CmakeProject(
'-DBUILD_TESTING=OFF',
],
windows_configure_args=[
'-DCMAKE_USE_SCHANNEL=ON',
'-DCURL_USE_SCHANNEL=ON',
],
patches='src/lib/curl/patches',
)
libnfs = AutotoolsProject(
'https://github.com/sahlberg/libnfs/archive/libnfs-4.0.0.tar.gz',
'6ee77e9fe220e2d3e3b1f53cfea04fb319828cc7dbb97dd9df09e46e901d797d',
'https://github.com/sahlberg/libnfs/archive/libnfs-5.0.1.tar.gz',
'7ef445410b42f36b9bad426608b53ccb9ccca4101e545c383f564c11db672ca8',
'lib/libnfs.a',
[
'--disable-shared', '--enable-static',
@@ -429,8 +433,7 @@ libnfs = AutotoolsProject(
'--disable-utils', '--disable-examples',
],
base='libnfs-libnfs-4.0.0',
patches='src/lib/nfs/patches',
base='libnfs-libnfs-5.0.1',
autoreconf=True,
)
@@ -441,7 +444,7 @@ jack = JackProject(
)
boost = BoostProject(
'https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2',
'fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854',
'https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.bz2',
'475d589d51a7f8b3ba2ba4eda022b170e562ca3b760ee922c146b6c65856ef39',
'include/boost/version.hpp',
)

@@ -53,19 +53,21 @@ pkgconfig = '{toolchain.pkg_config}'
f.write(f"""
[properties]
root = '{toolchain.install_prefix}'
[built-in options]
c_args = {repr((toolchain.cppflags + ' ' + toolchain.cflags).split())}
c_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
cpp_args = {repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split())}
cpp_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
""")
if 'android' in toolchain.arch:
f.write("""
# Keep Meson from executing Android-x86 test binariees
needs_exe_wrapper = true
""")
f.write(f"""
[built-in options]
c_args = {repr((toolchain.cppflags + ' ' + toolchain.cflags).split())}
c_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
cpp_args = {repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split())}
cpp_link_args = {repr(toolchain.ldflags.split() + toolchain.libs.split())}
""")
f.write(f"""

@@ -86,6 +86,9 @@ enum Option {
OPTION_KILL,
OPTION_NO_CONFIG,
OPTION_NO_DAEMON,
#ifdef __linux__
OPTION_SYSTEMD,
#endif
OPTION_STDOUT,
OPTION_STDERR,
OPTION_VERBOSE,
@@ -98,6 +101,9 @@ static constexpr OptionDef option_defs[] = {
{"kill", "kill the currently running mpd session"},
{"no-config", "don't read from config"},
{"no-daemon", "don't detach from console"},
#ifdef __linux__
{"systemd", "systemd service mode"},
#endif
{"stdout", nullptr}, // hidden, compatibility with old versions
{"stderr", "print messages to stderr"},
{"verbose", 'v', "verbose logging"},
@@ -328,7 +334,7 @@ bool ConfigLoader::TryFile(const AllocatedPath &base_path, Path path)
}
void
ParseCommandLine(int argc, char **argv, struct options &options,
ParseCommandLine(int argc, char **argv, CommandLineOptions &options,
ConfigData &config)
{
bool use_config_file = true;
@@ -349,6 +355,13 @@ ParseCommandLine(int argc, char **argv, struct options &options,
options.daemon = false;
break;
#ifdef __linux__
case OPTION_SYSTEMD:
options.daemon = false;
options.systemd = true;
break;
#endif
case OPTION_STDOUT:
case OPTION_STDERR:
options.log_stderr = true;

@@ -22,15 +22,20 @@
struct ConfigData;
struct options {
struct CommandLineOptions {
bool kill = false;
bool daemon = true;
#ifdef __linux__
bool systemd = false;
#endif
bool log_stderr = false;
bool verbose = false;
};
void
ParseCommandLine(int argc, char **argv, struct options &options,
ParseCommandLine(int argc, char **argv, CommandLineOptions &options,
ConfigData &config);
#endif

@@ -48,15 +48,14 @@ LocateFileUri(const char *uri, const Client *client
/* this path was relative to the music
directory */
// TODO: don't use suffix.data() (ok for now because we know it's null-terminated)
return LocatedUri(LocatedUri::Type::RELATIVE,
suffix.data());
return {LocatedUri::Type::RELATIVE, suffix.data()};
}
#endif
if (client != nullptr)
client->AllowFile(path);
return LocatedUri(LocatedUri::Type::PATH, uri, std::move(path));
return {LocatedUri::Type::PATH, uri, std::move(path)};
}
static LocatedUri
@@ -90,8 +89,7 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri
const auto suffix = storage->MapToRelativeUTF8(uri);
if (suffix.data() != nullptr)
// TODO: don't use suffix.data() (ok for now because we know it's null-terminated)
return LocatedUri(LocatedUri::Type::RELATIVE,
suffix.data());
return {LocatedUri::Type::RELATIVE, suffix.data()};
}
if (kind == UriPluginKind::STORAGE &&
@@ -99,7 +97,7 @@ LocateAbsoluteUri(UriPluginKind kind, const char *uri
throw std::invalid_argument("Unsupported URI scheme");
#endif
return LocatedUri(LocatedUri::Type::ABSOLUTE, uri);
return {LocatedUri::Type::ABSOLUTE, uri};
}
LocatedUri

@@ -19,6 +19,7 @@
#include "LogBackend.hxx"
#include "Log.hxx"
#include "util/Compiler.h"
#include "util/Domain.hxx"
#include "util/StringStrip.hxx"
#include "Version.h"
@@ -110,7 +111,7 @@ chomp_length(std::string_view p) noexcept
#ifdef HAVE_SYSLOG
gcc_const
[[gnu::const]]
static int
ToSysLogLevel(LogLevel log_level) noexcept
{

@@ -142,14 +142,24 @@ struct Config {
#ifdef ENABLE_DAEMON
static void
glue_daemonize_init(const struct options *options,
glue_daemonize_init(const CommandLineOptions &options,
const ConfigData &config)
{
auto pid_file = config.GetPath(ConfigOption::PID_FILE);
#ifdef __linux__
if (options.systemd && pid_file != nullptr) {
pid_file = nullptr;
fprintf(stderr,
"Ignoring the 'pid_file' setting in systemd mode\n");
}
#endif
daemonize_init(config.GetString(ConfigOption::USER),
config.GetString(ConfigOption::GROUP),
config.GetPath(ConfigOption::PID_FILE));
std::move(pid_file));
if (options->kill)
if (options.kill)
daemonize_kill();
}
@@ -361,7 +371,8 @@ Instance::BeginShutdownPartitions() noexcept
}
static inline void
MainConfigured(const struct options &options, const ConfigData &raw_config)
MainConfigured(const CommandLineOptions &options,
const ConfigData &raw_config)
{
#ifdef ENABLE_DAEMON
daemonize_close_stdin();
@@ -384,7 +395,7 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
const Config config(raw_config);
#ifdef ENABLE_DAEMON
glue_daemonize_init(&options, raw_config);
glue_daemonize_init(options, raw_config);
#endif
TagLoadConfig(raw_config);
@@ -582,7 +593,7 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
static void
AndroidMain()
{
struct options options;
CommandLineOptions options;
ConfigData raw_config;
const auto sdcard = Environment::getExternalStorageDirectory();
@@ -642,7 +653,7 @@ Java_org_musicpd_Bridge_pause(JNIEnv *, jclass)
static inline void
MainOrThrow(int argc, char *argv[])
{
struct options options;
CommandLineOptions options;
ConfigData raw_config;
ParseCommandLine(argc, argv, options, raw_config);

@@ -85,15 +85,15 @@ map_fs_to_utf8(Path path_fs) noexcept
{
if (path_fs.IsAbsolute()) {
if (global_instance->storage == nullptr)
return std::string();
return {};
const auto music_dir_fs = global_instance->storage->MapFS("");
if (music_dir_fs.IsNull())
return std::string();
return {};
auto relative = music_dir_fs.Relative(path_fs);
if (relative == nullptr || StringIsEmpty(relative))
return std::string();
return {};
path_fs = Path::FromFS(relative);
}

@@ -29,8 +29,8 @@ MusicBuffer::MusicBuffer(unsigned num_chunks)
MusicChunkPtr
MusicBuffer::Allocate() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
return MusicChunkPtr(buffer.Allocate(), MusicChunkDeleter(*this));
const std::scoped_lock<Mutex> protect(mutex);
return {buffer.Allocate(), MusicChunkDeleter(*this)};
}
void
@@ -44,7 +44,7 @@ MusicBuffer::Return(MusicChunk *chunk) noexcept
chunk->next.reset();
chunk->other.reset();
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
assert(!chunk->other || !chunk->other->other);

@@ -54,7 +54,7 @@ public:
#endif
bool IsFull() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return buffer.IsFull();
}

@@ -27,7 +27,7 @@
bool
MusicPipe::Contains(const MusicChunk *chunk) const noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
for (const MusicChunk *i = head.get(); i != nullptr; i = i->next.get())
if (i == chunk)
@@ -41,7 +41,7 @@ MusicPipe::Contains(const MusicChunk *chunk) const noexcept
MusicChunkPtr
MusicPipe::Shift() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
auto chunk = std::move(head);
if (chunk != nullptr) {
@@ -81,7 +81,7 @@ MusicPipe::Push(MusicChunkPtr chunk) noexcept
assert(!chunk->IsEmpty());
assert(chunk->length == 0 || chunk->audio_format.IsValid());
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
assert(size > 0 || !audio_format.IsDefined());
assert(!audio_format.IsDefined() ||

@@ -77,7 +77,7 @@ public:
*/
[[gnu::pure]]
const MusicChunk *Peek() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return head.get();
}
@@ -101,7 +101,7 @@ public:
*/
[[gnu::pure]]
unsigned GetSize() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return size;
}

@@ -19,8 +19,8 @@
#include "PlaylistDatabase.hxx"
#include "db/PlaylistVector.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/LineReader.hxx"
#include "io/BufferedOutputStream.hxx"
#include "time/ChronoUtil.hxx"
#include "util/StringStrip.hxx"
#include "util/RuntimeError.hxx"
@@ -42,7 +42,7 @@ playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv)
}
void
playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
playlist_metadata_load(LineReader &file, PlaylistVector &pv, const char *name)
{
PlaylistInfo pm(name);

@@ -24,7 +24,7 @@
class PlaylistVector;
class BufferedOutputStream;
class TextFile;
class LineReader;
void
playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv);
@@ -33,6 +33,7 @@ playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv);
* Throws #std::runtime_error on error.
*/
void
playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name);
playlist_metadata_load(LineReader &file, PlaylistVector &pv,
const char *name);
#endif

@@ -28,8 +28,8 @@
#include "Mapper.hxx"
#include "protocol/RangeArg.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/FileOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/FileOutputStream.hxx"
#include "io/BufferedOutputStream.hxx"
#include "config/Data.hxx"
#include "config/Option.hxx"
#include "config/Defaults.hxx"

@@ -28,8 +28,8 @@
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/FileSystem.hxx"
#include "fs/io/FileOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/FileOutputStream.hxx"
#include "io/BufferedOutputStream.hxx"
#include "util/UriExtract.hxx"
static void

@@ -98,7 +98,7 @@ RemoteTagCache::ItemResolved(Item &item) noexcept
void
RemoteTagCache::InvokeHandlers() noexcept
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
while (!invoke_list.empty()) {
auto &item = invoke_list.front();
@@ -125,7 +125,7 @@ RemoteTagCache::Item::OnRemoteTag(Tag &&_tag) noexcept
scanner.reset();
const std::lock_guard<Mutex> lock(parent.mutex);
const std::scoped_lock<Mutex> lock(parent.mutex);
parent.ItemResolved(*this);
}
@@ -137,6 +137,6 @@ RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept
scanner.reset();
const std::lock_guard<Mutex> lock(parent.mutex);
const std::scoped_lock<Mutex> lock(parent.mutex);
parent.ItemResolved(*this);
}

@@ -31,7 +31,7 @@ enum class SingleMode : uint8_t {
/**
* Return the string representation of a #SingleMode.
*/
[[gnu::pure]]
[[gnu::const]]
const char *
SingleToString(SingleMode mode) noexcept;

@@ -22,8 +22,8 @@
#include "db/plugins/simple/Song.hxx"
#include "song/DetachedSong.hxx"
#include "TagSave.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/LineReader.hxx"
#include "io/BufferedOutputStream.hxx"
#include "tag/ParseName.hxx"
#include "tag/Tag.hxx"
#include "tag/Builder.hxx"
@@ -85,7 +85,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
}
DetachedSong
song_load(TextFile &file, const char *uri,
song_load(LineReader &file, const char *uri,
std::string *target_r)
{
DetachedSong song(uri);

@@ -28,7 +28,7 @@ struct Song;
struct AudioFormat;
class DetachedSong;
class BufferedOutputStream;
class TextFile;
class LineReader;
void
song_save(BufferedOutputStream &os, const Song &song);
@@ -43,7 +43,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song);
* Throws on error.
*/
DetachedSong
song_load(TextFile &file, const char *uri,
song_load(LineReader &file, const char *uri,
std::string *target_r=nullptr);
#endif

@@ -22,8 +22,8 @@
#include "output/State.hxx"
#include "queue/PlaylistState.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/FileOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/FileOutputStream.hxx"
#include "io/BufferedOutputStream.hxx"
#include "storage/StorageState.hxx"
#include "Partition.hxx"
#include "Instance.hxx"

@@ -21,12 +21,16 @@
#include "TagStream.hxx"
#include "TagFile.hxx"
#include "tag/Generic.hxx"
#include "song/LightSong.hxx"
#include "db/Interface.hxx"
#include "storage/StorageInterface.hxx"
#include "client/Client.hxx"
#include "protocol/Ack.hxx"
#include "fs/AllocatedPath.hxx"
#include "input/InputStream.hxx"
#include "util/Compiler.h"
#include "util/ScopeExit.hxx"
#include "util/StringCompare.hxx"
#include "util/UriExtract.hxx"
#include "LocateUri.hxx"
@@ -51,10 +55,67 @@ TagScanFile(const Path path_fs, TagHandler &handler)
ScanGenericTags(path_fs, handler);
}
#ifdef ENABLE_DATABASE
/**
* Collapse "../" prefixes in a URI relative to the specified base
* URI.
*/
static std::string
ResolveUri(std::string_view base, const char *relative)
{
while (true) {
const char *rest = StringAfterPrefix(relative, "../");
if (rest == nullptr)
break;
if (base == ".")
throw ProtocolError(ACK_ERROR_NO_EXIST, "Bad real URI");
base = PathTraitsUTF8::GetParent(base);
relative = rest;
}
return PathTraitsUTF8::Build(base, relative);
}
/**
* Look up the specified song in the database and return its
* (resolved) "real" URI.
*/
static std::string
GetRealSongUri(Client &client, std::string_view uri)
{
const auto &db = client.GetDatabaseOrThrow();
const auto *song = db.GetSong(uri);
if (song == nullptr)
throw ProtocolError(ACK_ERROR_NO_EXIST, "No such song");
AtScopeExit(&db, song) { db.ReturnSong(song); };
if (song->real_uri == nullptr)
return {};
return ResolveUri(PathTraitsUTF8::GetParent(uri), song->real_uri);
}
#endif
static void
TagScanDatabase(Client &client, const char *uri, TagHandler &handler)
{
#ifdef ENABLE_DATABASE
const auto real_uri = GetRealSongUri(client, uri);
if (!real_uri.empty()) {
uri = real_uri.c_str();
// TODO: support absolute paths?
if (uri_has_scheme(uri))
return TagScanStream(uri, handler);
}
const Storage *storage = client.GetStorage();
if (storage == nullptr) {
#else

@@ -19,7 +19,7 @@
#include "TagSave.hxx"
#include "tag/Tag.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/BufferedOutputStream.hxx"
#define SONG_TIME "Time: "

@@ -26,7 +26,6 @@
#include "plugins/ZzipArchivePlugin.hxx"
#include <cassert>
#include <iterator>
#include <string.h>

@@ -162,7 +162,7 @@ class Iso9660InputStream final : public InputStream {
std::array<uint8_t, ISO_BLOCKSIZE> data;
public:
ConstBuffer<uint8_t> Read() const noexcept {
[[nodiscard]] ConstBuffer<uint8_t> Read() const noexcept {
assert(fill <= data.size());
assert(position <= fill);

@@ -35,7 +35,7 @@
#include <utility>
#include <inttypes.h> /* for PRIoffset (PRIu64) */
#include <cinttypes> /* for PRIoffset (PRIu64) */
struct ZzipDir {
ZZIP_DIR *const dir;

@@ -80,7 +80,7 @@ Response::VFmtError(enum ack code,
Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
(int)code, list_index, command);
VFmt(format_str, std::move(args));
VFmt(format_str, args);
Write("\n");
}

@@ -18,6 +18,7 @@
*/
#include "DatabaseCommands.hxx"
#include "PositionArg.hxx"
#include "Request.hxx"
#include "Partition.hxx"
#include "db/DatabaseQueue.hxx"
@@ -86,6 +87,20 @@ ParseQueuePosition(Request &args, unsigned queue_length)
return queue_length;
}
static unsigned
ParseInsertPosition(Request &args, const playlist &playlist)
{
if (args.size >= 2 && StringIsEqual(args[args.size - 2], "position")) {
unsigned position = ParseInsertPosition(args.back(), playlist);
args.pop_back();
args.pop_back();
return position;
}
/* append to the end of the queue by default */
return playlist.queue.GetLength();
}
/**
* Convert all remaining arguments to a #DatabaseSelection.
*
@@ -160,7 +175,8 @@ handle_match_add(Client &client, Request args, bool fold_case)
{
auto &partition = client.GetPartition();
const auto queue_length = partition.playlist.queue.GetLength();
const unsigned position = ParseQueuePosition(args, queue_length);
const unsigned position =
ParseInsertPosition(args, partition.playlist);
SongFilter filter;
const auto selection = ParseDatabaseSelection(args, fold_case, filter);
@@ -199,13 +215,20 @@ handle_searchaddpl(Client &client, Request args, Response &)
{
const char *playlist = args.shift();
const unsigned position = ParseQueuePosition(args, UINT_MAX);
SongFilter filter;
const auto selection = ParseDatabaseSelection(args, true, filter);
const Database &db = client.GetDatabaseOrThrow();
search_add_to_playlist(db, client.GetStorage(),
playlist, selection);
if (position == UINT_MAX)
search_add_to_playlist(db, client.GetStorage(),
playlist, selection);
else
SearchInsertIntoPlaylist(db, client.GetStorage(), selection,
playlist, position);
return CommandResult::OK;
}

@@ -160,8 +160,7 @@ find_stream_art(std::string_view directory, Mutex &mutex)
static constexpr auto art_names = std::array {
"cover.png",
"cover.jpg",
"cover.tiff",
"cover.bmp",
"cover.webp",
};
for(const auto name : art_names) {
@@ -213,7 +212,7 @@ read_stream_art(Response &r, const std::string_view art_directory,
std::min<offset_type>(art_file_size - offset,
r.GetClient().binary_limit);
std::unique_ptr<std::byte[]> buffer(new std::byte[buffer_size]);
auto buffer = std::make_unique<std::byte[]>(buffer_size);
std::size_t read_size = 0;
if (buffer_size > 0) {

@@ -67,7 +67,7 @@ protected:
}
void CancelThread() noexcept override {
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
cancel = true;
cond.notify_one();
}
@@ -204,7 +204,7 @@ GetChromaprintCommand::DecodeFile(std::string_view suffix, InputStream &is,
return false;
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
if (cancel)
throw StopDecoder();
}

@@ -231,15 +231,14 @@ handle_playlistadd_position(Client &client, const char *playlist_name,
editor.Insert(position, uri);
} else {
#ifdef ENABLE_DATABASE
const auto &db = client.GetDatabaseOrThrow();
const auto *storage = client.GetStorage();
const DatabaseSelection selection(uri, true, nullptr);
db.Visit(selection, [&editor, &position, storage](const auto &song){
editor.Insert(position,
DatabaseDetachSong(storage, song));
++position;
});
if (SearchInsertIntoPlaylist(client.GetDatabaseOrThrow(),
client.GetStorage(),
selection,
editor, position) == 0)
/* no song was found, don't need to save */
return CommandResult::OK;
#else
(void)client;
r.Error(ACK_ERROR_NO_EXIST, "No database");

@@ -31,8 +31,8 @@
#include "fs/FileSystem.hxx"
#include "fs/List.hxx"
#include "fs/Path.hxx"
#include "fs/io/FileReader.hxx"
#include "fs/io/BufferedReader.hxx"
#include "io/FileReader.hxx"
#include "io/BufferedReader.hxx"
#include "Log.hxx"
#include <cassert>

@@ -22,6 +22,7 @@
#include "PlaylistFile.hxx"
#include "Interface.hxx"
#include "song/DetachedSong.hxx"
#include "protocol/Ack.hxx"
#include <functional>
@@ -41,3 +42,41 @@ search_add_to_playlist(const Database &db, const Storage *storage,
const auto f = [=](auto && arg1) { return AddSong(storage, playlist_path_utf8, arg1); };
db.Visit(selection, f);
}
unsigned
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
const DatabaseSelection &selection,
PlaylistFileEditor &playlist,
unsigned position)
{
assert(position <= playlist.size());
unsigned n = 0;
db.Visit(selection, [&playlist, position, &n, storage](const auto &song){
playlist.Insert(position + n,
DatabaseDetachSong(storage, song));
++n;
});
return n;
}
void
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
const DatabaseSelection &selection,
const char *playlist_name,
unsigned position)
{
PlaylistFileEditor editor{
playlist_name,
PlaylistFileEditor::LoadMode::TRY,
};
if (position > editor.size())
throw ProtocolError{ACK_ERROR_ARG, "Bad position"};
if (SearchInsertIntoPlaylist(db, storage, selection,
editor, position) > 0)
editor.Save();
}

@@ -25,6 +25,7 @@
class Database;
class Storage;
struct DatabaseSelection;
class PlaylistFileEditor;
gcc_nonnull(3)
void
@@ -32,4 +33,19 @@ search_add_to_playlist(const Database &db, const Storage *storage,
const char *playlist_path_utf8,
const DatabaseSelection &selection);
/**
* @return the number of songs added
*/
unsigned
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
const DatabaseSelection &selection,
PlaylistFileEditor &playlist,
unsigned position);
void
SearchInsertIntoPlaylist(const Database &db, const Storage *storage,
const DatabaseSelection &selection,
const char *playlist_name,
unsigned position);
#endif

@@ -35,6 +35,7 @@ db_plugins = static_library(
include_directories: inc,
dependencies: [
upnp_dep,
pcre_dep,
libmpdclient_dep,
log_dep,
],

@@ -20,8 +20,8 @@
#include "DatabaseSave.hxx"
#include "db/DatabaseLock.hxx"
#include "DirectorySave.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/TextFile.hxx"
#include "io/BufferedOutputStream.hxx"
#include "io/LineReader.hxx"
#include "tag/ParseName.hxx"
#include "tag/Settings.hxx"
#include "fs/Charset.hxx"
@@ -64,7 +64,7 @@ db_save_internal(BufferedOutputStream &os, const Directory &music_root)
}
void
db_load_internal(TextFile &file, Directory &music_root)
db_load_internal(LineReader &file, Directory &music_root)
{
char *line;
unsigned format = 0;

@@ -22,7 +22,7 @@
struct Directory;
class BufferedOutputStream;
class TextFile;
class LineReader;
void
db_save_internal(BufferedOutputStream &os, const Directory &root);
@@ -31,6 +31,6 @@ db_save_internal(BufferedOutputStream &os, const Directory &root);
* Throws #std::runtime_error on error.
*/
void
db_load_internal(TextFile &file, Directory &root);
db_load_internal(LineReader &file, Directory &root);
#endif

@@ -278,5 +278,5 @@ Directory::Walk(bool recursive, const SongFilter *filter,
LightDirectory
Directory::Export() const noexcept
{
return LightDirectory(GetPath(), mtime);
return {GetPath(), mtime};
}

@@ -23,8 +23,8 @@
#include "SongSave.hxx"
#include "song/DetachedSong.hxx"
#include "PlaylistDatabase.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "io/LineReader.hxx"
#include "io/BufferedOutputStream.hxx"
#include "time/ChronoUtil.hxx"
#include "util/StringAPI.hxx"
#include "util/StringCompare.hxx"
@@ -121,7 +121,7 @@ ParseLine(Directory &directory, const char *line)
}
static Directory *
directory_load_subdir(TextFile &file, Directory &parent, std::string_view name)
directory_load_subdir(LineReader &file, Directory &parent, std::string_view name)
{
if (parent.FindChild(name) != nullptr)
throw FormatRuntimeError("Duplicate subdirectory '%.*s'",
@@ -152,7 +152,7 @@ directory_load_subdir(TextFile &file, Directory &parent, std::string_view name)
}
void
directory_load(TextFile &file, Directory &directory)
directory_load(LineReader &file, Directory &directory)
{
const char *line;

@@ -21,7 +21,7 @@
#define MPD_DIRECTORY_SAVE_HXX
struct Directory;
class TextFile;
class LineReader;
class BufferedOutputStream;
void
@@ -31,6 +31,6 @@ directory_save(BufferedOutputStream &os, const Directory &directory);
* Throws #std::runtime_error on error.
*/
void
directory_load(TextFile &file, Directory &directory);
directory_load(LineReader &file, Directory &directory);
#endif

@@ -34,8 +34,8 @@
#include "db/DatabaseLock.hxx"
#include "db/DatabaseError.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/FileOutputStream.hxx"
#include "io/BufferedOutputStream.hxx"
#include "io/FileOutputStream.hxx"
#include "fs/FileInfo.hxx"
#include "config/Block.hxx"
#include "fs/FileSystem.hxx"
@@ -46,7 +46,7 @@
#include "Log.hxx"
#ifdef ENABLE_ZLIB
#include "fs/io/GzipOutputStream.hxx"
#include "lib/zlib/GzipOutputStream.hxx"
#endif
#include <cerrno>
@@ -316,7 +316,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
if (r.rest.find('/') == std::string_view::npos) {
if (visit_song) {
Song *song = r.directory->FindSong(r.rest);
const Song *song = r.directory->FindSong(r.rest);
if (song != nullptr) {
const auto song2 = song->Export();
if (selection.Match(song2))

@@ -39,6 +39,7 @@
#include "util/ConstBuffer.hxx"
#include "util/RecursiveMap.hxx"
#include "util/SplitString.hxx"
#include "config/Block.hxx"
#include <cassert>
#include <string>
@@ -76,10 +77,13 @@ class UpnpDatabase : public Database {
UpnpClient_Handle handle;
UPnPDeviceDirectory *discovery;
const char* interface;
public:
explicit UpnpDatabase(EventLoop &_event_loop) noexcept
explicit UpnpDatabase(EventLoop &_event_loop, const ConfigBlock &block) noexcept
:Database(upnp_db_plugin),
event_loop(_event_loop) {}
event_loop(_event_loop),
interface(block.GetBlockValue("interface", nullptr)) {}
static DatabasePtr Create(EventLoop &main_event_loop,
EventLoop &io_event_loop,
@@ -147,15 +151,15 @@ private:
DatabasePtr
UpnpDatabase::Create(EventLoop &, EventLoop &io_event_loop,
[[maybe_unused]] DatabaseListener &listener,
const ConfigBlock &) noexcept
const ConfigBlock &block) noexcept
{
return std::make_unique<UpnpDatabase>(io_event_loop);
return std::make_unique<UpnpDatabase>(io_event_loop, block);;
}
void
UpnpDatabase::Open()
{
handle = UpnpClientGlobalInit();
handle = UpnpClientGlobalInit(interface);
discovery = new UPnPDeviceDirectory(event_loop, handle);
try {
@@ -246,11 +250,11 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server,
{
const SongFilter *filter = selection.filter;
if (selection.filter == nullptr)
return UPnPDirContent();
return {};
const auto searchcaps = server.getSearchCapabilities(handle);
if (searchcaps.empty())
return UPnPDirContent();
return {};
std::string cond;
for (const auto &item : filter->GetItems()) {

@@ -33,7 +33,6 @@
#include "util/StringCompare.hxx"
#include "Log.hxx"
#include <string>
#include <exception>
#include <string.h>

@@ -34,7 +34,7 @@ UpdateQueueItem
UpdateQueue::Pop() noexcept
{
if (update_queue.empty())
return UpdateQueueItem();
return {};
auto i = std::move(update_queue.front());
update_queue.pop_front();

@@ -36,7 +36,7 @@ UpdateRemoveService::RunDeferred() noexcept
std::forward_list<std::string> copy;
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
std::swap(uris, copy);
}
@@ -55,7 +55,7 @@ UpdateRemoveService::Remove(std::string &&uri)
bool was_empty;
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
was_empty = uris.empty();
uris.emplace_front(std::move(uri));
}

@@ -84,7 +84,7 @@ try {
}
bool
directory_child_access(Storage &storage, const Directory &directory,
directory_child_access(const Storage &storage, const Directory &directory,
std::string_view name, int mode) noexcept
{
#ifdef _WIN32

@@ -55,7 +55,7 @@ directory_child_is_regular(Storage &storage, const Directory &directory,
*/
[[gnu::pure]]
bool
directory_child_access(Storage &storage, const Directory &directory,
directory_child_access(const Storage &storage, const Directory &directory,
std::string_view name, int mode) noexcept;
#endif

@@ -152,7 +152,7 @@ DecoderBridge::FlushChunk() noexcept
if (!chunk->IsEmpty())
dc.pipe->Push(std::move(chunk));
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
dc.client_cond.notify_one();
}
@@ -214,7 +214,7 @@ DecoderBridge::GetVirtualCommand() noexcept
DecoderCommand
DecoderBridge::LockGetVirtualCommand() noexcept
{
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
return GetVirtualCommand();
}
@@ -274,7 +274,7 @@ DecoderBridge::Ready(const AudioFormat audio_format,
seekable);
{
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
dc.SetReady(audio_format, seekable, duration);
}
@@ -300,7 +300,7 @@ DecoderBridge::GetCommand() noexcept
void
DecoderBridge::CommandFinished() noexcept
{
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
assert(dc.command != DecoderCommand::NONE || initial_seek_running);
assert(dc.command != DecoderCommand::SEEK ||

@@ -22,7 +22,7 @@
#include "Command.hxx"
#include "pcm/AudioFormat.hxx"
#include "MixRampInfo.hxx"
#include "tag/MixRampInfo.hxx"
#include "input/Handler.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
@@ -231,7 +231,7 @@ public:
[[gnu::pure]]
bool LockIsIdle() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return IsIdle();
}
@@ -241,7 +241,7 @@ public:
[[gnu::pure]]
bool LockIsStarting() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return IsStarting();
}
@@ -253,7 +253,7 @@ public:
[[gnu::pure]]
bool LockHasFailed() const noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return HasFailed();
}
@@ -284,7 +284,7 @@ public:
* Like CheckRethrowError(), but locks and unlocks the object.
*/
void LockCheckRethrowError() const {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
CheckRethrowError();
}
@@ -360,7 +360,7 @@ private:
}
void LockAsynchronousCommand(DecoderCommand cmd) noexcept {
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
command = cmd;
Signal();
}

@@ -35,8 +35,8 @@
#include "DecoderPlugin.hxx"
#include "ReplayGainInfo.hxx"
#include "tag/Tag.hxx"
#include "tag/MixRampInfo.hxx"
#include "pcm/AudioFormat.hxx"
#include "MixRampInfo.hxx"
#include "config/Block.hxx"
#include "Chrono.hxx"

@@ -20,7 +20,7 @@
#ifndef MPD_DECODER_READER_HXX
#define MPD_DECODER_READER_HXX
#include "fs/io/Reader.hxx"
#include "io/Reader.hxx"
class DecoderClient;
class InputStream;

@@ -262,7 +262,7 @@ static void
MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is)
{
{
const std::lock_guard<Mutex> protect(bridge.dc.mutex);
const std::scoped_lock<Mutex> protect(bridge.dc.mutex);
if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF)
/* ReplayGain is disabled */
return;
@@ -337,7 +337,7 @@ TryDecoderFile(DecoderBridge &bridge, Path path_fs, std::string_view suffix,
DecoderControl &dc = bridge.dc;
if (plugin.file_decode != nullptr) {
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
} else if (plugin.stream_decode != nullptr) {
std::unique_lock<Mutex> lock(dc.mutex);
@@ -365,7 +365,7 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs,
bridge.Reset();
DecoderControl &dc = bridge.dc;
const std::lock_guard<Mutex> protect(dc.mutex);
const std::scoped_lock<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
}

@@ -83,8 +83,8 @@ audiofile_file_read(AFvirtualfile *vfile, void *data, size_t length) noexcept
static AFfileoffset
audiofile_file_length(AFvirtualfile *vfile) noexcept
{
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
InputStream &is = afis.is;
const AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
const InputStream &is = afis.is;
return is.GetSize();
}
@@ -92,8 +92,8 @@ audiofile_file_length(AFvirtualfile *vfile) noexcept
static AFfileoffset
audiofile_file_tell(AFvirtualfile *vfile) noexcept
{
AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
InputStream &is = afis.is;
const AudioFileInputStream &afis = *(AudioFileInputStream *)vfile->closure;
const InputStream &is = afis.is;
return is.GetOffset();
}

@@ -38,7 +38,7 @@
#include "tag/Builder.hxx"
#include "tag/Handler.hxx"
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
#include "tag/MixRampParser.hxx"
#include "input/InputStream.hxx"
#include "pcm/CheckAudioFormat.hxx"
#include "util/ScopeExit.hxx"
@@ -384,7 +384,8 @@ static void
FfmpegParseMetaData(const AVStream &stream,
ReplayGainInfo &rg, MixRampInfo &mr)
{
FfmpegParseMetaData(*stream.metadata, rg, mr);
if (stream.metadata != nullptr)
FfmpegParseMetaData(*stream.metadata, rg, mr);
}
static void
@@ -393,7 +394,9 @@ FfmpegParseMetaData(const AVFormatContext &format_context, int audio_stream,
{
assert(audio_stream >= 0);
FfmpegParseMetaData(*format_context.metadata, rg, mr);
if (format_context.metadata != nullptr)
FfmpegParseMetaData(*format_context.metadata, rg, mr);
FfmpegParseMetaData(*format_context.streams[audio_stream],
rg, mr);
}
@@ -468,7 +471,7 @@ static bool
IsSeekable(const AVFormatContext &format_context) noexcept
{
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 6, 100)
return (format_context.ctx_flags & AVFMTCTX_UNSEEKABLE) != 0;
return (format_context.ctx_flags & AVFMTCTX_UNSEEKABLE) == 0;
#else
(void)format_context;
return false;
@@ -502,7 +505,7 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
FmtDebug(ffmpeg_domain, "codec '{}'",
codec_descriptor->name);
AVCodec *codec = avcodec_find_decoder(codec_params.codec_id);
const AVCodec *codec = avcodec_find_decoder(codec_params.codec_id);
if (!codec) {
LogError(ffmpeg_domain, "Unsupported audio codec");
@@ -530,9 +533,8 @@ FfmpegDecode(DecoderClient &client, InputStream *input,
: FromFfmpegTimeChecked(format_context.duration, AV_TIME_BASE_Q);
client.Ready(audio_format,
input
? input->IsSeekable()
: IsSeekable(format_context),
(input ? input->IsSeekable() : false)
|| IsSeekable(format_context),
total_time);
FfmpegParseMetaData(client, format_context, audio_stream);

@@ -21,6 +21,7 @@
#define __STDC_CONSTANT_MACROS
#include "FfmpegIo.hxx"
#include "libavutil/mem.h"
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
@@ -35,7 +36,11 @@ AvioStream::~AvioStream()
inline int
AvioStream::Read(void *dest, int size)
{
return decoder_read(client, input, dest, size);
const auto nbytes = decoder_read(client, input, dest, size);
if (nbytes == 0)
return AVERROR_EOF;
return nbytes;
}
inline int64_t

@@ -78,7 +78,9 @@ FlacDecoder::OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc)
if (flac_parse_replay_gain(rgi, vc))
GetClient()->SubmitReplayGain(&rgi);
GetClient()->SubmitMixRamp(flac_parse_mixramp(vc));
if (auto mix_ramp = flac_parse_mixramp(vc);
mix_ramp.IsDefined())
GetClient()->SubmitMixRamp(std::move(mix_ramp));
tag = flac_vorbis_comments_to_tag(&vc);
}

@@ -23,9 +23,10 @@
#include "input/InputStream.hxx"
#include "tag/Id3Scan.hxx"
#include "tag/Id3ReplayGain.hxx"
#include "tag/Id3MixRamp.hxx"
#include "tag/Handler.hxx"
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
#include "tag/MixRampParser.hxx"
#include "pcm/CheckAudioFormat.hxx"
#include "util/Clamp.hxx"
#include "util/StringCompare.hxx"
@@ -268,35 +269,6 @@ MadDecoder::FillBuffer() noexcept
return true;
}
#ifdef ENABLE_ID3TAG
gcc_pure
static MixRampInfo
parse_id3_mixramp(struct id3_tag *tag) noexcept
{
MixRampInfo result;
struct id3_frame *frame;
for (unsigned i = 0; (frame = id3_tag_findframe(tag, "TXXX", i)); i++) {
if (frame->nfields < 3)
continue;
char *const key = (char *)
id3_ucs4_latin1duplicate(id3_field_getstring
(&frame->fields[1]));
char *const value = (char *)
id3_ucs4_latin1duplicate(id3_field_getstring
(&frame->fields[2]));
ParseMixRampTag(result, key, value);
free(key);
free(value);
}
return result;
}
#endif
inline void
MadDecoder::ParseId3(size_t tagsize, Tag *mpd_tag) noexcept
{
@@ -310,7 +282,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag *mpd_tag) noexcept
id3_data = stream.this_frame;
mad_stream_skip(&(stream), tagsize);
} else {
allocated.reset(new id3_byte_t[tagsize]);
allocated = std::make_unique<id3_byte_t[]>(tagsize);
memcpy(allocated.get(), stream.this_frame, count);
mad_stream_skip(&(stream), count);
@@ -338,7 +310,9 @@ MadDecoder::ParseId3(size_t tagsize, Tag *mpd_tag) noexcept
found_replay_gain = true;
}
client->SubmitMixRamp(parse_id3_mixramp(id3_tag.get()));
if (auto mix_ramp = Id3ToMixRampInfo(id3_tag.get());
mix_ramp.IsDefined())
client->SubmitMixRamp(std::move(mix_ramp));
}
#else /* !ENABLE_ID3TAG */

@@ -23,7 +23,7 @@
#include "tag/Handler.hxx"
#include "tag/Builder.hxx"
#include "tag/ReplayGain.hxx"
#include "tag/MixRamp.hxx"
#include "tag/MixRampParser.hxx"
#include "fs/Path.hxx"
#include "util/Domain.hxx"
#include "util/ScopeExit.hxx"

@@ -91,7 +91,8 @@ ScanOpusTags(const void *data, size_t size,
if (!r.Expect("OpusTags", 8))
return false;
if (!handler.WantPair() && !handler.WantTag())
if (!handler.WantPair() && !handler.WantTag() &&
!handler.WantPicture())
return true;
if (!r.SkipString())

@@ -27,7 +27,7 @@
#include "fs/AllocatedPath.hxx"
#include "lib/icu/Converter.hxx"
#ifdef HAVE_SIDPLAYFP
#include "fs/io/FileReader.hxx"
#include "io/FileReader.hxx"
#include "util/RuntimeError.hxx"
#endif
#include "util/StringFormat.hxx"
@@ -137,7 +137,7 @@ SidplayGlobal::SidplayGlobal(const ConfigBlock &block)
const auto kernal_path = block.GetPath("kernal");
if (!kernal_path.IsNull())
{
kernal.reset(new uint8_t[rom_size]);
kernal = std::make_unique<uint8_t[]>(rom_size);
loadRom(kernal_path, kernal.get());
}
@@ -145,7 +145,7 @@ SidplayGlobal::SidplayGlobal(const ConfigBlock &block)
const auto basic_path = block.GetPath("basic");
if (!basic_path.IsNull())
{
basic.reset(new uint8_t[rom_size]);
basic = std::make_unique<uint8_t[]>(rom_size);
loadRom(basic_path, basic.get());
}
#endif

@@ -19,7 +19,7 @@
#include "ToOutputStream.hxx"
#include "EncoderInterface.hxx"
#include "fs/io/OutputStream.hxx"
#include "io/OutputStream.hxx"
void
EncoderToOutputStream(OutputStream &os, Encoder &encoder)

@@ -3,6 +3,23 @@ encoder_features = configuration_data()
encoder_features.set('ENABLE_ENCODER', need_encoder)
if not need_encoder
if need_wave_encoder
# Special case for the Snapcast output plugin which only needs the
# PCM wave encoder encoder plugin
encoder_glue = static_library(
'encoder_glue',
'plugins/WaveEncoderPlugin.cxx',
include_directories: inc,
)
encoder_glue_dep = declare_dependency(
link_with: encoder_glue,
)
configure_file(output: 'Features.h', configuration: encoder_features)
subdir_done()
endif
encoder_glue_dep = dependency('', required: false)
configure_file(output: 'Features.h', configuration: encoder_features)
subdir_done()

@@ -35,7 +35,7 @@ if libshine_dep.found()
endif
encoder_features.set('ENABLE_WAVE_ENCODER', get_option('wave_encoder'))
if get_option('wave_encoder')
if get_option('wave_encoder') or need_wave_encoder
encoder_plugins_sources += 'WaveEncoderPlugin.cxx'
endif

@@ -68,7 +68,7 @@ private:
exception = std::current_exception();
}
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
done = true;
cond.notify_one();
}

@@ -52,6 +52,13 @@ EventLoop::EventLoop(
EventLoop::~EventLoop() noexcept
{
#if defined(HAVE_URING) && !defined(NDEBUG)
/* if Run() was never called (maybe because startup failed and
an exception is pending), we need to destruct the
Uring::Manager here or else the assertions below fail */
uring.reset();
#endif
assert(defer.empty());
assert(idle.empty());
#ifdef HAVE_THREADED_EVENT_LOOP
@@ -316,7 +323,7 @@ EventLoop::Run() noexcept
/* try to handle DeferEvents without WakeFD
overhead */
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
HandleInject();
#endif
@@ -339,7 +346,7 @@ EventLoop::Run() noexcept
#ifdef HAVE_THREADED_EVENT_LOOP
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
busy = true;
}
#endif
@@ -371,7 +378,7 @@ EventLoop::AddInject(InjectEvent &d) noexcept
bool must_wake;
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
if (d.IsPending())
return;
@@ -390,7 +397,7 @@ EventLoop::AddInject(InjectEvent &d) noexcept
void
EventLoop::RemoveInject(InjectEvent &d) noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
if (d.IsPending())
inject.erase(inject.iterator_to(d));
@@ -417,7 +424,7 @@ EventLoop::OnSocketReady([[maybe_unused]] unsigned flags) noexcept
wake_fd.Read();
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
HandleInject();
}

@@ -91,7 +91,7 @@ public:
}
#endif
bool IsDefined() const noexcept {
[[nodiscard]] bool IsDefined() const noexcept {
return event.IsDefined();
}

@@ -37,6 +37,7 @@
#endif
#include <algorithm>
#include <array>
#include <cassert>
#include <csignal>
@@ -62,7 +63,7 @@ public:
#endif
}
auto &GetEventLoop() const noexcept {
[[nodiscard]] auto &GetEventLoop() const noexcept {
return event.GetEventLoop();
}
@@ -90,12 +91,12 @@ private:
/* this should be enough - is it? */
static constexpr unsigned MAX_SIGNAL = 64;
static SignalHandler signal_handlers[MAX_SIGNAL];
static std::array<SignalHandler, MAX_SIGNAL> signal_handlers;
#ifdef USE_SIGNALFD
static sigset_t signal_mask;
#else
static std::atomic_bool signal_pending[MAX_SIGNAL];
static std::array<std::atomic_bool, MAX_SIGNAL> signal_pending;
#endif
static Manual<SignalMonitor> monitor;
@@ -153,7 +154,7 @@ void
SignalMonitorFinish() noexcept
{
#ifdef USE_SIGNALFD
std::fill_n(signal_handlers, MAX_SIGNAL, nullptr);
signal_handlers = {};
#else
struct sigaction sa;
sa.sa_flags = 0;
@@ -167,7 +168,7 @@ SignalMonitorFinish() noexcept
}
}
std::fill_n(signal_pending, MAX_SIGNAL, false);
std::fill(signal_pending.begin(), signal_pending.end(), false);
#endif
monitor.Destruct();

@@ -23,7 +23,6 @@
#include "filter/Filter.hxx"
#include "filter/Prepared.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/ConstBuffer.hxx"
#include <cassert>
#include <memory>

@@ -23,7 +23,7 @@
#include "filter/Prepared.hxx"
#include "pcm/Buffer.hxx"
#include "pcm/AudioFormat.hxx"
#include "AudioCompress/compress.h"
#include "pcm/AudioCompress/compress.h"
#include "util/ConstBuffer.hxx"
#include <string.h>

@@ -12,7 +12,6 @@ endif
filter_plugins = static_library(
'filter_plugins',
'../../AudioCompress/compress.c',
'NullFilterPlugin.cxx',
'TwoFilters.cxx',
'AutoConvertFilterPlugin.cxx',

@@ -31,7 +31,7 @@ AllocatedPath::FromUTF8(std::string_view path_utf8) noexcept
return FromFS(path_utf8);
#else
try {
return AllocatedPath(::PathFromUTF8(path_utf8));
return {::PathFromUTF8(path_utf8)};
} catch (...) {
return nullptr;
}
@@ -44,7 +44,7 @@ AllocatedPath::FromUTF8Throw(std::string_view path_utf8)
#ifdef FS_CHARSET_ALWAYS_UTF8
return FromFS(path_utf8);
#else
return AllocatedPath(::PathFromUTF8(path_utf8));
return {::PathFromUTF8(path_utf8)};
#endif
}

@@ -26,7 +26,7 @@ Path::ToUTF8() const noexcept
try {
return ToUTF8Throw();
} catch (...) {
return std::string();
return {};
}
}

@@ -41,7 +41,7 @@
#ifdef USE_XDG
#include "util/StringStrip.hxx"
#include "util/StringCompare.hxx"
#include "io/TextFile.hxx"
#include "fs/io/TextFile.hxx"
#include <string.h>
#include <utility>
#endif

@@ -18,9 +18,9 @@
*/
#include "TextFile.hxx"
#include "FileReader.hxx"
#include "AutoGunzipReader.hxx"
#include "BufferedReader.hxx"
#include "io/FileReader.hxx"
#include "io/BufferedReader.hxx"
#include "lib/zlib/AutoGunzipReader.hxx"
#include "fs/Path.hxx"
#include <cassert>

@@ -20,6 +20,7 @@
#ifndef MPD_TEXT_FILE_HXX
#define MPD_TEXT_FILE_HXX
#include "io/LineReader.hxx"
#include "config.h"
#include <memory>
@@ -29,7 +30,7 @@ class FileReader;
class AutoGunzipReader;
class BufferedReader;
class TextFile {
class TextFile final : public LineReader {
const std::unique_ptr<FileReader> file_reader;
#ifdef ENABLE_ZLIB
@@ -45,14 +46,8 @@ public:
~TextFile() noexcept;
/**
* Reads a line from the input file, and strips trailing
* space. There is a reasonable maximum line length, only to
* prevent denial of service.
*
* @return a pointer to the line, or nullptr on end-of-file
*/
char *ReadLine();
/* virtual methods from class LineReader */
char *ReadLine() override;
};
#endif

@@ -14,12 +14,7 @@ fs_sources = [
'CheckFile.cxx',
'LookupFile.cxx',
'DirectoryReader.cxx',
'io/PeekReader.cxx',
'io/FileReader.cxx',
'io/BufferedReader.cxx',
'io/TextFile.cxx',
'io/FileOutputStream.cxx',
'io/BufferedOutputStream.cxx',
]
if is_windows
@@ -28,14 +23,6 @@ else
shlwapi_dep = dependency('', required: false)
endif
if zlib_dep.found()
fs_sources += [
'io/GunzipReader.cxx',
'io/AutoGunzipReader.cxx',
'io/GzipOutputStream.cxx',
]
endif
fs = static_library(
'fs',
fs_sources,

@@ -244,7 +244,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size) noexcept
void
AsyncInputStream::DeferredResume() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
try {
Resume();
@@ -257,7 +257,7 @@ AsyncInputStream::DeferredResume() noexcept
void
AsyncInputStream::DeferredSeek() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
if (seek_state != SeekState::SCHEDULED)
return;

@@ -37,7 +37,7 @@ BufferingInputStream::BufferingInputStream(InputStreamPtr _input)
BufferingInputStream::~BufferingInputStream() noexcept
{
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
stop = true;
wake_cond.notify_one();
}

@@ -18,7 +18,7 @@
*/
#include "IcyInputStream.hxx"
#include "IcyMetaDataParser.hxx"
#include "tag/IcyMetaDataParser.hxx"
#include "tag/Tag.hxx"
#include "util/UriExtract.hxx"
#include "util/UriQueryParser.hxx"

@@ -97,7 +97,7 @@ InputStream::ReadTag() noexcept
std::unique_ptr<Tag>
InputStream::LockReadTag() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return ReadTag();
}
@@ -152,7 +152,7 @@ InputStream::LockReadFull(void *ptr, size_t _size)
bool
InputStream::LockIsEOF() const noexcept
{
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
return IsEOF();
}

@@ -27,6 +27,7 @@
#include <cassert>
#include <memory>
#include <string>
#include <utility>
struct Tag;
class InputStreamHandler;

@@ -20,7 +20,7 @@
#ifndef MPD_INPUT_READER_HXX
#define MPD_INPUT_READER_HXX
#include "fs/io/Reader.hxx"
#include "io/Reader.hxx"
class InputStream;

@@ -45,7 +45,7 @@ ThreadInputStream::Stop() noexcept
return;
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
close = true;
wake_cond.notify_one();
}

@@ -37,14 +37,14 @@ InputCacheItem::~InputCacheItem() noexcept
void
InputCacheItem::AddLease(InputCacheLease &lease) noexcept
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
leases.push_back(lease);
}
void
InputCacheItem::RemoveLease(InputCacheLease &lease) noexcept
{
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
auto i = leases.iterator_to(lease);
if (i == next_lease)
++next_lease;

@@ -63,7 +63,7 @@ public:
using BufferingInputStream::size;
bool IsInUse() const noexcept {
const std::lock_guard<Mutex> lock(mutex);
const std::scoped_lock<Mutex> lock(mutex);
return !leases.empty();
}

@@ -24,7 +24,7 @@ CacheInputStream::CacheInputStream(InputCacheLease _lease,
:InputStream(_lease->GetUri(), _mutex),
InputCacheLease(std::move(_lease))
{
auto &i = GetCacheItem();
const auto &i = GetCacheItem();
size = i.size();
seekable = true;
SetReady();
@@ -36,7 +36,7 @@ CacheInputStream::Check()
const ScopeUnlock unlock(mutex);
auto &i = GetCacheItem();
const std::lock_guard<Mutex> protect(i.mutex);
const std::scoped_lock<Mutex> protect(i.mutex);
i.Check();
}
@@ -60,7 +60,7 @@ CacheInputStream::IsAvailable() const noexcept
const ScopeUnlock unlock(mutex);
auto &i = GetCacheItem();
const std::lock_guard<Mutex> protect(i.mutex);
const std::scoped_lock<Mutex> protect(i.mutex);
return i.IsAvailable(_offset);
}
@@ -76,7 +76,7 @@ CacheInputStream::Read(std::unique_lock<Mutex> &lock,
{
const ScopeUnlock unlock(mutex);
const std::lock_guard<Mutex> protect(i.mutex);
const std::scoped_lock<Mutex> protect(i.mutex);
nbytes = i.Read(lock, _offset, ptr, read_size);
}
@@ -91,6 +91,6 @@ CacheInputStream::OnInputCacheAvailable() noexcept
auto &i = GetCacheItem();
const ScopeUnlock unlock(i.mutex);
const std::lock_guard<Mutex> protect(mutex);
const std::scoped_lock<Mutex> protect(mutex);
InvokeOnAvailable();
}

Some files were not shown because too many files have changed in this diff Show More