Compare commits

...

199 Commits

Author SHA1 Message Date
Max Kellermann
b4c9d9c2a7 release v0.20.7 2017-05-15 22:51:08 +02:00
Max Kellermann
fa2b59df4b Main: cap buffer_before_play at 80% to prevent deadlock
Closes 
2017-05-15 22:49:31 +02:00
Max Kellermann
f41a169460 Main: enforce a reasonable minimum audio_buffer_size setting 2017-05-15 22:44:18 +02:00
Max Kellermann
f567083006 Main: refactor DEFAULT_BUFFER_SIZE to represent bytes 2017-05-15 22:40:23 +02:00
Max Kellermann
a2a677e539 doc/developer.xml: change git URIs to GitHub 2017-05-15 21:49:18 +02:00
Max Kellermann
9123c0b733 doc, README.md: update bug tracker URL
Closes 
2017-05-15 21:48:03 +02:00
Max Kellermann
788e3b31e1 *: remove "pure" and "const" attributes from throwing functions
The "pure" and "const" attributes are not so well-defined, and a
recent clang version implements an optimization which pushes the
definition's boundary beyond what I believed it was.  clang now
assumes that functions declared "pure" cannot throw exceptions, even
if they lack the "noexcept" specification.

When compiled with this new clang version, MPD will crash randomly if
an exception happens to get thrown by such as "pure" function
(https://github.com/MusicPlayerDaemon/MPD/issues/41).

This commit removes all such misplaced "pure" and "const" attributes,
closing .
2017-05-08 17:25:06 +02:00
Max Kellermann
71f0ed8b74 *: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to
consider these functions throwing.
2017-05-08 14:44:49 +02:00
Max Kellermann
ac2e4e593d python/libs: upgrade Boost to 1.64 2017-04-24 20:43:04 +02:00
Max Kellermann
edaa7d7748 python/build/libs: upgrade CURL to 7.54.0 2017-04-24 20:42:28 +02:00
Max Kellermann
3cdf965fba python/build/libs: upgrade FFmpeg to 3.3 2017-04-24 20:41:08 +02:00
Max Kellermann
6b60d1e71f decoder/pcm: add missing nullptr check
Fixes a potential crash bug which is actually unreachable, because the
"pcm" plugin is never invoked when there is no (matching) MIME type.
2017-04-24 20:36:55 +02:00
Max Kellermann
7b7fb5acd5 decoder/pcm: fix potential assertion failure in FillBuffer()
After a seek failure, the buffer may still be full, and then
FillBuffer() aborts with assertion failure.
2017-04-24 11:20:37 +02:00
Bart Nagel
0a7d612f41 Remove some redundant code 2017-04-18 16:10:38 +02:00
Max Kellermann
38da76bbe0 util/ScopeExit: copy enabled tag in move constructor 2017-04-12 13:11:43 +02:00
martinarielhartmann
a13e045742 Update libs.py
upgrade zlib to 1.2.11
2017-04-11 13:31:34 +02:00
cotko
811620c0a0 Fix typo 2017-04-11 13:31:15 +02:00
Max Kellermann
504f5f7bdd storage/FileInfo, db/simple/Directory: use 64 bit for device/inode
An ino_t is usually a 64 bit integer, and some file systems (such as
Linux's kernel NFS client) really uses the upper 32 bit.  This can
lead to false positives in the directory loop detection in
FindAncestorLoop().  Increasing these two attributes (in
StorageFileInfo and Directory) to 64 bit adds little overhead, but
makes the check a lot safer.
2017-04-06 09:58:25 +02:00
Max Kellermann
32bcad51b8 configure.ac: prepare for 0.20.7 2017-03-16 10:50:12 +01:00
Max Kellermann
a40510c241 release v0.20.6 2017-03-10 16:57:59 +01:00
Max Kellermann
ac8dce6599 lib/curl/Request: "ICY 200 OK" is a response boundary header 2017-03-10 16:28:02 +01:00
Max Kellermann
190d525099 lib/curl/Request: move code to IsResponseBoundaryHeader() 2017-03-10 16:24:30 +01:00
Max Kellermann
1b6666fa39 Partition: handle SYNC_WITH_PLAYER before TAG_MODIFIED
The TAG_MODIFIED handler (i.e. playlist::TagModified()) works only if
the modified song is the current song - something that is not updated
until SYNC_WITH_PLAYER is finished.  This fixes tag updates right
after a new song is started.
2017-03-10 16:11:34 +01:00
Max Kellermann
1dd01c99e8 decoder/sidplay: make compatible with libsidplayfp < 1.8
https://bugs.musicpd.org/view.php?id=4665
2017-03-10 13:48:52 +01:00
Thomas Zander
d50b30a498 Add missing include for cstdlib, otherwise free() is undefined 2017-03-07 20:02:36 +01:00
Max Kellermann
42a3a87f13 util/HugeAllocator: paranoid check for sysconf()<0
Just in case.
2017-03-01 21:50:26 +01:00
Ben Boeckel
9dfedbe619 ReusableArray: fix build error on GCC7
GCC7 outputs the following error without this change:

    src/util/ReusableArray.hxx:61:35: error: no matching function for call to ‘swap(size_t&, const size_t&)’
       std::swap(capacity, src.capacity);

which can be resolved by just using an rvalue-reference rather than a
const rvalue-reference.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2017-03-01 19:38:41 +01:00
Max Kellermann
88957b4c9d android/build.py: build with libc++ instead of GNU libstdc++
Android is migrating away from GCC, and libstdc++ will disappear
eventually.
2017-03-01 17:31:26 +01:00
Max Kellermann
b2f2c9322b db/simple/Mount: workaround for libc++ 2017-03-01 17:31:26 +01:00
Max Kellermann
3be2051808 decoder/Thread: check ENABLE_FFMPEG, not HAVE_FFMPEG
This repairs the damage to commit 74dbaade6f done by commit
b3f5b4932c
2017-03-01 17:06:23 +01:00
Max Kellermann
ff32b0dc9b input/curl: use %lu instead of %llu
Fixes a GCC warning because %llu appears to be unsupported by the
Windows standard library.
2017-03-01 16:44:11 +01:00
Max Kellermann
c1869a11af input/curl: format Range offset as unsigned 2017-03-01 16:44:08 +01:00
Max Kellermann
e22a4fdba4 command/Error: improve libstdc++ 4.9.x detection for std::rethrow_if_nested() workaround 2017-03-01 16:38:22 +01:00
Max Kellermann
29a7b2c5b5 decoder/mpcdec: ignore empty frames
https://bugs.musicpd.org/view.php?id=4656 describes a crash due to
division by zero because frame.samples==0.  This should never happen,
but apparently can happen after seeking.  The best we can do is to
just ignore this frame.
2017-03-01 16:13:21 +01:00
Max Kellermann
3b6c285c2a configure.ac: prepare for 0.20.6 2017-03-01 16:13:21 +01:00
Max Kellermann
575d1786af release v0.20.5 2017-02-20 21:51:31 +01:00
Max Kellermann
bc1c927952 util/TimeFormat: suppress -Wunused on Windows 2017-02-20 21:44:01 +01:00
Max Kellermann
f95bc85f91 python/build/libs: upgrade FFmpeg to 3.2.4 2017-02-20 21:13:43 +01:00
Max Kellermann
4015195314 doc/user: instructions to compile the Windows binary 2017-02-20 21:06:43 +01:00
Max Kellermann
c3d883c6cb win32/build.py: default to x64 build 2017-02-20 21:06:43 +01:00
Max Kellermann
097e30321b win32/build.py: add option --32 2017-02-20 21:06:31 +01:00
Max Kellermann
b6ddeaacf2 win32/build.py: convert argument parser to loop
Allow multiple arguments.
2017-02-20 21:06:21 +01:00
Max Kellermann
b0c60ec124 win32/build.py: add variable "x64", assign host_arch later 2017-02-20 21:04:34 +01:00
Max Kellermann
f3b788703e tag/Handler: improve snprintf() return value check 2017-02-19 19:34:13 +01:00
Max Kellermann
4bb83781e8 output/httpd/IcyMetaDataServer: cast length to unsigned
Fixes another buffer overflow: if the stream has a very long title or
URL, resulting in a metadata string of more than 2 kB, icy_string[0]
is a negative value, which gets casted to size_t - ouch!

 https://bugs.musicpd.org/view.php?id=4652
2017-02-19 19:28:52 +01:00
Max Kellermann
a73195b7cc output/httpd/IcyMetaDataServer: pad the string with 15 spaces
Fixes a buffer overflow due to the bad formula rounding the buffer
size up.  At the same time, remove the "+1" from the meta_length
calculation, which takes the padding into account and at the same time
implements proper rounding.
2017-02-19 19:27:37 +01:00
Max Kellermann
1bd00b8a9a output/httpd/IcyMetaDataServer: remove the int cast
Why did this cast exist??
2017-02-19 19:27:37 +01:00
Max Kellermann
d84eaeafc5 doc/include/tags.xml: clarify that track/disc are decimal 2017-02-18 19:01:04 +01:00
Max Kellermann
20ae84bff9 {input,mixer}/alsa: cancel the DeferredMonitor in the destructor
Yet another potential crash bug fix.
2017-02-10 15:05:49 +01:00
Max Kellermann
7372c931b3 event/Loop: make IsInsideOrNull() available in the NDEBUG build
Fixes build breakage by commit 4e5271fcdf7; and this method does make
sense in non-debug builds.
2017-02-09 21:21:49 +01:00
Max Kellermann
29e1b6e465 mixer/alsa: reset the MultiSocketMonitor in the destructor
Fixes potential crash bug.
2017-02-09 21:13:19 +01:00
Max Kellermann
eda06993f8 event/MultiSocketMonitor: add method Reset() 2017-02-09 21:12:23 +01:00
Max Kellermann
4b30ef1cf2 event/MultiSocketMonitor: use C++11 initializer 2017-02-09 21:12:23 +01:00
Max Kellermann
e92e5e8eb8 event/MultiSocketMonitor: more API documentation
Now ClearSocketList() may only be called from PrepareSockets().
Calling it before destroying the object doesn't work properly, because
it doesn't unregister the TimeoutMonitor and the IdleMonitor.  Some of
its callers need to be fixed.
2017-02-09 21:12:23 +01:00
Max Kellermann
4e5271fcdf event/Call: allow usage during shutdown
Change EventLoop::IsInside() call to EventLoop::IsInsideOrNull().
This means that BlockingCall() may be used during shutdown, after the
main EventLoop::Run() has finished.  This is important because mixers
are currently registered in the main EventLoop.
2017-02-09 21:12:23 +01:00
Max Kellermann
3c55487a16 configure.ac: don't require libsidutils when building with libsidplayfp
The libsidplayfp fork has merged libsidutils into the main library.
The libsidutils we used to link with was part of the original
libsidplay project.
2017-02-09 13:09:03 +01:00
Max Kellermann
76a1cae5d8 {input,mixer}/alsa: fix off-by-one bug in count check
Doesn't make a practical difference - but it's more correct this way.
2017-02-09 12:46:49 +01:00
Max Kellermann
81a97315e3 NEWS: mention ID3 memory leak fix 2017-02-08 08:44:47 +01:00
Max Kellermann
53c14d97a6 lib/nfs/FileReader: remove debug line 2017-02-08 08:43:56 +01:00
Max Kellermann
69a82eec17 tag/TagId3: use AtScopeExit() for exception-safety 2017-02-06 23:32:07 +01:00
Max Kellermann
45cadef22f configure.ac: prepare for 0.20.5 2017-02-06 23:28:36 +01:00
Max Kellermann
0a033fb10a release v0.20.4 2017-02-01 21:59:36 +01:00
Max Kellermann
591afa0647 lib/nfs/Connection: detect socket hangup and unregister from epoll
Fixes race condition when epoll_ctl() gets called after the socket has
been closed, which may affect a different socket created by another
thread meanwhile.
2017-02-01 21:44:20 +01:00
Max Kellermann
05eac20ffe lib/nfs/Connection: detect libnfs reconnect
When rpc_reconnect_requeue() gets called from inside nfs_service(),
the NfsInputStream can stall completely because the old socket has
been unregistered from epoll automatically, but the new one has never
been registered.  Therefore, nfs_service() will never be called again.

This kludge attempts to detect this condition by checking
nfs_which_events()==POLLOUT.

https://bugs.musicpd.org/view.php?id=4081
2017-02-01 21:36:58 +01:00
Max Kellermann
38d263ac19 output/sndio: work around a libroar C++ incompatibility
Same as in commit e02d8ad8d2, but this time for the sndio plugin
which can be emulated by libroar.
2017-02-01 19:53:23 +01:00
Thomas Zander
f71c204eef Correct method types to match Interface.hxx 2017-01-31 21:22:02 +01:00
Thomas Zander
51147203be free() require cstdlib to be included 2017-01-31 21:21:37 +01:00
Max Kellermann
a931686317 pcm/SampleFormat: workaround for GCC 4.9 "constexpr" bug
GCC 4.9 has incomplete C++14 support.  Specifically, it doesn't allow
switch/case in "constexpr" functions.
2017-01-27 11:02:58 +01:00
Max Kellermann
5bd322bdcf python/libs: upgrade Opus to 1.1.4 2017-01-27 08:47:58 +01:00
Max Kellermann
bb097109f0 configure.ac: prepare for 0.20.4 2017-01-27 08:47:36 +01:00
Max Kellermann
2ab6c40ff1 release v0.20.3 2017-01-25 08:53:16 +01:00
Max Kellermann
68bb738af2 input/alsa: use snd_pcm_?w_params_alloca() 2017-01-25 08:47:20 +01:00
Max Kellermann
6b968beede output/alsa: convert to class, make attributes private 2017-01-24 23:08:16 +01:00
Max Kellermann
f68dd1bffb output/alsa: make AlsaSetup() an AlsaOutput method 2017-01-24 23:06:33 +01:00
Max Kellermann
f92b71ca99 output/alsa: move code from AlsaSetup() to AlsaSetupSw() 2017-01-24 23:05:29 +01:00
Max Kellermann
2b79fe2d6a output/alsa: move code from AlsaSetup() to AlsaSetupHw() 2017-01-24 22:48:48 +01:00
Max Kellermann
44dd9af276 lib/upnp/Util: pass single delimiter character to stringToTokens() 2017-01-23 19:34:55 +01:00
Max Kellermann
d3013d4f8c lib/upnp/Util: remove parameter "skipinit", always true 2017-01-23 19:28:07 +01:00
Max Kellermann
678524ad21 lib/upnp/WorkQueue: fix race condition
With "ok==false", newly created threads may quit instantly.
2017-01-23 19:25:30 +01:00
Max Kellermann
32a64481f2 lib/upnp: fix bad std::chrono cast
libupnp provides seconds, not whatever time unit is used by
std::chrono::steady_clock.
2017-01-23 19:16:14 +01:00
Max Kellermann
1776015c6c db/simple: drop redundant "virtual" 2017-01-23 18:57:23 +01:00
Max Kellermann
f1c71a26e3 db/proxy: drop redundant "virtual" 2017-01-23 18:56:45 +01:00
Max Kellermann
e78ab767d3 db/proxy: make connect errors during startup non-fatal 2017-01-23 18:55:40 +01:00
Max Kellermann
f01eb2f95d db/proxy: improve Connect() error message 2017-01-23 18:55:18 +01:00
Max Kellermann
1450e45d97 Main, db/Glue: improve error messages 2017-01-23 18:52:16 +01:00
Max Kellermann
ec8cba369c lib/upnp/WorkQueue: disallow copying 2017-01-23 18:35:58 +01:00
Max Kellermann
f4c248f406 lib/upnp/WorkQueue: make constructor explicit 2017-01-23 18:35:47 +01:00
Max Kellermann
f3b2a58646 lib/upnp/WorkQueue: use C++11 initializers 2017-01-23 18:35:22 +01:00
Max Kellermann
c6f89c42b2 db/proxy: make the base class of LibmpdclientError public
If the base class is not accessible, the "catching" the base class
won't work.  This caused the fatal error:

 terminate called after throwing an instance of 'LibmpdclientError'
2017-01-23 18:28:40 +01:00
Max Kellermann
5e93cfdd9e output/Source: reset the ReplayGain serials ion OpenFilter()
Each close/open cycle resets the Filter's state, because a new Filter
instance is being created.  That results in the serials
(replay_gain_serial and other_replay_gain_serial) being out of sync
with the internal ReplayGainFilter state.

So instead of initializing those serials once, we need to initialize
them each time we create new ReplayGainFilter instances, i.e. in
OpenFilter().

 https://bugs.musicpd.org/view.php?id=4632
2017-01-23 17:55:04 +01:00
Max Kellermann
d91d5a3ab5 playlist/SoundCloud: eliminate unnecessary casted variable 2017-01-20 17:16:11 +01:00
Max Kellermann
907c045f33 doc/user: add missing playlist plugins 2017-01-20 17:09:19 +01:00
Max Kellermann
90f189eb54 doc/user: mention which commands are available with playlist plugins 2017-01-20 16:59:07 +01:00
Florian Schlichting
4abd5b2112 doc/user: document effect of http_proxy envvar on curl plugin 2017-01-20 16:52:02 +01:00
Max Kellermann
df9a665994 pcm/Traits: add "SILENCE" attribute 2017-01-20 15:57:09 +01:00
Max Kellermann
7a098ca0ed pcm/Traits: add specialization for SampleFormat::DSD 2017-01-20 15:48:30 +01:00
Max Kellermann
33716732a1 pcm/PcmChannels: silence surround channels when converting from stereo
Previously, there was no special code to convert stereo to
multi-channel.  The generic solution for this was to convert to mono,
and then copy the result to all channels.  That's a pretty bad
solution, but at least something which always renders audio.  MPD does
something, instead of failing.

Now that MPD has proper support for multi-channel (by defining the
channel order), we can do better than that.  It is a (somewhat) common
case to play back stereo music on a DAC which can only do
multi-channel.  The best approach here is to copy the stereo channels
to front-left and front-right, and apply the "silence" pattern to all
other channels.
2017-01-19 10:53:41 +01:00
Max Kellermann
97ae594375 DetachedSong: use C++11 initializers 2017-01-18 13:13:36 +01:00
Max Kellermann
3f321ae9a0 pcm/SampleFormat: make the two inline functions "constexpr" 2017-01-17 22:52:09 +01:00
Max Kellermann
161d32a7e7 AudioFormat: update ToString() API documentatio 2017-01-17 22:48:34 +01:00
Max Kellermann
d7137586a9 Audio{Format,Parser}: use shortcuts such as "dsd64" in log messages 2017-01-17 22:42:23 +01:00
Max Kellermann
cd0c06ba6e doc/protocol: refer to user manual for status/audio 2017-01-17 22:42:23 +01:00
Max Kellermann
899ab63d91 doc/user: document the "dsd" sample format 2017-01-17 22:36:44 +01:00
Max Kellermann
1097820a5a doc/user: add <replaceable> element 2017-01-17 22:36:44 +01:00
Max Kellermann
39114f91a7 AudioFormat: replace struct audio_format_string with class StringBuffer, return it 2017-01-17 22:18:21 +01:00
Max Kellermann
4f01387edf util/StringBuffer: new utility class 2017-01-17 22:03:42 +01:00
Max Kellermann
de3e0585f1 AudioFormat: move enum SampleFormat to pcm/SampleFormat.hxx 2017-01-17 22:01:01 +01:00
Max Kellermann
f85f25ba82 test: add AudioFormat unit test 2017-01-17 12:02:41 +01:00
Max Kellermann
10a2c179f9 Makefile.am: move AudioFormat.cxx to libpcm.a 2017-01-17 12:01:49 +01:00
Max Kellermann
6eea56861b AUTHORS, ...: update my email address 2017-01-17 11:54:55 +01:00
Jörg Krause
21fd2064ae Makefile.am: fix linking xiph with ogg
The internal static xiph library needs to link with libogg. Otherwise
building mpd will fail:

```
/mips-linux-gnu/bin/ld: libxiph.a(libxiph_a-OggVisitor.o): undefined
reference to symbol 'ogg_stream_packetout'
```

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
2017-01-17 11:24:20 +01:00
Max Kellermann
dcbab8e37a PlaylistFile: "playlistadd" creates new playlist if it does not exist, as documented 2017-01-16 20:55:19 +01:00
Max Kellermann
5677278251 CommandLine: update copyright year 2017-01-16 12:04:04 +01:00
Max Kellermann
a83bee993d configure.ac: prepare for 0.20.3 2017-01-16 12:03:22 +01:00
Max Kellermann
96a31f554a release v0.20.2 2017-01-15 01:28:00 +01:00
Max Kellermann
d14ec6aea5 output/Thread: reconfigure ConvertFilter for its new input AudioFormat
If the input AudioFormat changes but the out_audio_format doesn't
change (e.g. because there is a fixed "format" setting in this
"audio_output" section), the ConvertFilter needs to be reconfigured.
This didn't happen, resulting in awful static noise after changing
songs.
2017-01-15 01:24:17 +01:00
Max Kellermann
917cedf893 output/Thread: move AudioFormat logging code around 2017-01-15 01:23:49 +01:00
Max Kellermann
193dd71600 output/Thread: remember the original filter audio format in local variable 2017-01-15 01:21:14 +01:00
Max Kellermann
6c293a3d7f lib/nfs: add more API documentation 2017-01-15 00:58:49 +01:00
Max Kellermann
e847ddf011 DetachedSong: compare start_time and end_time in IsSame()
This method is used by DecoderControl::IsCurrentSong(), which is used
by the player thread to check whether the current decoder instance can
be reused to seek.  When switching to another song in the same CUE
sheet, previously DetachedSong::IsSame() returned true, and thus the
old decoder instance was used for the new song, not considering the
new end_time.  This led to the old decoder quickly quitting.
2017-01-15 00:54:25 +01:00
Max Kellermann
7e8b448985 input/alsa: set period_size=buffer_size/4
This way, we have four periods instead of the default of two.  With
only two periods, we don't get woken up often enough, and we
frequently encounter buffer overruns.  With four periods, we have more
time to breathe, and the buffer overruns magically disappear.
2017-01-14 21:50:28 +01:00
Max Kellermann
d1f3a87c08 input/alsa: remove the start_threshold setting
This setting is mostly useless for capture devices.  There's no point
in configuring it.
2017-01-14 21:47:37 +01:00
Max Kellermann
9f8145e590 input/alsa: dump buffer/period sizes 2017-01-14 21:09:57 +01:00
Steven O'Brien
791efc171a input/alsa: enable non-blocking mode 2017-01-14 20:59:57 +01:00
Steven O'Brien
144312a525 input/alsa: handle EAGAIN 2017-01-14 20:59:23 +01:00
Max Kellermann
92684112ed input/alsa: call snd_pcm_start() after snd_pcm_prepare()
This is necessary because we'll never get woken up again by
epoll_wait() after a buffer overrun recovery, unless we start the PCM
explicitly before returning to the I/O loop.
2017-01-14 20:58:30 +01:00
Max Kellermann
ef114ee6cb input/alsa: improve logging in Recover()
Copy yet more code from the ALSA output plugin.
2017-01-14 20:52:41 +01:00
Max Kellermann
667f209742 input/alsa: check snd_pcm_state() in Recover()
Copy some good code from the ALSA output plugin.
2017-01-14 20:51:51 +01:00
Max Kellermann
4ad0747c78 output/alsa: explicitly mention all snd_pcm_state() enums
I want a compiler warning when a new state needs to be considered
here.
2017-01-14 20:49:15 +01:00
Max Kellermann
c5cf66402c input/alsa: make two attributes "const" 2017-01-13 20:26:36 +01:00
Max Kellermann
05417049eb input/alsa: clear sockets from within IOThread
Fixes assertion failure in implicit destructor.
2017-01-13 20:17:16 +01:00
Max Kellermann
c7b0c46d9f output/recorder: fix typo in variable name
Fixes the dreaded error "Failed to create : No such file or
directory".

 https://bugs.musicpd.org/view.php?id=4625
2017-01-12 21:36:32 +01:00
Max Kellermann
df578c91ad output/alsa: log DoP mode 2017-01-11 22:50:40 +01:00
Max Kellermann
70008c47c9 output/alsa: support DSD_U16 2017-01-11 22:47:21 +01:00
Max Kellermann
938affef32 pcm/export: support DSD_U16 2017-01-11 22:47:12 +01:00
Max Kellermann
a3c33000ee pcm/Dsd32: include cleanup 2017-01-11 22:47:12 +01:00
Max Kellermann
1e54b7b294 test/test_pcm: fix the DSD_U32 byte order
The unit test was wrong as well.  D'oh!
2017-01-11 22:39:23 +01:00
Max Kellermann
cc0dbcf3f4 pcm/Dsd32: fix the byte order
The byte order of DSD_U32 was wrong from the start.  The oldest bits
must be in the MSB, not in the LSB, according to
snd_pcm_format_descriptions in alsa-lib.
2017-01-11 22:25:54 +01:00
Max Kellermann
c5a2cadccc pcm/Export: convert to class, make members private 2017-01-11 21:48:43 +01:00
Max Kellermann
9aa43416b6 pcm/dop: remove unnecessary assertions 2017-01-11 21:48:43 +01:00
Max Kellermann
8364029db8 output/alsa: move code to PlayRaw() 2017-01-11 21:38:05 +01:00
Max Kellermann
d842d21be0 util/ReusableArray: add method GetCapacity() 2017-01-11 20:37:12 +01:00
Max Kellermann
3514fd2433 util/ReusableArray: add move constructor/operator 2017-01-11 20:37:12 +01:00
Max Kellermann
6778ff27ea util/ReusableArray: use C++11 initializers 2017-01-11 20:33:01 +01:00
Max Kellermann
f32315d699 pcm/Export: remove obsolete gcc warning suppression 2017-01-11 20:31:48 +01:00
Max Kellermann
8b754b24b6 pcm/Buffer: update API documentation 2017-01-11 20:24:32 +01:00
Max Kellermann
b1bee9ff38 test/test_pcm: enable the DSD unit tests
These were disabled by accident.
2017-01-11 20:06:10 +01:00
Max Kellermann
569be2d402 test/test_pcm_export: fix TestDop() sample rate results 2017-01-11 20:06:10 +01:00
Max Kellermann
78a73eac53 pcm/Export: add (dummy) method Cancel()
We'll have some code for it soon.
2017-01-11 15:41:28 +01:00
Max Kellermann
533cb99c33 output/Source: reset all filters in Cancel() 2017-01-11 15:39:18 +01:00
Max Kellermann
79726940dc output/Source: un-inline Cancel() 2017-01-11 15:39:00 +01:00
Max Kellermann
27c7891169 filter/Internal: add method Reset() 2017-01-11 15:34:25 +01:00
Max Kellermann
7a3a793a12 decoder/Bridge: call PcmConvert::Reset() after seeking 2017-01-11 15:32:57 +01:00
Max Kellermann
8088469eca pcm/Convert: add method Reset() 2017-01-11 15:30:30 +01:00
Max Kellermann
3dcb082015 pcm/Resampler: add method Reset()
Hook for src_reset(), not yet used.
2017-01-11 15:26:48 +01:00
Max Kellermann
bece023028 pcm/PcmDsd: move Dsd8To32() to Dsd32.cxx 2017-01-11 15:22:43 +01:00
Max Kellermann
9c4df66925 pcm/Export: halve the sample rate for DoP
Move this sample rate fixup from the ALSA output plugin to PcmExport,
where it belongs.
2017-01-11 10:33:23 +01:00
Max Kellermann
2b43ceb6c6 pcm/Export: DSD_U32 quarters the sample rate
DSD_U32 packs four bytes instead of one large "sample", thus the
sample rate is one quarter of the input sample rate.  This fixes a
rather critical DSD_U32 playback problem.
2017-01-11 10:14:41 +01:00
Max Kellermann
c143adba91 pcm/Export: add CalcOutputSampleRate(), CalcInputSampleRate()
Prepare for DSD sample rate fixups.
2017-01-10 23:48:26 +01:00
Max Kellermann
142fdc8d86 decoder/flac: add options "probesize" and "analyzeduration"
https://bugs.musicpd.org/view.php?id=3876
2017-01-10 23:05:04 +01:00
Max Kellermann
67778dcd3d configure.ac: prepare for 0.20.2 2017-01-10 23:01:42 +01:00
Max Kellermann
ed80863eac release v0.20.1 2017-01-09 18:10:18 +01:00
Max Kellermann
c3fc84de12 input/curl: wake up client thread after seek to end of file
Call SeekDone() to avoid the freeze bug.
2017-01-09 18:08:33 +01:00
Max Kellermann
904f83cd85 doc/developer: add GitHub reference 2017-01-09 17:19:15 +01:00
Max Kellermann
28bf100a50 doc/developer: more code style 2017-01-09 17:13:28 +01:00
Max Kellermann
accbd4e82a doc/developer: change C++11 to C++14 2017-01-09 17:13:28 +01:00
Max Kellermann
d7f478c154 doc/developer: add XML ids 2017-01-09 17:13:28 +01:00
Wieland Hoffmann
8f7f13fea4 doc/user: Replace "It used used" with "It is used" 2017-01-08 18:23:13 +01:00
Max Kellermann
c82b03a74c decoder/wavpack: fix crash bug 2017-01-08 14:54:12 +01:00
Max Kellermann
58fb36bdb9 storage/http: new storage plugin 2017-01-08 14:40:20 +01:00
Max Kellermann
4297a7b0a4 lib/curl/Request: move exception handling out of the WRITEFUNCTION
libcurl's WRITEFUNCTION is pretty fragile; if we destroy the CURL*
instance or even unregister it using curl_multi_remove_handle(),
libcurl will crash instantly.  But still we need to be able to handle
exceptions from inside the WRITEFUNCTION, and call
CurlResponseHandler::OnError(), which may destroy the whole thing.  As
a workaround, I use DeferredMonitor to postpone the OnError() call
into a stack frame which is allowed to destroy the request.
2017-01-08 14:36:27 +01:00
Max Kellermann
1bab6d0dd7 lib/curl/Request: move catch clause out of FinishHeaders
Let the caller decide what to do with the exception.
2017-01-08 14:36:27 +01:00
Max Kellermann
13b85edbe2 lib/curl/Request: postpone the curl_easy_cleanup() call
When the request is done, only unregister the CURL* handle, but do not
delete it yet - it may still be needed for CURLINFO_RESPONSE_CODE.
2017-01-08 13:51:53 +01:00
Max Kellermann
dc53098e43 lib/curl/Request: allow Stop() to be called twice
Convert assertion to runtime check.  This is useful because this is a
public method, and the caller has no chance to check if the object is
still registered.
2017-01-08 13:51:53 +01:00
Max Kellermann
3c66feff5a lib/curl/Global: defer the ReadInfo() call
Fixes a crash that can occur due to recursion from InvalidateSockets()
to ReadInfo() to CurlRequest callbacks.
2017-01-08 12:46:35 +01:00
Max Kellermann
218c3bc0d5 lib/curl/Multi: fix typo 2017-01-08 12:46:35 +01:00
Max Kellermann
9f5eddcd13 lib/curl/Global: move code to UpdateTimeout() 2017-01-08 12:44:07 +01:00
Max Kellermann
3cba76552b lib/curl/Global: drop redundant ">=0" check 2017-01-08 12:44:04 +01:00
Max Kellermann
e98a8b624b lib/curl/Global: drop redundant "virtual" 2017-01-08 12:41:26 +01:00
Max Kellermann
6c6947b01f util/UriUtil: add uri_get_path() 2017-01-08 11:05:58 +01:00
Max Kellermann
78c91e9e5b test/run_storage: don't print unknown time stamps 2017-01-08 10:41:08 +01:00
Max Kellermann
44493ca0c4 util/TimeParser: add "pure" attribute 2017-01-08 10:41:08 +01:00
Max Kellermann
42acf78b09 util/TimeParser: wrapper for strptime()
Move code from SongFilter.cxx.
2017-01-07 22:11:45 +01:00
TermeHansen
3aa9f8af18 Rewrite of AlsaMixerPlugin to use volume_mapping
Changed AlsaMixerPlugin to use the get and set normalized functions from volume_mapping of alsa-utils/alsamixer
Changed volume_mapping set volume to be for all channels and not per channel
added volume_mapping files to Makefile.am
2017-01-07 16:30:19 +01:00
TermeHansen
8a32ee30a5 Adding volume_mapping from alsa-utils/alsamixer
source:
http://git.alsa-project.org/?p=alsa-utils.git;a=blob_plain;f=alsamixer/volume_mapping.c;hb=HEAD
http://git.alsa-project.org/?p=alsa-utils.git;a=blob_plain;f=alsamixer/volume_mapping.h;hb=HEAD
2017-01-07 16:26:36 +01:00
Max Kellermann
981dc0626b lib/expat/ExpatParser: add constructor overload for XML_ParserCreateNS() 2017-01-07 16:17:53 +01:00
Max Kellermann
8986d14e98 lib/expat/ExpatParser: make constructors "explicit" 2017-01-07 16:15:11 +01:00
Max Kellermann
5163b1a624 lib/curl/Request: require the caller to explicitly register the request
This allows constructing an instance in any thread, and register it
inside the IOThread later.
2017-01-07 16:01:58 +01:00
Max Kellermann
860aa9d6d0 lib/expat/ExpatParser: move InputStream overload to separate source file
Eliminate one unnecessary dependency for debug programs which don't
need the InputStream API.
2017-01-07 15:46:36 +01:00
Max Kellermann
64dc5212f9 Makefile.am: add variable CURL_SOURCES 2017-01-07 14:19:24 +01:00
Max Kellermann
6cff3214f3 lib/curl/Slist: new wrapper for curl_slist 2017-01-06 19:37:31 +01:00
Max Kellermann
fd910bd5e9 db/upnp: use "override" instead of "virtual" 2017-01-06 19:35:58 +01:00
Max Kellermann
c6086bed41 filter/Internal: remove the default constructor
Not used.  Force implementations to initialize out_audio_format.
2017-01-06 12:45:52 +01:00
Max Kellermann
1a9dfdfab8 filter/AutoConvert: initialize Filter::out_audio_format 2017-01-06 12:44:55 +01:00
Max Kellermann
5284cd11a9 filter/AutoConvert: remove obsolete NULL check 2017-01-06 12:35:06 +01:00
Max Kellermann
d1a47cffad filter/convert: remove obsolete method prototype 2017-01-06 12:34:39 +01:00
Max Kellermann
f469595eee filter/Internal: remove obsolete doxygen line 2017-01-06 12:34:39 +01:00
Max Kellermann
9cfc52f114 filter/Internal: add assertion to constructor 2017-01-06 11:17:55 +01:00
Max Kellermann
30bfb756c2 configure.ac: prepare for 0.20.1 2017-01-05 19:36:32 +01:00
440 changed files with 4477 additions and 1763 deletions
AUTHORSMakefile.amNEWSREADME.md
android
configure.ac
doc
m4
python/build
src
AudioFormat.cxxAudioFormat.hxxAudioParser.cxxAudioParser.hxxCommandLine.cxxDetachedSong.cxxDetachedSong.hxxIOThread.cxxIOThread.hxxIdleFlags.cxxIdleFlags.hxxInstance.hxxMain.cxxMapper.cxxMapper.hxxMusicBuffer.cxxMusicBuffer.hxxMusicChunk.cxxMusicChunk.hxxMusicPipe.cxxMusicPipe.hxxPartition.cxxPartition.hxxPermission.cxxPlaylistFile.cxxReplayGainInfo.cxxReplayGainInfo.hxxReplayGainMode.cxxReplayGainMode.hxxSongFilter.cxxSongFilter.hxxStateFile.cxxStateFile.hxxTagStream.cxx
archive
client
command
config
db
decoder
event
filter
fs
input
java
lib
ls.cxxls.hxx
mixer
neighbor
net
output
pcm
player
playlist
protocol
queue
sticker
storage
system
tag
thread
unix
util
test
win32

@@ -5,7 +5,7 @@ The following people have contributed code to MPD:
Warren Dukes <warren.dukes@gmail.com>
Avuton Olrich <avuton@gmail.com>
Max Kellermann <max@duempel.org>
Max Kellermann <max.kellermann@gmail.com>
Laszlo Ashin <kodest@gmail.com>
Viliam Mateicka <viliam.mateicka@gmail.com>
Eric Wollesen <encoded@xmtp.net>

@@ -233,6 +233,15 @@ libmpd_a_SOURCES += \
src/db/Selection.cxx src/db/Selection.hxx
endif
CURL_SOURCES = \
src/lib/curl/Version.cxx src/lib/curl/Version.hxx \
src/lib/curl/Global.cxx src/lib/curl/Global.hxx \
src/lib/curl/Request.cxx src/lib/curl/Request.hxx \
src/lib/curl/Handler.hxx \
src/lib/curl/Easy.hxx \
src/lib/curl/Multi.hxx \
src/lib/curl/Slist.hxx
UPNP_SOURCES = \
src/lib/upnp/Init.cxx src/lib/upnp/Init.hxx \
src/lib/upnp/ClientInit.cxx src/lib/upnp/ClientInit.hxx \
@@ -406,6 +415,7 @@ libutil_a_SOURCES = \
src/util/CharUtil.hxx \
src/util/NumberParser.hxx \
src/util/MimeType.cxx src/util/MimeType.hxx \
src/util/StringBuffer.hxx \
src/util/StringPointer.hxx \
src/util/StringView.cxx src/util/StringView.hxx \
src/util/AllocatedString.cxx src/util/AllocatedString.hxx \
@@ -420,6 +430,7 @@ libutil_a_SOURCES = \
src/util/FormatString.cxx src/util/FormatString.hxx \
src/util/Tokenizer.cxx src/util/Tokenizer.hxx \
src/util/TextFile.hxx \
src/util/TimeParser.cxx src/util/TimeParser.hxx \
src/util/UriUtil.cxx src/util/UriUtil.hxx \
src/util/Manual.hxx \
src/util/RefCount.hxx \
@@ -529,6 +540,10 @@ ICU_LDADD = libicu.a $(ICU_LIBS)
# PCM library
libpcm_a_SOURCES = \
src/CheckAudioFormat.cxx src/CheckAudioFormat.hxx \
src/AudioFormat.cxx src/AudioFormat.hxx \
src/AudioParser.cxx src/AudioParser.hxx \
src/pcm/SampleFormat.cxx src/pcm/SampleFormat.hxx \
src/pcm/Traits.hxx \
src/pcm/Interleave.cxx src/pcm/Interleave.hxx \
src/pcm/PcmBuffer.cxx src/pcm/PcmBuffer.hxx \
@@ -565,6 +580,8 @@ PCM_LIBS = \
if ENABLE_DSD
libpcm_a_SOURCES += \
src/pcm/Dsd16.cxx src/pcm/Dsd16.hxx \
src/pcm/Dsd32.cxx src/pcm/Dsd32.hxx \
src/pcm/PcmDsd.cxx src/pcm/PcmDsd.hxx \
src/pcm/dsd2pcm/dsd2pcm.c src/pcm/dsd2pcm/dsd2pcm.h
endif
@@ -603,7 +620,8 @@ libxiph_a_SOURCES += \
src/lib/xiph/OggStreamState.hxx
endif
XIPH_LIBS = libxiph.a
XIPH_LIBS = libxiph.a \
$(OGG_LIBS)
endif
@@ -689,6 +707,8 @@ libstorage_a_CPPFLAGS = $(AM_CPPFLAGS) \
STORAGE_LIBS = \
libstorage.a \
$(CURL_LIBS) \
$(EXPAT_LIBS) \
$(NFS_LIBS) \
$(SMBCLIENT_LIBS)
@@ -704,6 +724,12 @@ libstorage_a_SOURCES += \
src/storage/plugins/NfsStorage.cxx src/storage/plugins/NfsStorage.hxx
endif
if ENABLE_WEBDAV
libstorage_a_SOURCES += \
src/lib/expat/ExpatParser.cxx \
src/storage/plugins/CurlStorage.cxx src/storage/plugins/CurlStorage.hxx
endif
endif
# neighbor plugins
@@ -851,9 +877,6 @@ ARCHIVE_LIBS =
endif
libbasic_a_SOURCES = \
src/CheckAudioFormat.cxx src/CheckAudioFormat.hxx \
src/AudioFormat.cxx src/AudioFormat.hxx \
src/AudioParser.cxx src/AudioParser.hxx \
src/ReplayGainConfig.hxx \
src/ReplayGainMode.cxx src/ReplayGainMode.hxx \
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx
@@ -1279,12 +1302,7 @@ if ENABLE_CURL
libinput_a_SOURCES += \
src/input/IcyInputStream.cxx src/input/IcyInputStream.hxx \
src/input/plugins/CurlInputPlugin.cxx src/input/plugins/CurlInputPlugin.hxx \
src/lib/curl/Version.cxx src/lib/curl/Version.hxx \
src/lib/curl/Global.cxx src/lib/curl/Global.hxx \
src/lib/curl/Request.cxx src/lib/curl/Request.hxx \
src/lib/curl/Handler.hxx \
src/lib/curl/Easy.hxx \
src/lib/curl/Multi.hxx \
$(CURL_SOURCES) \
src/IcyMetaDataParser.cxx src/IcyMetaDataParser.hxx
endif
@@ -1382,6 +1400,7 @@ libmixer_plugins_a_SOURCES = \
src/mixer/plugins/NullMixerPlugin.cxx \
src/mixer/plugins/SoftwareMixerPlugin.cxx \
src/mixer/plugins/SoftwareMixerPlugin.hxx
libmixer_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(ALSA_CFLAGS) \
$(PULSE_CFLAGS)
@@ -1390,7 +1409,10 @@ if ENABLE_ALSA
liboutput_plugins_a_SOURCES += \
src/output/plugins/AlsaOutputPlugin.cxx \
src/output/plugins/AlsaOutputPlugin.hxx
libmixer_plugins_a_SOURCES += src/mixer/plugins/AlsaMixerPlugin.cxx
libmixer_plugins_a_SOURCES += \
src/mixer/plugins/volume_mapping.h \
src/mixer/plugins/volume_mapping.c \
src/mixer/plugins/AlsaMixerPlugin.cxx
endif
if ANDROID
@@ -1573,6 +1595,7 @@ endif
if ENABLE_EXPAT
libplaylist_plugins_a_SOURCES += \
src/lib/expat/StreamExpatParser.cxx \
src/lib/expat/ExpatParser.cxx src/lib/expat/ExpatParser.hxx \
src/playlist/plugins/XspfPlaylistPlugin.cxx \
src/playlist/plugins/XspfPlaylistPlugin.hxx \
@@ -1758,6 +1781,10 @@ test_run_storage_SOURCES = \
test/ScopeIOThread.hxx \
test/run_storage.cxx
if ENABLE_WEBDAV
test_run_storage_SOURCES += $(CURL_SOURCES)
endif
endif
test_run_input_LDADD = \
@@ -2203,6 +2230,7 @@ test_test_icy_parser_LDADD = \
endif
test_test_pcm_SOURCES = \
test/TestAudioFormat.cxx test/TestAudioFormat.hxx \
test/test_pcm_util.hxx \
test/test_pcm_dither.cxx \
test/test_pcm_pack.cxx \

76
NEWS

@@ -1,3 +1,79 @@
ver 0.20.7 (2017/05/15)
* database
- simple: fix false positive directory loop detection with NFS
* enforce a reasonable minimum audio_buffer_size setting
* cap buffer_before_play at 80% to prevent deadlock
* fix random crashes when compiled with clang
ver 0.20.6 (2017/03/10)
* input
- curl: fix headers after HTTP redirect to Shoutcast server
* decoder
- ffmpeg: re-enable as fallback
- mpcdec: fix crash (division by zero) after seeking
- sidplay: make compatible with libsidplayfp < 1.8
* fix stream tags after automatic song change
* workaround for GCC 4.9.4 / libstdc++ bug (build failure)
ver 0.20.5 (2017/02/20)
* tags
- id3: fix memory leak on corrupt ID3 tags
* decoder
- sidplay: don't require libsidutils when building with libsidplayfp
* output
- httpd: fix two buffer overflows in IcyMetaData length calculation
* mixer
- alsa: fix crash bug
ver 0.20.4 (2017/02/01)
* input
- nfs: fix freeze after reconnect
* output
- sndio: work around a libroar C++ incompatibility
* workaround for GCC 4.9 "constexpr" bug
* fix FreeBSD build failure
ver 0.20.3 (2017/01/25)
* protocol
- "playlistadd" creates new playlist if it does not exist, as documented
* database
- proxy: fix error "terminate called after throwing ..."
- proxy: make connect errors during startup non-fatal
* neighbor
- upnp: fix premature expiry
* replay gain: don't reset ReplayGain levels when unpausing playback
* silence surround channels when converting from stereo
* use shortcuts such as "dsd64" in log messages
ver 0.20.2 (2017/01/15)
* input
- alsa: fix crash bug
- alsa: fix buffer overruns
* decoder
- flac: add options "probesize" and "analyzeduration"
* resampler
- libsamplerate: reset state after seeking
* output
- fix static noise after changing to a different audio format
- alsa: fix the DSD_U32 sample rate
- alsa: fix the DSD_U32 byte order
- alsa: support DSD_U16
- recorder: fix error "Failed to create : No such file or directory"
* playlist
- cue: fix skipping songs
ver 0.20.1 (2017/01/09)
* input
- curl: fix crash bug
- curl: fix freeze bug
* decoder
- wavpack: fix crash bug
* storage
- curl: new storage plugin for WebDAV (work in progress)
* mixer
- alsa: normalize displayed volume according to human perception
* fix crash with volume_normalization enabled
ver 0.20 (2017/01/04)
* protocol
- "commands" returns playlist commands only if playlist_directory configured

@@ -14,7 +14,7 @@ For basic installation information see the INSTALL file.
- [Manual](http://www.musicpd.org/doc/user/)
- [Forum](http://forum.musicpd.org/)
- [IRC](irc://chat.freenode.net/#mpd)
- [Bug tracker](http://bugs.musicpd.org/)
- [Bug tracker](https://github.com/MusicPlayerDaemon/MPD/issues/)
# Developers

@@ -87,9 +87,14 @@ class AndroidNdkToolchain:
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
self.is_windows = False
libstdcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/gnu-libstdc++', gcc_version)
libstdcxx_cppflags = '-isystem ' + os.path.join(libstdcxx_path, 'include') + ' -isystem ' + os.path.join(libstdcxx_path, 'libs', android_abi, 'include')
libstdcxx_ldadd = os.path.join(libstdcxx_path, 'libs', android_abi, 'libgnustl_static.a')
libcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/llvm-libc++')
libcxx_libs_path = os.path.join(libcxx_path, 'libs', android_abi)
libstdcxx_cppflags = '-nostdinc++ -isystem ' + os.path.join(libcxx_path, 'include') + ' -isystem ' + os.path.join(ndk_path, 'sources/android/support/include')
libstdcxx_ldadd = os.path.join(libcxx_libs_path, 'libc++_static.a') + ' ' + os.path.join(libcxx_libs_path, 'libc++abi.a')
if self.is_armv7:
libstdcxx_ldadd += ' ' + os.path.join(libcxx_libs_path, 'libunwind.a')
if use_cxx:
self.libs += ' ' + libstdcxx_ldadd

@@ -1,10 +1,10 @@
AC_PREREQ(2.60)
AC_INIT(mpd, 0.20, musicpd-dev-team@lists.sourceforge.net)
AC_INIT(mpd, 0.20.7, musicpd-dev-team@lists.sourceforge.net)
VERSION_MAJOR=0
VERSION_MINOR=20
VERSION_REVISION=0
VERSION_REVISION=7
VERSION_EXTRA=0
AC_CONFIG_SRCDIR([src/Main.cxx])
@@ -720,6 +720,19 @@ fi
MPD_ENABLE_AUTO_PKG(mms, MMS, [libmms >= 0.4],
[libmms mms:// protocol support], [libmms not found])
dnl ---------------------------------------------------------------------------
dnl Storage Plugins
dnl ---------------------------------------------------------------------------
MPD_ENABLE_AUTO(webdav, WEBDAV, [WebDAV storage plugin],
[WebDAV requires libcurl and libexpat],
[auto],
[if test x$enable_curl = xyes && test x$enable_expat = xyes; then
found_webdav=yes
else
found_webdav=no
fi])
dnl ---------------------------------------------------------------------------
dnl Playlist Plugins
dnl ---------------------------------------------------------------------------
@@ -979,7 +992,7 @@ AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enab
dnl --------------------------------- sidplay ---------------------------------
if test x$enable_sidplay != xno; then
dnl Check for libsidplayfp first
PKG_CHECK_MODULES([SIDPLAY], [libsidplayfp libsidutils],
PKG_CHECK_MODULES([SIDPLAY], [libsidplayfp],
[found_sidplayfp=yes],
[found_sidplayfp=no])
found_sidplay=$found_sidplayfp

@@ -5,7 +5,7 @@
<book>
<title>The Music Player Daemon - Developer's Manual</title>
<chapter>
<chapter id="introduction">
<title>Introduction</title>
<para>
@@ -21,7 +21,7 @@
</para>
</chapter>
<chapter>
<chapter id="code_style">
<title>Code Style</title>
<itemizedlist>
@@ -40,21 +40,47 @@
<listitem>
<para>
the code should be C++11 compliant, and must compile with
comment your code, document your APIs
</para>
</listitem>
<listitem>
<para>
the code should be C++14 compliant, and must compile with
<application>GCC</application> 4.9 and
<application>clang</application> 3.4
</para>
</listitem>
<listitem>
<para>
report error conditions with C++ exceptions, preferable
derived from <varname>std::runtime_error</varname>
</para>
</listitem>
<listitem>
<para>
all code must be exception-safe
</para>
</listitem>
<listitem>
<para>
classes and functions names use CamelCase; variables are
lower-case with words separated by underscore
</para>
</listitem>
<listitem>
<para>
Some example code:
</para>
<programlisting lang="C">static inline int
foo(const char *abc, int xyz)
Foo(const char *abc, int xyz)
{
if (abc == NULL) {
if (abc == nullptr) {
LogWarning("Foo happened!");
return -1;
}
@@ -66,25 +92,25 @@ foo(const char *abc, int xyz)
</itemizedlist>
</chapter>
<chapter>
<chapter id="hacking">
<title>Hacking The Source</title>
<para>
MPD sources are managed in a git repository on <ulink
url="http://git.musicpd.org/">git.musicpd.org</ulink>.
url="https://github.com/MusicPlayerDaemon/">GitHub</ulink>.
</para>
<para>
Always write your code against the latest git:
</para>
<programlisting>git clone git://git.musicpd.org/master/mpd.git</programlisting>
<programlisting>git clone git://github.com/MusicPlayerDaemon/MPD</programlisting>
<para>
If you already have a clone, update it:
</para>
<programlisting>git pull --rebase git://git.musicpd.org/master/mpd.git master</programlisting>
<programlisting>git pull --rebase git://github.com/MusicPlayerDaemon/MPD master</programlisting>
<para>
You can do without "--rebase", but we recommend that you rebase
@@ -151,7 +177,7 @@ foo(const char *abc, int xyz)
</section>
</chapter>
<chapter>
<chapter id="submitting_patches">
<title>Submitting Patches</title>
<para>
@@ -162,14 +188,11 @@ foo(const char *abc, int xyz)
</para>
<para>
<command>git pull</command> requests are preferred. Regular
contributors can get <ulink
url="http://git.musicpd.org/account-policy.html">an account on
git.musicpd.org</ulink>, but any public git repository will do.
<command>git pull</command> requests are preferred.
</para>
</chapter>
<chapter>
<chapter id="tools">
<title>Development Tools</title>
<section>

@@ -55,7 +55,8 @@
<listitem>
<para>
<varname>track</varname>: the track number within the album.
<varname>track</varname>: the decimal track number within the
album.
</para>
</listitem>
@@ -103,7 +104,8 @@
<listitem>
<para>
<varname>disc</varname>: the disc number in a multi-disc album.
<varname>disc</varname>: the decimal disc number in a multi-disc
album.
</para>
</listitem>

@@ -48,8 +48,8 @@ mpd.conf(5), mpc(1)
.SH BUGS
If you find a bug, please report it at
.br
<\fBhttp://bugs.musicpd.org/bug_report_page.php\fP>.
<\fBhttps://github.com/MusicPlayerDaemon/MPD/issues/\fP>.
.SH AUTHORS
Max Kellermann <max@duempel.org>
Max Kellermann <max.kellermann@gmail.com>
Special thanks to all the people that provided feedback and patches.

@@ -573,7 +573,12 @@
<listitem>
<para>
<varname>audio</varname>:
<returnvalue>sampleRate:bits:channels</returnvalue>
<returnvalue>
The format emitted by the decoder plugin during
playback, format:
"<replaceable>samplerate:bits:channels</replaceable>".
Check the user manual for a detailed explanation.
</returnvalue>
</para>
</listitem>
<listitem>

@@ -135,6 +135,91 @@ apt-get install g++ \
</para>
<programlisting>make install</programlisting>
<section id="windows_build">
<title>Compiling for Windows</title>
<para>
Even though it does not "feel" like a Windows application,
<application>MPD</application> works well under Windows.
Its build process follows the "Linux style", and may seem
awkward for Windows people (who are not used to compiling
their software, anyway).
</para>
<para>
Basically, there are three ways to compile
<application>MPD</application> for Windows:
</para>
<orderedlist>
<listitem>
<para>
Build on Windows for Windows. All you need to do is
described above already: configure and make.
</para>
<para>
For Windows users, this is kind of unusual, because few
Windows users have a GNU toolchain and a UNIX shell
installed.
</para>
</listitem>
<listitem>
<para>
Build on Linux for Windows. This is described above
already: configure and make. You need the <ulink
url="https://mingw-w64.org/"><application>mingw-w64</application>
cross compiler</ulink>. Pass
<parameter>--host=i686-w64-mingw32</parameter> (32 bit)
or <parameter>--host=x86_64-w64-mingw32</parameter> (64
bit) to configure.
</para>
<para>
This is somewhat natural for Linux users. Many
distributions have <application>mingw-w64</application>
packages. The remaining difficulty here is installing
all the external libraries. And
<application>MPD</application> usually needs many,
making this method cumbersome for the casual user.
</para>
</listitem>
<listitem>
<para>
Build on Linux for Windows using the
<application>MPD</application>'s library build script.
</para>
</listitem>
</orderedlist>
<para>
This section is about the latter.
</para>
<para>
Just like with the native build, unpack the
<application>MPD</application> source tarball and change
into the directory. Then, instead of
<command>./configure</command>, type:
</para>
<programlisting>./win32/build.py --64</programlisting>
<para>
This downloads various library sources, and then configures
and builds <application>MPD</application> (for x64; to build
a 32 bit binary, pass <parameter>--32</parameter>). The
resulting EXE files is linked statically, i.e. it contains
all the libraries already, and you do not need carry DLLs
around. It is large, but easy to use. If you wish to have
a small <filename>mpd.exe</filename> with DLLs, you need to
compile manually, without the <filename>build.py</filename>
script.
</para>
</section>
</section>
<section id="systemd_socket">
@@ -576,10 +661,11 @@ systemctl start mpd.socket</programlisting>
</entry>
<entry>
<para>
Always open the audio output with the specified audio
format (samplerate:bits:channels), regardless of the
format of the input file. This is optional for most
plugins.
Always open the audio output with the specified
audio format
(<replaceable>samplerate:bits:channels</replaceable>),
regardless of the format of the input file. This is
optional for most plugins.
</para>
<para>
Any of the three attributes may be an asterisk to
@@ -596,7 +682,20 @@ systemctl start mpd.socket</programlisting>
24 bit integer samples padded to 32 bit),
<varname>32</varname> (signed 32 bit integer
samples), <varname>f</varname> (32 bit floating
point, -1.0 to 1.0).
point, -1.0 to 1.0), "<varname>dsd</varname>" means
DSD (Direct Stream Digital). For DSD, there are
special cases such as "<varname>dsd64</varname>",
which allows you to omit the sample rate
(e.g. <parameter>dsd512:2</parameter> for stereo
DSD512, i.e. 22.5792 MHz).
</para>
<para>
The sample rate is special for DSD:
<application>MPD</application> counts the number of
bytes, not bits. Thus, a DSD "bit" rate of 22.5792
MHz (DSD512) is 2822400 from
<application>MPD</application>'s point of view
(44100*512/8).
</para>
</entry>
</row>
@@ -742,9 +841,11 @@ systemctl start mpd.socket</programlisting>
<title>Configuring playlist plugins</title>
<para>
Playlist plugins are used to load remote playlists. This is
not related to <application>MPD</application>'s playlist
directory.
Playlist plugins are used to load remote playlists (protocol
commands <command>load</command>,
<command>listplaylist</command> and
<command>listplaylistinfo</command>). This is not related to
<application>MPD</application>'s playlist directory.
</para>
<para>
@@ -1646,7 +1747,7 @@ buffer_size: 16384</programlisting>
<para>
If you believe you found a bug in
<application>MPD</application>, report it on <ulink
url="https://bugs.musicpd.org/my_view_page.php">the bug
url="https://github.com/MusicPlayerDaemon/MPD/issues/">the bug
tracker</ulink>.
</para>
@@ -1800,6 +1901,13 @@ run</programlisting>
database.
</para>
<para>
Note that unless overridden by the below settings (e.g. by
setting them to a blank value), general curl configuration
from environment variables such as http_proxy or specified
in ~/.curlrc will be in effect.
</para>
<informaltable>
<tgroup cols="2">
<thead>
@@ -1868,11 +1976,23 @@ run</programlisting>
</para>
</section>
<section id="curl_storage">
<title><varname>curl</varname></title>
<para>
A WebDAV client using <filename>libcurl</filename>. It is
used when <varname>music_directory</varname> contains a
<parameter>http://</parameter> or
<parameter>https://</parameter> URI, for example
"<parameter>https://the.server/dav/</parameter>".
</para>
</section>
<section id="smbclient_storage">
<title><varname>smbclient</varname></title>
<para>
Load music files from a SMB/CIFS server. It used used when
Load music files from a SMB/CIFS server. It is used when
<varname>music_directory</varname> contains a
<parameter>smb://</parameter> URI, for example
"<parameter>smb://myfileserver/Music</parameter>".
@@ -1883,7 +2003,7 @@ run</programlisting>
<title><varname>nfs</varname></title>
<para>
Load music files from a NFS server. It used used when
Load music files from a NFS server. It is used when
<varname>music_directory</varname> contains a
<parameter>nfs://</parameter> URI according to <ulink
url="http://tools.ietf.org/html/rfc2224">RFC2224</ulink>,
@@ -2194,6 +2314,48 @@ run</programlisting>
Decodes various codecs using
<application>FFmpeg</application>.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>analyzeduration</varname>
<parameter>VALUE</parameter>
</entry>
<entry>
Sets the FFmpeg muxer option
<varname>analyzeduration</varname>, which specifies
how many microseconds are analyzed to probe the
input. The <ulink
url="https://ffmpeg.org/ffmpeg-formats.html">FFmpeg
formats documentation</ulink> has more information.
</entry>
</row>
<row>
<entry>
<varname>probesize</varname>
<parameter>VALUE</parameter>
</entry>
<entry>
Sets the FFmpeg muxer option
<varname>probesize</varname>, which specifies
probing size in bytes, i.e. the size of the data to
analyze to get stream information. The <ulink
url="https://ffmpeg.org/ffmpeg-formats.html">FFmpeg
formats documentation</ulink> has more information.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section id="flac_decoder">
@@ -3918,7 +4080,7 @@ run</programlisting>
(logical "and") can be used to select portions of
the format string depending on the existing tag
values. Example:
<parameter>~/.mpd/recorder/[%title|%name%].ogg</parameter>
<parameter>~/.mpd/recorder/[%title%|%name%].ogg</parameter>
(use the "name" tag if no title exists)
</para>
</entry>
@@ -4139,6 +4301,22 @@ run</programlisting>
<section id="playlist_plugins">
<title>Playlist plugins</title>
<section>
<title><varname>asx</varname></title>
<para>
Reads <filename>.asx</filename> playlist files.
</para>
</section>
<section>
<title><varname>cue</varname></title>
<para>
Reads <filename>.cue</filename> files.
</para>
</section>
<section>
<title><varname>embcue</varname></title>
@@ -4163,6 +4341,15 @@ run</programlisting>
</para>
</section>
<section>
<title><varname>flac</varname></title>
<para>
Reads the <varname>cuesheet</varname> metablock from a FLAC
file.
</para>
</section>
<section>
<title><varname>pls</varname></title>
@@ -4171,6 +4358,45 @@ run</programlisting>
</para>
</section>
<section>
<title><varname>rss</varname></title>
<para>
Reads music links from <filename>.rss</filename> files.
</para>
</section>
<section>
<title><varname>soundcloud</varname></title>
<para>
Download playlist from SoundCloud. It accepts URIs starting
with <filename>soundcloud://</filename>.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>apikey</varname>
<parameter>KEY</parameter>
</entry>
<entry>
An API key to access the SoundCloud servers.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>xspf</varname></title>

@@ -1,6 +1,6 @@
# Check if "struct ucred" is available.
#
# Author: Max Kellermann <max@duempel.org>
# Author: Max Kellermann <max.kellermann@gmail.com>
AC_DEFUN([STRUCT_UCRED],[
AC_MSG_CHECKING([for struct ucred])

@@ -19,8 +19,8 @@ libvorbis = AutotoolsProject(
)
opus = AutotoolsProject(
'http://downloads.xiph.org/releases/opus/opus-1.1.3.tar.gz',
'32bbb6b557fe1b6066adc0ae1f08b629',
'http://downloads.xiph.org/releases/opus/opus-1.1.4.tar.gz',
'9122b6b380081dd2665189f97bfd777f04f92dc3ab6698eea1dbb27ad59d8692',
'lib/libopus.a',
['--disable-shared', '--enable-static'],
)
@@ -36,8 +36,8 @@ flac = AutotoolsProject(
)
zlib = ZlibProject(
'http://zlib.net/zlib-1.2.8.tar.xz',
'28f1205d8dd2001f26fec1e8c2cebe37',
'http://zlib.net/zlib-1.2.11.tar.xz',
'4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066',
'lib/libz.a',
)
@@ -58,8 +58,8 @@ libmad = AutotoolsProject(
)
ffmpeg = FfmpegProject(
'http://ffmpeg.org/releases/ffmpeg-3.2.2.tar.xz',
'3f01bd1fe1a17a277f8c84869e5d9192b4b978cb660872aa2b54c3cc8a2fedfc',
'http://ffmpeg.org/releases/ffmpeg-3.3.tar.xz',
'599e7f7c017221c22011c4037b88bdcd1c47cd40c1e466838bc3c465f3e9569d',
'lib/libavcodec.a',
[
'--disable-shared', '--enable-static',
@@ -82,8 +82,8 @@ ffmpeg = FfmpegProject(
)
curl = AutotoolsProject(
'http://curl.haxx.se/download/curl-7.52.1.tar.lzma',
'44286d4b825936e2430fc44ad730ce899afb736a5d328cbb8b5d42462f3f2365',
'http://curl.haxx.se/download/curl-7.54.0.tar.lzma',
'cd6aa6039f13e0b06e0a93e1b93754f6dc07f444812bb6c32be75a8f28c4070a',
'lib/libcurl.a',
[
'--disable-shared', '--enable-static',
@@ -103,7 +103,7 @@ curl = AutotoolsProject(
)
boost = BoostProject(
'http://downloads.sourceforge.net/project/boost/boost/1.63.0/boost_1_63_0.tar.bz2',
'beae2529f759f6b3bf3f4969a19c2e9d6f0c503edcb2de4a61d1428519fcb3b0',
'http://downloads.sourceforge.net/project/boost/boost/1.64.0/boost_1_64_0.tar.bz2',
'7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332',
'include/boost/version.hpp',
)

@@ -18,12 +18,13 @@
*/
#include "AudioFormat.hxx"
#include "util/StringBuffer.hxx"
#include <assert.h>
#include <stdio.h>
void
AudioFormat::ApplyMask(AudioFormat mask)
AudioFormat::ApplyMask(AudioFormat mask) noexcept
{
assert(IsValid());
assert(mask.IsMaskValid());
@@ -40,46 +41,24 @@ AudioFormat::ApplyMask(AudioFormat mask)
assert(IsValid());
}
const char *
sample_format_to_string(SampleFormat format)
StringBuffer<24>
ToString(const AudioFormat af) noexcept
{
switch (format) {
case SampleFormat::UNDEFINED:
return "?";
StringBuffer<24> buffer;
case SampleFormat::S8:
return "8";
case SampleFormat::S16:
return "16";
case SampleFormat::S24_P32:
return "24";
case SampleFormat::S32:
return "32";
case SampleFormat::FLOAT:
return "f";
case SampleFormat::DSD:
return "dsd";
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
af.sample_rate % 44100 == 0) {
/* use shortcuts such as "dsd64" which implies the
sample rate */
snprintf(buffer.data(), buffer.capacity(), "dsd%u:%u",
af.sample_rate * 8 / 44100,
af.channels);
return buffer;
}
/* unreachable */
assert(false);
gcc_unreachable();
}
const char *
audio_format_to_string(const AudioFormat af,
struct audio_format_string *s)
{
assert(s != nullptr);
snprintf(s->buffer, sizeof(s->buffer), "%u:%s:%u",
snprintf(buffer.data(), buffer.capacity(), "%u:%s:%u",
af.sample_rate, sample_format_to_string(af.format),
af.channels);
return s->buffer;
return buffer;
}

@@ -20,47 +20,14 @@
#ifndef MPD_AUDIO_FORMAT_HXX
#define MPD_AUDIO_FORMAT_HXX
#include "pcm/SampleFormat.hxx"
#include "Compiler.h"
#include <stdint.h>
#include <assert.h>
#include <stdint.h>
#include <stddef.h>
#if defined(WIN32) && GCC_CHECK_VERSION(4,6)
/* on WIN32, "FLOAT" is already defined, and this triggers -Wshadow */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
enum class SampleFormat : uint8_t {
UNDEFINED = 0,
S8,
S16,
/**
* Signed 24 bit integer samples, packed in 32 bit integers
* (the most significant byte is filled with the sign bit).
*/
S24_P32,
S32,
/**
* 32 bit floating point samples in the host's format. The
* range is -1.0f to +1.0f.
*/
FLOAT,
/**
* Direct Stream Digital. 1-bit samples; each frame has one
* byte (8 samples) per channel.
*/
DSD,
};
#if defined(WIN32) && GCC_CHECK_VERSION(4,6)
#pragma GCC diagnostic pop
#endif
template<size_t CAPACITY> class StringBuffer;
static constexpr unsigned MAX_CHANNELS = 8;
@@ -157,7 +124,7 @@ struct AudioFormat {
return !(*this == other);
}
void ApplyMask(AudioFormat mask);
void ApplyMask(AudioFormat mask) noexcept;
gcc_pure
AudioFormat WithMask(AudioFormat mask) const {
@@ -183,13 +150,6 @@ struct AudioFormat {
double GetTimeToSize() const;
};
/**
* Buffer for audio_format_string().
*/
struct audio_format_string {
char buffer[24];
};
/**
* Checks whether the sample rate is valid.
*
@@ -201,28 +161,6 @@ audio_valid_sample_rate(unsigned sample_rate)
return sample_rate > 0 && sample_rate < (1 << 30);
}
/**
* Checks whether the sample format is valid.
*/
static inline bool
audio_valid_sample_format(SampleFormat format)
{
switch (format) {
case SampleFormat::S8:
case SampleFormat::S16:
case SampleFormat::S24_P32:
case SampleFormat::S32:
case SampleFormat::FLOAT:
case SampleFormat::DSD:
return true;
case SampleFormat::UNDEFINED:
break;
}
return false;
}
/**
* Checks whether the number of channels is valid.
*/
@@ -258,34 +196,6 @@ AudioFormat::IsMaskValid() const
(channels == 0 || audio_valid_channel_count(channels));
}
gcc_const
static inline unsigned
sample_format_size(SampleFormat format)
{
switch (format) {
case SampleFormat::S8:
return 1;
case SampleFormat::S16:
return 2;
case SampleFormat::S24_P32:
case SampleFormat::S32:
case SampleFormat::FLOAT:
return 4;
case SampleFormat::DSD:
/* each frame has 8 samples per channel */
return 1;
case SampleFormat::UNDEFINED:
return 0;
}
assert(false);
gcc_unreachable();
}
inline unsigned
AudioFormat::GetSampleSize() const
{
@@ -304,28 +214,15 @@ AudioFormat::GetTimeToSize() const
return sample_rate * GetFrameSize();
}
/**
* Renders a #SampleFormat enum into a string, e.g. for printing it
* in a log file.
*
* @param format a #SampleFormat enum value
* @return the string
*/
gcc_pure gcc_malloc
const char *
sample_format_to_string(SampleFormat format);
/**
* Renders the #AudioFormat object into a string, e.g. for printing
* it in a log file.
*
* @param af the #AudioFormat object
* @param s a buffer to print into
* @return the string, or nullptr if the #AudioFormat object is invalid
* @return the string buffer
*/
gcc_pure gcc_malloc
const char *
audio_format_to_string(AudioFormat af,
struct audio_format_string *s);
gcc_const
StringBuffer<24>
ToString(AudioFormat af) noexcept;
#endif

@@ -137,6 +137,26 @@ ParseAudioFormat(const char *src, bool mask)
AudioFormat dest;
dest.Clear();
if (strncmp(src, "dsd", 3) == 0) {
/* allow format specifications such as "dsd64" which
implies the sample rate */
char *endptr;
auto dsd = strtoul(src + 3, &endptr, 10);
if (endptr > src + 3 && *endptr == ':' &&
dsd >= 32 && dsd <= 4096 && dsd % 2 == 0) {
dest.sample_rate = dsd * 44100 / 8;
dest.format = SampleFormat::DSD;
src = endptr + 1;
dest.channels = ParseChannelCount(src, mask, &src);
if (*src != 0)
throw FormatRuntimeError("Extra data after channel count: %s", src);
return dest;
}
}
/* parse sample rate */
dest.sample_rate = ParseSampleRate(src, mask, &src);

@@ -25,8 +25,6 @@
#ifndef MPD_AUDIO_PARSER_HXX
#define MPD_AUDIO_PARSER_HXX
#include "Compiler.h"
struct AudioFormat;
/**
@@ -38,7 +36,6 @@ struct AudioFormat;
* @param src the input string
* @param mask if true, then "*" is allowed for any number of items
*/
gcc_pure
AudioFormat
ParseAudioFormat(const char *src, bool mask);

@@ -107,7 +107,7 @@ static void version(void)
"\n"
"\n"
"Copyright (C) 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
"Copyright (C) 2008-2015 Max Kellermann <max@duempel.org>\n"
"Copyright 2008-2017 Max Kellermann <max.kellermann@gmail.com>\n"
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"

@@ -37,19 +37,19 @@ DetachedSong::~DetachedSong()
}
bool
DetachedSong::IsRemote() const
DetachedSong::IsRemote() const noexcept
{
return uri_has_scheme(GetRealURI());
}
bool
DetachedSong::IsAbsoluteFile() const
DetachedSong::IsAbsoluteFile() const noexcept
{
return PathTraitsUTF8::IsAbsolute(GetRealURI());
}
bool
DetachedSong::IsInDatabase() const
DetachedSong::IsInDatabase() const noexcept
{
/* here, we use GetURI() and not GetRealURI() because
GetRealURI() is never relative */
@@ -59,7 +59,7 @@ DetachedSong::IsInDatabase() const
}
SignedSongTime
DetachedSong::GetDuration() const
DetachedSong::GetDuration() const noexcept
{
SongTime a = start_time, b = end_time;
if (!b.IsPositive()) {

@@ -63,18 +63,18 @@ class DetachedSong {
Tag tag;
time_t mtime;
time_t mtime = 0;
/**
* Start of this sub-song within the file.
*/
SongTime start_time;
SongTime start_time = SongTime::zero();
/**
* End of this sub-song within the file.
* Unused if zero.
*/
SongTime end_time;
SongTime end_time = SongTime::zero();
explicit DetachedSong(const LightSong &other);
@@ -82,33 +82,25 @@ public:
explicit DetachedSong(const DetachedSong &) = default;
explicit DetachedSong(const char *_uri)
:uri(_uri),
mtime(0),
start_time(SongTime::zero()), end_time(SongTime::zero()) {}
:uri(_uri) {}
explicit DetachedSong(const std::string &_uri)
:uri(_uri),
mtime(0),
start_time(SongTime::zero()), end_time(SongTime::zero()) {}
:uri(_uri) {}
explicit DetachedSong(std::string &&_uri)
:uri(std::move(_uri)),
mtime(0),
start_time(SongTime::zero()), end_time(SongTime::zero()) {}
:uri(std::move(_uri)) {}
template<typename U>
DetachedSong(U &&_uri, Tag &&_tag)
:uri(std::forward<U>(_uri)),
tag(std::move(_tag)),
mtime(0),
start_time(SongTime::zero()), end_time(SongTime::zero()) {}
tag(std::move(_tag)) {}
DetachedSong(DetachedSong &&) = default;
~DetachedSong();
gcc_pure
const char *GetURI() const {
const char *GetURI() const noexcept {
return uri.c_str();
}
@@ -122,7 +114,7 @@ public:
* displayed URI?
*/
gcc_pure
bool HasRealURI() const {
bool HasRealURI() const noexcept {
return !real_uri.empty();
}
@@ -131,7 +123,7 @@ public:
* GetURI().
*/
gcc_pure
const char *GetRealURI() const {
const char *GetRealURI() const noexcept {
return (HasRealURI() ? real_uri : uri).c_str();
}
@@ -145,17 +137,19 @@ public:
* song.
*/
gcc_pure
bool IsSame(const DetachedSong &other) const {
return uri == other.uri;
bool IsSame(const DetachedSong &other) const noexcept {
return uri == other.uri &&
start_time == other.start_time &&
end_time == other.end_time;
}
gcc_pure gcc_nonnull_all
bool IsURI(const char *other_uri) const {
bool IsURI(const char *other_uri) const noexcept {
return uri == other_uri;
}
gcc_pure
bool IsRemote() const;
bool IsRemote() const noexcept;
gcc_pure
bool IsFile() const {
@@ -163,10 +157,10 @@ public:
}
gcc_pure
bool IsAbsoluteFile() const;
bool IsAbsoluteFile() const noexcept;
gcc_pure
bool IsInDatabase() const;
bool IsInDatabase() const noexcept;
const Tag &GetTag() const {
return tag;
@@ -221,7 +215,7 @@ public:
}
gcc_pure
SignedSongTime GetDuration() const;
SignedSongTime GetDuration() const noexcept;
/**
* Update the #tag and #mtime.

@@ -96,7 +96,7 @@ io_thread_deinit(void)
}
EventLoop &
io_thread_get()
io_thread_get() noexcept
{
assert(io.loop != nullptr);
@@ -104,7 +104,7 @@ io_thread_get()
}
bool
io_thread_inside(void)
io_thread_inside() noexcept
{
return io.thread.IsInside();
}

@@ -51,13 +51,13 @@ io_thread_deinit();
gcc_const
EventLoop &
io_thread_get();
io_thread_get() noexcept;
/**
* Is the current thread the I/O thread?
*/
gcc_pure
bool
io_thread_inside();
io_thread_inside() noexcept;
#endif

@@ -46,13 +46,13 @@ static const char *const idle_names[] = {
};
const char*const*
idle_get_names(void)
idle_get_names() noexcept
{
return idle_names;
}
unsigned
idle_parse_name(const char *name)
idle_parse_name(const char *name) noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */

@@ -70,8 +70,9 @@ static constexpr unsigned IDLE_MOUNT = 0x1000;
/**
* Get idle names
*/
gcc_const
const char*const*
idle_get_names();
idle_get_names() noexcept;
/**
* Parse an idle name and return its mask. Returns 0 if the given
@@ -79,6 +80,6 @@ idle_get_names();
*/
gcc_nonnull_all gcc_pure
unsigned
idle_parse_name(const char *name);
idle_parse_name(const char *name) noexcept;
#endif

@@ -117,7 +117,6 @@ struct Instance final
* DatabaseError if this MPD configuration has no database (no
* music_directory was configured).
*/
gcc_pure
const Database &GetDatabaseOrThrow() const;
#endif

@@ -117,7 +117,13 @@
#include <limits.h>
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
static constexpr size_t KILOBYTE = 1024;
static constexpr size_t MEGABYTE = 1024 * KILOBYTE;
static constexpr size_t DEFAULT_BUFFER_SIZE = 4 * MEGABYTE;
static constexpr size_t MIN_BUFFER_SIZE = std::max(CHUNK_SIZE * 32,
64 * KILOBYTE);
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
#ifdef ANDROID
@@ -130,7 +136,6 @@ struct Config {
ReplayGainConfig replay_gain;
};
gcc_const
static Config
LoadConfig()
{
@@ -203,7 +208,11 @@ glue_db_init_and_load(void)
"because the database does not need it");
}
instance->database->Open();
try {
instance->database->Open();
} catch (...) {
std::throw_with_nested(std::runtime_error("Failed to open database plugin"));
}
if (!instance->database->IsPlugin(simple_db_plugin))
return true;
@@ -303,12 +312,17 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
FormatFatalError("buffer size \"%s\" is not a "
"positive integer, line %i",
param->value.c_str(), param->line);
buffer_size = tmp;
buffer_size = tmp * KILOBYTE;
if (buffer_size < MIN_BUFFER_SIZE) {
FormatWarning(config_domain, "buffer size %lu is too small, using %lu bytes instead",
(unsigned long)buffer_size,
(unsigned long)MIN_BUFFER_SIZE);
buffer_size = MIN_BUFFER_SIZE;
}
} else
buffer_size = DEFAULT_BUFFER_SIZE;
buffer_size *= 1024;
const unsigned buffered_chunks = buffer_size / CHUNK_SIZE;
if (buffered_chunks >= 1 << 15)
@@ -326,6 +340,19 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
"than 100 percent, line %i",
param->value.c_str(), param->line);
}
if (perc > 80) {
/* this upper limit should avoid deadlocks
which can occur because the DecoderThread
cannot ever fill the music buffer to
exactly 100%; a few chunks always need to
be available to generate silence in
Player::SendSilence() */
FormatError(config_domain,
"buffer_before_play is too large (%f%%), capping at 80%%; please fix your configuration",
perc);
perc = 80;
}
} else
perc = DEFAULT_BUFFER_BEFORE_PLAY;

@@ -59,14 +59,14 @@ mapper_init(AllocatedPath &&_playlist_dir)
}
void
mapper_finish()
mapper_finish() noexcept
{
}
#ifdef ENABLE_DATABASE
AllocatedPath
map_uri_fs(const char *uri)
map_uri_fs(const char *uri) noexcept
{
assert(uri != nullptr);
assert(*uri != '/');
@@ -86,7 +86,7 @@ map_uri_fs(const char *uri)
}
std::string
map_fs_to_utf8(Path path_fs)
map_fs_to_utf8(Path path_fs) noexcept
{
if (path_fs.IsAbsolute()) {
if (instance->storage == nullptr)
@@ -109,13 +109,13 @@ map_fs_to_utf8(Path path_fs)
#endif
const AllocatedPath &
map_spl_path()
map_spl_path() noexcept
{
return playlist_dir_fs;
}
AllocatedPath
map_spl_utf8_to_fs(const char *name)
map_spl_utf8_to_fs(const char *name) noexcept
{
if (playlist_dir_fs.IsNull())
return AllocatedPath::Null();

@@ -37,7 +37,7 @@ void
mapper_init(AllocatedPath &&playlist_dir);
void
mapper_finish();
mapper_finish() noexcept;
#ifdef ENABLE_DATABASE
@@ -48,7 +48,7 @@ mapper_finish();
*/
gcc_pure
AllocatedPath
map_uri_fs(const char *uri);
map_uri_fs(const char *uri) noexcept;
/**
* Maps a file system path (relative to the music directory or
@@ -60,7 +60,7 @@ map_uri_fs(const char *uri);
*/
gcc_pure
std::string
map_fs_to_utf8(Path path_fs);
map_fs_to_utf8(Path path_fs) noexcept;
#endif
@@ -69,7 +69,7 @@ map_fs_to_utf8(Path path_fs);
*/
gcc_const
const AllocatedPath &
map_spl_path();
map_spl_path() noexcept;
/**
* Maps a playlist name (without the ".m3u" suffix) to a file system
@@ -79,6 +79,6 @@ map_spl_path();
*/
gcc_pure
AllocatedPath
map_spl_utf8_to_fs(const char *name);
map_spl_utf8_to_fs(const char *name) noexcept;
#endif

@@ -23,19 +23,19 @@
#include <assert.h>
MusicBuffer::MusicBuffer(unsigned num_chunks)
MusicBuffer::MusicBuffer(unsigned num_chunks) noexcept
:buffer(num_chunks) {
}
MusicChunk *
MusicBuffer::Allocate()
MusicBuffer::Allocate() noexcept
{
const std::lock_guard<Mutex> protect(mutex);
return buffer.Allocate();
}
void
MusicBuffer::Return(MusicChunk *chunk)
MusicBuffer::Return(MusicChunk *chunk) noexcept
{
assert(chunk != nullptr);

@@ -41,7 +41,7 @@ public:
* @param num_chunks the number of #MusicChunk reserved in
* this buffer
*/
MusicBuffer(unsigned num_chunks);
MusicBuffer(unsigned num_chunks) noexcept;
#ifndef NDEBUG
/**
@@ -71,13 +71,13 @@ public:
* @return an empty chunk or nullptr if there are no chunks
* available
*/
MusicChunk *Allocate();
MusicChunk *Allocate() noexcept;
/**
* Returns a chunk to the buffer. It can be reused by
* Allocate() then.
*/
void Return(MusicChunk *chunk);
void Return(MusicChunk *chunk) noexcept;
};
#endif

@@ -31,7 +31,7 @@ MusicChunk::~MusicChunk()
#ifndef NDEBUG
bool
MusicChunk::CheckFormat(const AudioFormat other_format) const
MusicChunk::CheckFormat(const AudioFormat other_format) const noexcept
{
assert(other_format.IsValid());
@@ -41,7 +41,7 @@ MusicChunk::CheckFormat(const AudioFormat other_format) const
WritableBuffer<void>
MusicChunk::Write(const AudioFormat af,
SongTime data_time, uint16_t _bit_rate)
SongTime data_time, uint16_t _bit_rate) noexcept
{
assert(CheckFormat(af));
assert(length == 0 || audio_format.IsValid());
@@ -64,7 +64,7 @@ MusicChunk::Write(const AudioFormat af,
}
bool
MusicChunk::Expand(const AudioFormat af, size_t _length)
MusicChunk::Expand(const AudioFormat af, size_t _length) noexcept
{
const size_t frame_size = af.GetFrameSize();

@@ -111,7 +111,7 @@ struct MusicChunk {
* specified audio_format.
*/
gcc_pure
bool CheckFormat(AudioFormat audio_format) const;
bool CheckFormat(AudioFormat audio_format) const noexcept;
#endif
/**
@@ -127,7 +127,7 @@ struct MusicChunk {
*/
WritableBuffer<void> Write(AudioFormat af,
SongTime data_time,
uint16_t bit_rate);
uint16_t bit_rate) noexcept;
/**
* Increases the length of the chunk after the caller has written to
@@ -138,7 +138,7 @@ struct MusicChunk {
* @param length the number of bytes which were appended
* @return true if the chunk is full
*/
bool Expand(AudioFormat af, size_t length);
bool Expand(AudioFormat af, size_t length) noexcept;
};
#endif

@@ -25,7 +25,7 @@
#ifndef NDEBUG
bool
MusicPipe::Contains(const MusicChunk *chunk) const
MusicPipe::Contains(const MusicChunk *chunk) const noexcept
{
const std::lock_guard<Mutex> protect(mutex);

@@ -86,7 +86,7 @@ public:
* Checks if the specified chunk is enqueued in the music pipe.
*/
gcc_pure
bool Contains(const MusicChunk *chunk) const;
bool Contains(const MusicChunk *chunk) const noexcept;
#endif
/**

@@ -141,9 +141,9 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
void
Partition::OnGlobalEvent(unsigned mask)
{
if ((mask & TAG_MODIFIED) != 0)
TagModified();
if ((mask & SYNC_WITH_PLAYER) != 0)
SyncWithPlayer();
if ((mask & TAG_MODIFIED) != 0)
TagModified();
}

@@ -200,7 +200,6 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
*/
const Database *GetDatabase() const;
gcc_pure
const Database &GetDatabaseOrThrow() const;
/**

@@ -49,7 +49,6 @@ static std::map<std::string, unsigned> permission_passwords;
static unsigned permission_default;
gcc_pure
static unsigned
ParsePermission(const char *p)
{

@@ -335,7 +335,7 @@ try {
const auto path_fs = spl_map_to_fs(utf8path);
assert(!path_fs.IsNull());
FileOutputStream fos(path_fs, FileOutputStream::Mode::APPEND_EXISTING);
FileOutputStream fos(path_fs, FileOutputStream::Mode::APPEND_OR_CREATE);
if (fos.Tell() / (MPD_PATH_MAX + 1) >= playlist_max_length)
throw PlaylistError(PlaylistResult::TOO_LARGE,

@@ -24,7 +24,7 @@
#include <math.h>
float
ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const
ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const noexcept
{
float scale;

@@ -40,23 +40,23 @@ struct ReplayGainTuple {
}
gcc_pure
float CalculateScale(const ReplayGainConfig &config) const;
float CalculateScale(const ReplayGainConfig &config) const noexcept;
};
struct ReplayGainInfo {
ReplayGainTuple track, album;
constexpr bool IsDefined() const {
constexpr bool IsDefined() const noexcept {
return track.IsDefined() || album.IsDefined();
}
const ReplayGainTuple &Get(ReplayGainMode mode) const {
const ReplayGainTuple &Get(ReplayGainMode mode) const noexcept {
return mode == ReplayGainMode::ALBUM
? (album.IsDefined() ? album : track)
: (track.IsDefined() ? track : album);
}
void Clear() {
void Clear() noexcept {
track.Clear();
album.Clear();
}

@@ -25,7 +25,7 @@
#include <string.h>
const char *
ToString(ReplayGainMode mode)
ToString(ReplayGainMode mode) noexcept
{
switch (mode) {
case ReplayGainMode::AUTO:

@@ -36,13 +36,12 @@ enum class ReplayGainMode : uint8_t {
*/
gcc_pure
const char *
ToString(ReplayGainMode mode);
ToString(ReplayGainMode mode) noexcept;
/**
* Parse a string to a #ReplayGainMode. Throws std::runtime_error on
* error.
*/
gcc_pure
ReplayGainMode
FromString(const char *s);

@@ -25,9 +25,12 @@
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#include "util/ASCII.hxx"
#include "util/TimeParser.hxx"
#include "util/UriUtil.hxx"
#include "lib/icu/Collate.hxx"
#include <stdexcept>
#include <assert.h>
#include <stdlib.h>
@@ -36,7 +39,7 @@
#define LOCATE_TAG_ANY_KEY "any"
unsigned
locate_parse_type(const char *str)
locate_parse_type(const char *str) noexcept
{
if (StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY) ||
StringEqualsCaseASCII(str, LOCATE_TAG_FILE_KEY_OLD))
@@ -54,7 +57,6 @@ locate_parse_type(const char *str)
return tag_name_parse_i(str);
}
gcc_pure
static AllocatedString<>
ImportString(const char *p, bool fold_case)
{
@@ -75,7 +77,7 @@ SongFilter::Item::Item(unsigned _tag, time_t _time)
}
bool
SongFilter::Item::StringMatch(const char *s) const
SongFilter::Item::StringMatch(const char *s) const noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
@@ -94,14 +96,14 @@ SongFilter::Item::StringMatch(const char *s) const
}
bool
SongFilter::Item::Match(const TagItem &item) const
SongFilter::Item::Match(const TagItem &item) const noexcept
{
return (tag == LOCATE_TAG_ANY_TYPE || (unsigned)item.type == tag) &&
StringMatch(item.value);
}
bool
SongFilter::Item::Match(const Tag &_tag) const
SongFilter::Item::Match(const Tag &_tag) const noexcept
{
bool visited_types[TAG_NUM_OF_ITEM_TYPES];
std::fill_n(visited_types, size_t(TAG_NUM_OF_ITEM_TYPES), false);
@@ -137,7 +139,7 @@ SongFilter::Item::Match(const Tag &_tag) const
}
bool
SongFilter::Item::Match(const DetachedSong &song) const
SongFilter::Item::Match(const DetachedSong &song) const noexcept
{
if (tag == LOCATE_TAG_BASE_TYPE)
return uri_is_child_or_same(value.c_str(), song.GetURI());
@@ -152,7 +154,7 @@ SongFilter::Item::Match(const DetachedSong &song) const
}
bool
SongFilter::Item::Match(const LightSong &song) const
SongFilter::Item::Match(const LightSong &song) const noexcept
{
if (tag == LOCATE_TAG_BASE_TYPE) {
const auto uri = song.GetURI();
@@ -180,27 +182,9 @@ SongFilter::~SongFilter()
/* this destructor exists here just so it won't get inlined */
}
#if !defined(__GLIBC__) && !defined(WIN32)
/**
* Determine the time zone offset in a portable way.
*/
gcc_const
static time_t
GetTimeZoneOffset()
{
time_t t = 1234567890;
struct tm tm;
tm.tm_isdst = 0;
gmtime_r(&t, &tm);
return t - mktime(&tm);
}
#endif
gcc_pure
static time_t
ParseTimeStamp(const char *s)
ParseTimeStamp(const char *s) noexcept
{
assert(s != nullptr);
@@ -210,26 +194,13 @@ ParseTimeStamp(const char *s)
/* it's an integral UNIX time stamp */
return (time_t)value;
#ifdef WIN32
/* TODO: emulate strptime()? */
return 0;
#else
/* try ISO 8601 */
struct tm tm;
const char *end = strptime(s, "%FT%TZ", &tm);
if (end == nullptr || *end != 0)
try {
/* try ISO 8601 */
const auto t = ParseTimePoint(s, "%FT%TZ");
return std::chrono::system_clock::to_time_t(t);
} catch (const std::runtime_error &) {
return 0;
#ifdef __GLIBC__
/* timegm() is a GNU extension */
return timegm(&tm);
#else
tm.tm_isdst = 0;
return mktime(&tm) + GetTimeZoneOffset();
#endif /* !__GLIBC__ */
#endif /* !WIN32 */
}
}
bool
@@ -274,7 +245,7 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
}
bool
SongFilter::Match(const DetachedSong &song) const
SongFilter::Match(const DetachedSong &song) const noexcept
{
for (const auto &i : items)
if (!i.Match(song))
@@ -284,7 +255,7 @@ SongFilter::Match(const DetachedSong &song) const
}
bool
SongFilter::Match(const LightSong &song) const
SongFilter::Match(const LightSong &song) const noexcept
{
for (const auto &i : items)
if (!i.Match(song))
@@ -294,7 +265,7 @@ SongFilter::Match(const LightSong &song) const
}
bool
SongFilter::HasOtherThanBase() const
SongFilter::HasOtherThanBase() const noexcept
{
for (const auto &i : items)
if (i.GetTag() != LOCATE_TAG_BASE_TYPE)
@@ -304,7 +275,7 @@ SongFilter::HasOtherThanBase() const
}
const char *
SongFilter::GetBase() const
SongFilter::GetBase() const noexcept
{
for (const auto &i : items)
if (i.GetTag() == LOCATE_TAG_BASE_TYPE)

@@ -80,19 +80,19 @@ public:
}
gcc_pure gcc_nonnull(2)
bool StringMatch(const char *s) const;
bool StringMatch(const char *s) const noexcept;
gcc_pure
bool Match(const TagItem &tag_item) const;
bool Match(const TagItem &tag_item) const noexcept;
gcc_pure
bool Match(const Tag &tag) const;
bool Match(const Tag &tag) const noexcept;
gcc_pure
bool Match(const DetachedSong &song) const;
bool Match(const DetachedSong &song) const noexcept;
gcc_pure
bool Match(const LightSong &song) const;
bool Match(const LightSong &song) const noexcept;
};
private:
@@ -112,20 +112,20 @@ public:
bool Parse(ConstBuffer<const char *> args, bool fold_case=false);
gcc_pure
bool Match(const Tag &tag) const;
bool Match(const Tag &tag) const noexcept;
gcc_pure
bool Match(const DetachedSong &song) const;
bool Match(const DetachedSong &song) const noexcept;
gcc_pure
bool Match(const LightSong &song) const;
bool Match(const LightSong &song) const noexcept;
const std::list<Item> &GetItems() const {
const std::list<Item> &GetItems() const noexcept {
return items;
}
gcc_pure
bool IsEmpty() const {
bool IsEmpty() const noexcept {
return items.empty();
}
@@ -133,7 +133,7 @@ public:
* Is there at least one item with "fold case" enabled?
*/
gcc_pure
bool HasFoldCase() const {
bool HasFoldCase() const noexcept {
for (const auto &i : items)
if (i.GetFoldCase())
return true;
@@ -145,14 +145,14 @@ public:
* Does this filter contain constraints other than "base"?
*/
gcc_pure
bool HasOtherThanBase() const;
bool HasOtherThanBase() const noexcept;
/**
* Returns the "base" specification (if there is one) or
* nullptr.
*/
gcc_pure
const char *GetBase() const;
const char *GetBase() const noexcept;
};
/**
@@ -160,6 +160,6 @@ public:
*/
gcc_pure
unsigned
locate_parse_type(const char *str);
locate_parse_type(const char *str) noexcept;
#endif

@@ -50,7 +50,7 @@ StateFile::StateFile(AllocatedPath &&_path,
}
void
StateFile::RememberVersions()
StateFile::RememberVersions() noexcept
{
prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version();
@@ -59,7 +59,7 @@ StateFile::RememberVersions()
}
bool
StateFile::IsModified() const
StateFile::IsModified() const noexcept
{
return prev_volume_version != sw_volume_state_get_hash() ||
prev_output_version != audio_output_state_get_version() ||

@@ -67,14 +67,14 @@ private:
/**
* Save the current state versions for use with IsModified().
*/
void RememberVersions();
void RememberVersions() noexcept;
/**
* Check if MPD's state was modified since the last
* RememberVersions() call.
*/
gcc_pure
bool IsModified() const;
bool IsModified() const noexcept;
/* virtual methods from TimeoutMonitor */
void OnTimeout() override;

@@ -40,7 +40,7 @@
gcc_pure
static bool
CheckDecoderPlugin(const DecoderPlugin &plugin,
const char *suffix, const char *mime)
const char *suffix, const char *mime) noexcept
{
return (mime != nullptr && plugin.SupportsMimeType(mime)) ||
(suffix != nullptr && plugin.SupportsSuffix(suffix));

@@ -28,7 +28,7 @@
gcc_pure
static char *
FindSlash(char *p, size_t i)
FindSlash(char *p, size_t i) noexcept
{
for (; i > 0; --i)
if (p[i] == '/')
@@ -39,7 +39,7 @@ FindSlash(char *p, size_t i)
gcc_pure
static const char *
FindSuffix(const char *p, const char *i)
FindSuffix(const char *p, const char *i) noexcept
{
for (; i > p; --i) {
if (*i == '.')

@@ -93,7 +93,7 @@ public:
~Bzip2InputStream();
/* virtual methods from InputStream */
bool IsEOF() override;
bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override;
private:
@@ -205,7 +205,7 @@ Bzip2InputStream::Read(void *ptr, size_t length)
}
bool
Bzip2InputStream::IsEOF()
Bzip2InputStream::IsEOF() noexcept
{
return eof;
}

@@ -162,7 +162,7 @@ public:
}
/* virtual methods from InputStream */
bool IsEOF() override;
bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override;
};
@@ -213,7 +213,7 @@ Iso9660InputStream::Read(void *ptr, size_t read_size)
}
bool
Iso9660InputStream::IsEOF()
Iso9660InputStream::IsEOF() noexcept
{
return offset == size;
}

@@ -116,7 +116,7 @@ struct ZzipInputStream final : public InputStream {
}
/* virtual methods from InputStream */
bool IsEOF() override;
bool IsEOF() noexcept override;
size_t Read(void *ptr, size_t size) override;
void Seek(offset_type offset) override;
};
@@ -147,7 +147,7 @@ ZzipInputStream::Read(void *ptr, size_t read_size)
}
bool
ZzipInputStream::IsEOF()
ZzipInputStream::IsEOF() noexcept
{
return offset_type(zzip_tell(file)) == size;
}

@@ -28,7 +28,7 @@ const Domain client_domain("client");
#ifdef ENABLE_DATABASE
const Database *
Client::GetDatabase() const
Client::GetDatabase() const noexcept
{
return partition.instance.GetDatabase();
}
@@ -40,7 +40,7 @@ Client::GetDatabaseOrThrow() const
}
const Storage *
Client::GetStorage() const
Client::GetStorage() const noexcept
{
return partition.instance.storage;
}

@@ -160,7 +160,7 @@ public:
};
gcc_pure
bool IsSubscribed(const char *channel_name) const {
bool IsSubscribed(const char *channel_name) const noexcept {
return subscriptions.find(channel_name) != subscriptions.end();
}
@@ -186,16 +186,15 @@ public:
* Wrapper for Instance::GetDatabase().
*/
gcc_pure
const Database *GetDatabase() const;
const Database *GetDatabase() const noexcept;
/**
* Wrapper for Instance::GetDatabaseOrThrow().
*/
gcc_pure
const Database &GetDatabaseOrThrow() const;
gcc_pure
const Storage *GetStorage() const;
const Storage *GetStorage() const noexcept;
private:
/* virtual methods from class BufferedSocket */

@@ -23,14 +23,14 @@
gcc_const
static bool
valid_channel_char(const char ch)
valid_channel_char(const char ch) noexcept
{
return IsAlphaNumericASCII(ch) ||
ch == '_' || ch == '-' || ch == '.' || ch == ':';
}
bool
client_message_valid_channel_name(const char *name)
client_message_valid_channel_name(const char *name) noexcept
{
do {
if (!valid_channel_char(*name))

@@ -53,6 +53,6 @@ public:
gcc_pure
bool
client_message_valid_channel_name(const char *name);
client_message_valid_channel_name(const char *name) noexcept;
#endif

@@ -29,9 +29,32 @@
#include <assert.h>
#define GLIBCXX_490 20140422
#define GLIBCXX_491 20140716
#define GLIBCXX_492 20141030
#define GLIBCXX_492_Debian_9 20141220
#define GLIBCXX_493 20150626
#define GLIBCXX_494 20160803
#define GLIBCXX_49X_NDK_r13b 20150123
/* the big mess attempts to detect whether we're compiling with
libstdc++ 4.9.x; __GLIBCXX__ is a date tag and cannot be used to
check the major version; and just checking the compiler version
isn't enough, because somebody could use an old libstdc++ with
clang - SIGH! */
#if GCC_OLDER_THAN(5,0) || (defined(__GLIBCXX__) && \
(__GLIBCXX__ == GLIBCXX_490 || __GLIBCXX__ == GLIBCXX_491 || \
__GLIBCXX__ == GLIBCXX_492 || \
__GLIBCXX__ == GLIBCXX_492_Debian_9 || \
__GLIBCXX__ == GLIBCXX_493 || \
__GLIBCXX__ == GLIBCXX_494 || \
__GLIBCXX__ == GLIBCXX_49X_NDK_r13b))
#define GLIBCXX_49X
#endif
gcc_const
static enum ack
ToAck(PlaylistResult result)
ToAck(PlaylistResult result) noexcept
{
switch (result) {
case PlaylistResult::SUCCESS:
@@ -67,7 +90,7 @@ ToAck(PlaylistResult result)
#ifdef ENABLE_DATABASE
gcc_const
static enum ack
ToAck(DatabaseErrorCode code)
ToAck(DatabaseErrorCode code) noexcept
{
switch (code) {
case DatabaseErrorCode::DISABLED:
@@ -84,7 +107,7 @@ ToAck(DatabaseErrorCode code)
gcc_pure
static enum ack
ToAck(std::exception_ptr ep)
ToAck(std::exception_ptr ep) noexcept
{
try {
std::rethrow_exception(ep);
@@ -100,13 +123,13 @@ ToAck(std::exception_ptr ep)
return ACK_ERROR_SYSTEM;
} catch (const std::invalid_argument &e) {
return ACK_ERROR_ARG;
#if defined(__GLIBCXX__) && __GLIBCXX__ < 20151204
#ifdef GLIBCXX_49X
} catch (const std::exception &e) {
#else
} catch (...) {
#endif
try {
#if defined(__GLIBCXX__) && __GLIBCXX__ < 20151204
#ifdef GLIBCXX_49X
/* workaround for g++ 4.x: no overload for
rethrow_exception(exception_ptr) */
std::rethrow_if_nested(e);

@@ -44,7 +44,7 @@
gcc_pure
static bool
SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
SkipNameFS(PathTraitsFS::const_pointer_type name_fs) noexcept
{
return name_fs[0] == '.' &&
(name_fs[1] == 0 ||
@@ -53,7 +53,7 @@ SkipNameFS(PathTraitsFS::const_pointer_type name_fs)
gcc_pure
static bool
skip_path(Path name_fs)
skip_path(Path name_fs) noexcept
{
return name_fs.HasNewline();
}
@@ -107,7 +107,7 @@ handle_listfiles_local(Response &r, Path path_fs)
gcc_pure
static bool
IsValidName(const char *p)
IsValidName(const char *p) noexcept
{
if (!IsAlphaASCII(*p))
return false;
@@ -123,7 +123,7 @@ IsValidName(const char *p)
gcc_pure
static bool
IsValidValue(const char *p)
IsValidValue(const char *p) noexcept
{
while (*p) {
const char ch = *p++;

@@ -30,7 +30,7 @@
#include <string>
bool
neighbor_commands_available(const Instance &instance)
neighbor_commands_available(const Instance &instance) noexcept
{
return instance.neighbors != nullptr;
}

@@ -30,7 +30,7 @@ class Response;
gcc_pure
bool
neighbor_commands_available(const Instance &instance);
neighbor_commands_available(const Instance &instance) noexcept;
CommandResult
handle_listneighbors(Client &client, Request request, Response &response);

@@ -30,6 +30,7 @@
#include "Instance.hxx"
#include "Idle.hxx"
#include "AudioFormat.hxx"
#include "util/StringBuffer.hxx"
#include "util/ScopeExit.hxx"
#include "util/Exception.hxx"
@@ -171,13 +172,9 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
r.Format("duration: %1.3f\n",
player_status.total_time.ToDoubleS());
if (player_status.audio_format.IsDefined()) {
struct audio_format_string af_string;
if (player_status.audio_format.IsDefined())
r.Format(COMMAND_STATUS_AUDIO ": %s\n",
audio_format_to_string(player_status.audio_format,
&af_string));
}
ToString(player_status.audio_format).c_str());
}
#ifdef ENABLE_DATABASE

@@ -39,7 +39,7 @@
#include "util/ConstBuffer.hxx"
bool
playlist_commands_available()
playlist_commands_available() noexcept
{
return !map_spl_path().IsNull();
}

@@ -29,7 +29,7 @@ class Response;
gcc_const
bool
playlist_commands_available();
playlist_commands_available() noexcept;
CommandResult
handle_save(Client &client, Request request, Response &response);

@@ -45,7 +45,7 @@
gcc_pure
static bool
skip_path(const char *name_utf8)
skip_path(const char *name_utf8) noexcept
{
return strchr(name_utf8, '\n') != nullptr;
}

@@ -68,7 +68,7 @@ ConfigBlock::~ConfigBlock()
}
const BlockParam *
ConfigBlock::GetBlockParam(const char *name) const
ConfigBlock::GetBlockParam(const char *name) const noexcept
{
for (const auto &i : block_params) {
if (i.name == name) {
@@ -81,7 +81,8 @@ ConfigBlock::GetBlockParam(const char *name) const
}
const char *
ConfigBlock::GetBlockValue(const char *name, const char *default_value) const
ConfigBlock::GetBlockValue(const char *name,
const char *default_value) const noexcept
{
const BlockParam *bp = GetBlockParam(name);
if (bp == nullptr)
@@ -128,7 +129,6 @@ ConfigBlock::GetBlockValue(const char *name, unsigned default_value) const
return bp->GetUnsignedValue();
}
gcc_pure
bool
ConfigBlock::GetBlockValue(const char *name, bool default_value) const
{

@@ -44,13 +44,10 @@ struct BlockParam {
BlockParam(const char *_name, const char *_value, int _line=-1)
:name(_name), value(_value), line(_line), used(false) {}
gcc_pure
int GetIntValue() const;
gcc_pure
unsigned GetUnsignedValue() const;
gcc_pure
bool GetBoolValue() const;
};
@@ -101,11 +98,11 @@ struct ConfigBlock {
}
gcc_nonnull_all gcc_pure
const BlockParam *GetBlockParam(const char *_name) const;
const BlockParam *GetBlockParam(const char *_name) const noexcept;
gcc_pure
const char *GetBlockValue(const char *name,
const char *default_value=nullptr) const;
const char *default_value=nullptr) const noexcept;
/**
* Same as config_get_path(), but looks up the setting in the
@@ -116,13 +113,10 @@ struct ConfigBlock {
AllocatedPath GetPath(const char *name,
const char *default_value=nullptr) const;
gcc_pure
int GetBlockValue(const char *name, int default_value) const;
gcc_pure
unsigned GetBlockValue(const char *name, unsigned default_value) const;
gcc_pure
bool GetBlockValue(const char *name, bool default_value) const;
};

@@ -75,7 +75,7 @@ void config_global_check(void)
}
const ConfigParam *
config_get_param(ConfigOption option)
config_get_param(ConfigOption option) noexcept
{
auto *param = config_data.params[unsigned(option)];
if (param != nullptr)
@@ -84,7 +84,7 @@ config_get_param(ConfigOption option)
}
const ConfigBlock *
config_get_block(ConfigBlockOption option)
config_get_block(ConfigBlockOption option) noexcept
{
ConfigBlock *block = config_data.blocks[unsigned(option)];
if (block != nullptr)
@@ -110,7 +110,7 @@ config_find_block(ConfigBlockOption option, const char *key, const char *value)
}
const char *
config_get_string(ConfigOption option, const char *default_value)
config_get_string(ConfigOption option, const char *default_value) noexcept
{
const auto *param = config_get_param(option);

@@ -48,11 +48,11 @@ ReadConfigFile(Path path);
gcc_pure
const ConfigParam *
config_get_param(enum ConfigOption option);
config_get_param(enum ConfigOption option) noexcept;
gcc_pure
const ConfigBlock *
config_get_block(enum ConfigBlockOption option);
config_get_block(enum ConfigBlockOption option) noexcept;
/**
* Find a block with a matching attribute.
@@ -61,20 +61,12 @@ config_get_block(enum ConfigBlockOption option);
* @param key the attribute name
* @param value the expected attribute value
*/
gcc_pure
const ConfigBlock *
config_find_block(ConfigBlockOption option, const char *key, const char *value);
/* Note on gcc_pure: Some of the functions declared pure are not
really pure in strict sense. They have side effect such that they
validate parameter's value and signal an error if it's invalid.
However, if the argument was already validated or we don't care
about the argument at all, this may be ignored so in the end, we
should be fine with calling those functions pure. */
gcc_pure
const char *
config_get_string(enum ConfigOption option, const char *default_value=nullptr);
config_get_string(enum ConfigOption option,
const char *default_value=nullptr) noexcept;
/**
* Returns an optional configuration variable which contains an
@@ -86,11 +78,9 @@ config_get_string(enum ConfigOption option, const char *default_value=nullptr);
AllocatedPath
config_get_path(enum ConfigOption option);
gcc_pure
unsigned
config_get_unsigned(enum ConfigOption option, unsigned default_value);
gcc_pure
static inline std::chrono::steady_clock::duration
config_get_unsigned(ConfigOption option,
std::chrono::steady_clock::duration default_value)
@@ -100,11 +90,9 @@ config_get_unsigned(ConfigOption option,
return std::chrono::steady_clock::duration(u);
}
gcc_pure
unsigned
config_get_positive(enum ConfigOption option, unsigned default_value);
gcc_pure
static inline std::chrono::steady_clock::duration
config_get_positive(ConfigOption option,
std::chrono::steady_clock::duration default_value)
@@ -114,7 +102,6 @@ config_get_positive(ConfigOption option,
return std::chrono::steady_clock::duration(u);
}
gcc_pure
bool config_get_bool(enum ConfigOption option, bool default_value);
#endif

@@ -102,13 +102,13 @@ enum class ConfigBlockOption {
*/
gcc_pure
enum ConfigOption
ParseConfigOptionName(const char *name);
ParseConfigOptionName(const char *name) noexcept;
/**
* @return #ConfigOption::MAX if not found
*/
gcc_pure
enum ConfigBlockOption
ParseConfigBlockOptionName(const char *name);
ParseConfigBlockOptionName(const char *name) noexcept;
#endif

@@ -101,7 +101,7 @@ static_assert(n_config_block_templates == unsigned(ConfigBlockOption::MAX),
gcc_pure
static inline unsigned
ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
const char *name)
const char *name) noexcept
{
unsigned i = 0;
for (; i < count; ++i)
@@ -112,7 +112,7 @@ ParseConfigTemplateName(const ConfigTemplate templates[], unsigned count,
}
ConfigOption
ParseConfigOptionName(const char *name)
ParseConfigOptionName(const char *name) noexcept
{
return ConfigOption(ParseConfigTemplateName(config_param_templates,
n_config_param_templates,
@@ -120,7 +120,7 @@ ParseConfigOptionName(const char *name)
}
ConfigBlockOption
ParseConfigBlockOptionName(const char *name)
ParseConfigBlockOptionName(const char *name) noexcept
{
return ConfigBlockOption(ParseConfigTemplateName(config_block_templates,
n_config_block_templates,

@@ -71,7 +71,6 @@ struct ConfigParam {
*
* Throws #std::runtime_error on error.
*/
gcc_pure
AllocatedPath GetPath() const;
};

@@ -62,7 +62,7 @@ Print(Response &r, TagType group, const TagCountMap &m)
}
}
static bool
static void
stats_visitor_song(SearchStats &stats, const LightSong &song)
{
stats.n_songs++;
@@ -70,8 +70,6 @@ stats_visitor_song(SearchStats &stats, const LightSong &song)
const auto duration = song.GetDuration();
if (!duration.IsNegative())
stats.total_duration += duration;
return true;
}
static bool
@@ -94,7 +92,7 @@ CollectGroupCounts(TagCountMap &map, TagType group, const Tag &tag)
return found;
}
static bool
static void
GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
{
assert(song.tag != nullptr);
@@ -103,8 +101,6 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
if (!CollectGroupCounts(map, group, tag) && group == TAG_ALBUM_ARTIST)
/* fall back to "Artist" if no "AlbumArtist" was found */
CollectGroupCounts(map, TAG_ARTIST, tag);
return true;
}
void

@@ -37,5 +37,10 @@ DatabaseGlobalInit(EventLoop &loop, DatabaseListener &listener,
throw FormatRuntimeError("No such database plugin: %s",
plugin_name);
return plugin->create(loop, listener, block);
try {
return plugin->create(loop, listener, block);
} catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize database plugin '%s'",
plugin_name));
}
}

@@ -45,7 +45,7 @@ extern ThreadId db_mutex_holder;
*/
gcc_pure
static inline bool
holding_db_lock(void)
holding_db_lock() noexcept
{
return db_mutex_holder.IsInside();
}

@@ -27,13 +27,12 @@
#include <functional>
static bool
static void
AddSong(const Storage &storage, const char *playlist_path_utf8,
const LightSong &song)
{
spl_append_song(playlist_path_utf8,
DatabaseDetachSong(storage, song));
return true;
}
void

@@ -49,16 +49,14 @@ PrintDirectoryURI(Response &r, bool base, const LightDirectory &directory)
ApplyBaseFlag(directory.GetPath(), base));
}
static bool
static void
PrintDirectoryBrief(Response &r, bool base, const LightDirectory &directory)
{
if (!directory.IsRoot())
PrintDirectoryURI(r, base, directory);
return true;
}
static bool
static void
PrintDirectoryFull(Response &r, bool base, const LightDirectory &directory)
{
if (!directory.IsRoot()) {
@@ -67,8 +65,6 @@ PrintDirectoryFull(Response &r, bool base, const LightDirectory &directory)
if (directory.mtime > 0)
time_print(r, "Last-Modified", directory.mtime);
}
return true;
}
static void
@@ -96,7 +92,7 @@ print_playlist_in_directory(Response &r, bool base,
directory->GetPath(), name_utf8);
}
static bool
static void
PrintSongBrief(Response &r, Partition &partition,
bool base, const LightSong &song)
{
@@ -106,11 +102,9 @@ PrintSongBrief(Response &r, Partition &partition,
/* this song file has an embedded CUE sheet */
print_playlist_in_directory(r, base,
song.directory, song.uri);
return true;
}
static bool
static void
PrintSongFull(Response &r, Partition &partition,
bool base, const LightSong &song)
{
@@ -120,21 +114,18 @@ PrintSongFull(Response &r, Partition &partition,
/* this song file has an embedded CUE sheet */
print_playlist_in_directory(r, base,
song.directory, song.uri);
return true;
}
static bool
static void
PrintPlaylistBrief(Response &r, bool base,
const PlaylistInfo &playlist,
const LightDirectory &directory)
{
print_playlist_in_directory(r, base,
&directory, playlist.name.c_str());
return true;
}
static bool
static void
PrintPlaylistFull(Response &r, bool base,
const PlaylistInfo &playlist,
const LightDirectory &directory)
@@ -144,8 +135,6 @@ PrintPlaylistFull(Response &r, bool base,
if (playlist.mtime > 0)
time_print(r, "Last-Modified", playlist.mtime);
return true;
}
void
@@ -191,15 +180,13 @@ db_selection_print(Response &r, Partition &partition,
0, std::numeric_limits<int>::max());
}
static bool
static void
PrintSongURIVisitor(Response &r, Partition &partition, const LightSong &song)
{
song_print_uri(r, partition, song);
return true;
}
static bool
static void
PrintUniqueTag(Response &r, TagType tag_type,
const Tag &tag)
{
@@ -211,8 +198,6 @@ PrintUniqueTag(Response &r, TagType tag_type,
if (item.type != tag_type)
r.Format("%s: %s\n",
tag_item_names[item.type], item.value);
return true;
}
void

@@ -27,14 +27,13 @@
#include <functional>
static bool
static void
AddToQueue(Partition &partition, const LightSong &song)
{
const Storage &storage = *partition.instance.storage;
partition.playlist.AppendSong(partition.pc,
DatabaseDetachSong(storage,
song));
return true;
}
void

@@ -31,7 +31,6 @@ class DetachedSong;
* "Detach" the #Song object, i.e. convert it to a #DetachedSong
* instance.
*/
gcc_pure
DetachedSong
DatabaseDetachSong(const Storage &storage, const LightSong &song);

@@ -67,15 +67,13 @@ StatsVisitTag(DatabaseStats &stats, StringSet &artists, StringSet &albums,
}
}
static bool
static void
StatsVisitSong(DatabaseStats &stats, StringSet &artists, StringSet &albums,
const LightSong &song)
{
++stats.song_count;
StatsVisitTag(stats, artists, albums, *song.tag);
return true;
}
DatabaseStats

@@ -21,7 +21,7 @@
#include "tag/Tag.hxx"
SignedSongTime
LightSong::GetDuration() const
LightSong::GetDuration() const noexcept
{
SongTime a = start_time, b = end_time;
if (!b.IsPositive()) {

@@ -76,7 +76,7 @@ struct LightSong {
SongTime end_time;
gcc_pure
std::string GetURI() const {
std::string GetURI() const noexcept {
if (directory == nullptr)
return std::string(uri);
@@ -87,7 +87,7 @@ struct LightSong {
}
gcc_pure
SignedSongTime GetDuration() const;
SignedSongTime GetDuration() const noexcept;
};
#endif

@@ -26,7 +26,7 @@
#include <assert.h>
PlaylistVector::iterator
PlaylistVector::find(const char *name)
PlaylistVector::find(const char *name) noexcept
{
assert(holding_db_lock());
assert(name != nullptr);

@@ -31,7 +31,7 @@ protected:
* Caller must lock the #db_mutex.
*/
gcc_pure
iterator find(const char *name);
iterator find(const char *name) noexcept;
public:
using std::list<PlaylistInfo>::empty;

@@ -38,7 +38,7 @@ const DatabasePlugin *const database_plugins[] = {
};
const DatabasePlugin *
GetDatabasePluginByName(const char *name)
GetDatabasePluginByName(const char *name) noexcept
{
for (auto i = database_plugins; *i != nullptr; ++i)
if (strcmp((*i)->name, name) == 0)

@@ -32,6 +32,6 @@ extern const DatabasePlugin *const database_plugins[];
gcc_pure
const DatabasePlugin *
GetDatabasePluginByName(const char *name);
GetDatabasePluginByName(const char *name) noexcept;
#endif

@@ -34,19 +34,19 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
}
bool
DatabaseSelection::IsEmpty() const
DatabaseSelection::IsEmpty() const noexcept
{
return uri.empty() && (filter == nullptr || filter->IsEmpty());
}
bool
DatabaseSelection::HasOtherThanBase() const
DatabaseSelection::HasOtherThanBase() const noexcept
{
return filter != nullptr && filter->HasOtherThanBase();
}
bool
DatabaseSelection::Match(const LightSong &song) const
DatabaseSelection::Match(const LightSong &song) const noexcept
{
return filter == nullptr || filter->Match(song);
}

@@ -45,16 +45,16 @@ struct DatabaseSelection {
const SongFilter *_filter=nullptr);
gcc_pure
bool IsEmpty() const;
bool IsEmpty() const noexcept;
/**
* Does this selection contain constraints other than "base"?
*/
gcc_pure
bool HasOtherThanBase() const;
bool HasOtherThanBase() const noexcept;
gcc_pure
bool Match(const LightSong &song) const;
bool Match(const LightSong &song) const noexcept;
};
#endif

@@ -34,6 +34,7 @@
#include "tag/TagBuilder.hxx"
#include "tag/Tag.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
#include "protocol/Ack.hxx"
#include "event/SocketMonitor.hxx"
#include "event/IdleMonitor.hxx"
@@ -46,7 +47,7 @@
#include <string>
#include <list>
class LibmpdclientError final : std::runtime_error {
class LibmpdclientError final : public std::runtime_error {
enum mpd_error code;
public:
@@ -108,8 +109,8 @@ public:
static Database *Create(EventLoop &loop, DatabaseListener &listener,
const ConfigBlock &block);
virtual void Open() override;
virtual void Close() override;
void Open() override;
void Close() override;
const LightSong *GetSong(const char *uri_utf8) const override;
void ReturnSong(const LightSong *song) const override;
@@ -126,7 +127,7 @@ public:
unsigned Update(const char *uri_utf8, bool discard) override;
virtual time_t GetUpdateStamp() const override {
time_t GetUpdateStamp() const override {
return update_stamp;
}
@@ -138,10 +139,10 @@ private:
void Disconnect();
/* virtual methods from SocketMonitor */
virtual bool OnSocketReady(unsigned flags) override;
bool OnSocketReady(unsigned flags) override;
/* virtual methods from IdleMonitor */
virtual void OnIdle() override;
void OnIdle() override;
};
static constexpr struct {
@@ -215,7 +216,7 @@ ProxySong::ProxySong(const mpd_song *song)
gcc_const
static enum mpd_tag_type
Convert(TagType tag_type)
Convert(TagType tag_type) noexcept
{
for (auto i = &tag_table[0]; i->d != TAG_NUM_OF_ITEM_TYPES; ++i)
if (i->d == tag_type)
@@ -345,9 +346,15 @@ ProxyDatabase::Create(EventLoop &loop, DatabaseListener &listener,
void
ProxyDatabase::Open()
{
Connect();
update_stamp = 0;
try {
Connect();
} catch (const std::runtime_error &error) {
/* this error is non-fatal, because this plugin will
attempt to reconnect again automatically */
LogError(error);
}
}
void
@@ -371,7 +378,10 @@ ProxyDatabase::Connect()
mpd_connection_free(connection);
connection = nullptr;
throw;
std::throw_with_nested(host.empty()
? std::runtime_error("Failed to connect to remote MPD")
: FormatRuntimeError("Failed to connect to remote MPD '%s'",
host.c_str()));
}
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
@@ -564,7 +574,7 @@ Visit(struct mpd_connection *connection,
gcc_pure
static bool
Match(const SongFilter *filter, const LightSong &song)
Match(const SongFilter *filter, const LightSong &song) noexcept
{
return filter == nullptr || filter->Match(song);
}
@@ -707,7 +717,7 @@ SearchSongs(struct mpd_connection *connection,
*/
gcc_pure
static bool
ServerSupportsSearchBase(const struct mpd_connection *connection)
ServerSupportsSearchBase(const struct mpd_connection *connection) noexcept
{
#if LIBMPDCLIENT_CHECK_VERSION(2,9,0)
return mpd_connection_cmp_server_version(connection, 0, 18, 0) >= 0;

@@ -65,7 +65,7 @@ Directory::Delete()
}
const char *
Directory::GetName() const
Directory::GetName() const noexcept
{
assert(!IsRoot());
@@ -89,7 +89,7 @@ Directory::CreateChild(const char *name_utf8)
}
const Directory *
Directory::FindChild(const char *name) const
Directory::FindChild(const char *name) const noexcept
{
assert(holding_db_lock());
@@ -101,7 +101,7 @@ Directory::FindChild(const char *name) const
}
void
Directory::PruneEmpty()
Directory::PruneEmpty() noexcept
{
assert(holding_db_lock());
@@ -118,7 +118,7 @@ Directory::PruneEmpty()
}
Directory::LookupResult
Directory::LookupDirectory(const char *uri)
Directory::LookupDirectory(const char *uri) noexcept
{
assert(holding_db_lock());
assert(uri != nullptr);
@@ -173,7 +173,7 @@ Directory::AddSong(Song *song)
}
void
Directory::RemoveSong(Song *song)
Directory::RemoveSong(Song *song) noexcept
{
assert(holding_db_lock());
assert(song != nullptr);
@@ -183,7 +183,7 @@ Directory::RemoveSong(Song *song)
}
const Song *
Directory::FindSong(const char *name_utf8) const
Directory::FindSong(const char *name_utf8) const noexcept
{
assert(holding_db_lock());
assert(name_utf8 != nullptr);
@@ -200,13 +200,13 @@ Directory::FindSong(const char *name_utf8) const
gcc_pure
static bool
directory_cmp(const Directory &a, const Directory &b)
directory_cmp(const Directory &a, const Directory &b) noexcept
{
return IcuCollate(a.path.c_str(), b.path.c_str()) < 0;
}
void
Directory::Sort()
Directory::Sort() noexcept
{
assert(holding_db_lock());
@@ -261,7 +261,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
}
LightDirectory
Directory::Export() const
Directory::Export() const noexcept
{
return LightDirectory(GetPath(), mtime);
}

@@ -86,7 +86,7 @@ struct Directory {
Directory *parent;
time_t mtime;
unsigned inode, device;
uint64_t inode, device;
std::string path;
@@ -134,10 +134,10 @@ public:
* Caller must lock the #db_mutex.
*/
gcc_pure
const Directory *FindChild(const char *name) const;
const Directory *FindChild(const char *name) const noexcept;
gcc_pure
Directory *FindChild(const char *name) {
Directory *FindChild(const char *name) noexcept {
const Directory *cthis = this;
return const_cast<Directory *>(cthis->FindChild(name));
}
@@ -177,10 +177,10 @@ public:
* @return the Directory, or nullptr if none was found
*/
gcc_pure
LookupResult LookupDirectory(const char *uri);
LookupResult LookupDirectory(const char *uri) noexcept;
gcc_pure
bool IsEmpty() const {
bool IsEmpty() const noexcept {
return children.empty() &&
songs.empty() &&
playlists.empty();
@@ -195,13 +195,13 @@ public:
* Returns the base name of the directory.
*/
gcc_pure
const char *GetName() const;
const char *GetName() const noexcept;
/**
* Is this the root directory of the music database?
*/
gcc_pure
bool IsRoot() const {
bool IsRoot() const noexcept {
return parent == nullptr;
}
@@ -229,10 +229,10 @@ public:
* Caller must lock the #db_mutex.
*/
gcc_pure
const Song *FindSong(const char *name_utf8) const;
const Song *FindSong(const char *name_utf8) const noexcept;
gcc_pure
Song *FindSong(const char *name_utf8) {
Song *FindSong(const char *name_utf8) noexcept {
const Directory *cthis = this;
return const_cast<Song *>(cthis->FindSong(name_utf8));
}
@@ -248,19 +248,19 @@ public:
* invalidates the song object, because the "parent" attribute becomes
* stale), but does not free it.
*/
void RemoveSong(Song *song);
void RemoveSong(Song *song) noexcept;
/**
* Caller must lock the #db_mutex.
*/
void PruneEmpty();
void PruneEmpty() noexcept;
/**
* Sort all directory entries recursively.
*
* Caller must lock the #db_mutex.
*/
void Sort();
void Sort() noexcept;
/**
* Caller must lock #db_mutex.
@@ -270,7 +270,7 @@ public:
VisitPlaylist visit_playlist) const;
gcc_pure
LightDirectory Export() const;
LightDirectory Export() const noexcept;
};
#endif

@@ -40,7 +40,7 @@
gcc_const
static const char *
DeviceToTypeString(unsigned device)
DeviceToTypeString(unsigned device) noexcept
{
switch (device) {
case DEVICE_INARCHIVE:
@@ -56,7 +56,7 @@ DeviceToTypeString(unsigned device)
gcc_pure
static unsigned
ParseTypeString(const char *type)
ParseTypeString(const char *type) noexcept
{
if (strcmp(type, "archive") == 0)
return DEVICE_INARCHIVE;

@@ -25,6 +25,13 @@
#include "db/Interface.hxx"
#include "fs/Traits.hxx"
#ifdef _LIBCPP_VERSION
/* workaround for "error: incomplete type 'PlaylistInfo' used in type
trait expression" with libc++ version 3900 (from Android NDK
r13b) */
#include "db/PlaylistInfo.hxx"
#endif
#include <string>
struct PrefixedLightDirectory : LightDirectory {

@@ -108,8 +108,8 @@ public:
bool Unmount(const char *uri);
/* virtual methods from class Database */
virtual void Open() override;
virtual void Close() override;
void Open() override;
void Close() override;
const LightSong *GetSong(const char *uri_utf8) const override;
void ReturnSong(const LightSong *song) const override;
@@ -125,7 +125,7 @@ public:
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
virtual time_t GetUpdateStamp() const override {
time_t GetUpdateStamp() const override {
return mtime;
}

@@ -77,7 +77,7 @@ Song::Free()
}
std::string
Song::GetURI() const
Song::GetURI() const noexcept
{
assert(*uri);
@@ -96,7 +96,7 @@ Song::GetURI() const
}
LightSong
Song::Export() const
Song::Export() const noexcept
{
LightSong dest;
dest.directory = parent->IsRoot()

@@ -123,10 +123,10 @@ struct Song {
* location within the music directory.
*/
gcc_pure
std::string GetURI() const;
std::string GetURI() const noexcept;
gcc_pure
LightSong Export() const;
LightSong Export() const noexcept;
};
typedef boost::intrusive::list<Song,

@@ -26,7 +26,7 @@
#include <stdlib.h>
static int
compare_utf8_string(const char *a, const char *b)
compare_utf8_string(const char *a, const char *b) noexcept
{
if (a == nullptr)
return b == nullptr ? 0 : -1;
@@ -42,8 +42,7 @@ compare_utf8_string(const char *a, const char *b)
* nullptr.
*/
static int
compare_string_tag_item(const Tag &a, const Tag &b,
TagType type)
compare_string_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
{
return compare_utf8_string(a.GetValue(type),
b.GetValue(type));
@@ -54,7 +53,7 @@ compare_string_tag_item(const Tag &a, const Tag &b,
* (e.g. disc or track number). Either one may be nullptr.
*/
static int
compare_number_string(const char *a, const char *b)
compare_number_string(const char *a, const char *b) noexcept
{
long ai = a == nullptr ? 0 : strtol(a, nullptr, 10);
long bi = b == nullptr ? 0 : strtol(b, nullptr, 10);
@@ -69,7 +68,7 @@ compare_number_string(const char *a, const char *b)
}
static int
compare_tag_item(const Tag &a, const Tag &b, TagType type)
compare_tag_item(const Tag &a, const Tag &b, TagType type) noexcept
{
return compare_number_string(a.GetValue(type),
b.GetValue(type));
@@ -78,7 +77,7 @@ compare_tag_item(const Tag &a, const Tag &b, TagType type)
/* Only used for sorting/searchin a songvec, not general purpose compares */
gcc_pure
static bool
song_cmp(const Song &a, const Song &b)
song_cmp(const Song &a, const Song &b) noexcept
{
int ret;
@@ -102,7 +101,7 @@ song_cmp(const Song &a, const Song &b)
}
void
song_list_sort(SongList &songs)
song_list_sort(SongList &songs) noexcept
{
songs.sort(song_cmp);
}

@@ -23,6 +23,6 @@
#include "Song.hxx"
void
song_list_sort(SongList &songs);
song_list_sort(SongList &songs) noexcept;
#endif

@@ -39,7 +39,7 @@ UPnPDirContent::~UPnPDirContent()
gcc_pure
static UPnPDirObject::ItemClass
ParseItemClass(StringView name)
ParseItemClass(StringView name) noexcept
{
if (name.EqualsLiteral("object.item.audioItem.musicTrack"))
return UPnPDirObject::ItemClass::MUSIC;
@@ -51,7 +51,7 @@ ParseItemClass(StringView name)
gcc_pure
static SignedSongTime
ParseDuration(const char *duration)
ParseDuration(const char *duration) noexcept
{
char *endptr;
@@ -81,7 +81,7 @@ ParseDuration(const char *duration)
*/
gcc_pure
static std::string &&
TitleToPathSegment(std::string &&s)
TitleToPathSegment(std::string &&s) noexcept
{
std::replace(s.begin(), s.end(), '/', '_');
return std::move(s);
@@ -124,7 +124,7 @@ public:
}
protected:
virtual void StartElement(const XML_Char *name, const XML_Char **attrs)
void StartElement(const XML_Char *name, const XML_Char **attrs) override
{
if (object.type != UPnPDirObject::Type::UNKNOWN &&
tag_type == TAG_NUM_OF_ITEM_TYPES) {
@@ -188,7 +188,7 @@ protected:
}
}
virtual void EndElement(const XML_Char *name)
void EndElement(const XML_Char *name) override
{
if (tag_type != TAG_NUM_OF_ITEM_TYPES) {
assert(object.type != UPnPDirObject::Type::UNKNOWN);
@@ -212,7 +212,7 @@ protected:
state = NONE;
}
virtual void CharacterData(const XML_Char *s, int len)
void CharacterData(const XML_Char *s, int len) override
{
if (tag_type != TAG_NUM_OF_ITEM_TYPES) {
assert(object.type != UPnPDirObject::Type::UNKNOWN);

@@ -40,7 +40,7 @@ public:
~UPnPDirContent();
gcc_pure
UPnPDirObject *FindObject(const char *name) {
UPnPDirObject *FindObject(const char *name) noexcept {
for (auto &o : objects)
if (o.name == name)
return &o;

@@ -77,9 +77,9 @@ public:
static Database *Create(EventLoop &loop, DatabaseListener &listener,
const ConfigBlock &block);
virtual void Open() override;
virtual void Close() override;
virtual const LightSong *GetSong(const char *uri_utf8) const override;
void Open() override;
void Close() override;
const LightSong *GetSong(const char *uri_utf8) const override;
void ReturnSong(const LightSong *song) const override;
void Visit(const DatabaseSelection &selection,
@@ -180,7 +180,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const
const LightSong *
UpnpDatabase::GetSong(const char *uri) const
{
auto vpath = stringToTokens(uri, "/", true);
auto vpath = stringToTokens(uri, '/');
if (vpath.size() < 2)
throw DatabaseError(DatabaseErrorCode::NOT_FOUND,
"No such song");
@@ -577,7 +577,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
VisitSong visit_song,
VisitPlaylist visit_playlist) const
{
auto vpath = stringToTokens(selection.uri, "/", true);
auto vpath = stringToTokens(selection.uri, '/');
if (vpath.empty()) {
for (const auto &server : discovery->GetDirectories()) {
if (visit_directory) {

@@ -56,7 +56,7 @@ InotifyQueue::OnTimeout()
gcc_pure
static bool
path_in(const char *path, const char *possible_parent)
path_in(const char *path, const char *possible_parent) noexcept
{
if (StringIsEmpty(path))
return true;

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