Compare commits

...

145 Commits

Author SHA1 Message Date
Max Kellermann
f6125f0c35 release v0.21.11 2019-07-03 15:16:27 +02:00
Max Kellermann
f780ac418a output/alsa: log when generating silence due to slow decoder
MPD used to do that when this code lived in the player thread, but it
was removed by commit 98a7c62d7a4f716d90af6d78e18d1a3b10bc54b3; and
the replacement code in the ALSA output plugin didn't have it.
2019-06-28 18:15:30 +02:00
Max Kellermann
61a72a5d13 output/alsa: schedule a timer to generate silence
Without this timer, DispatchSockets() may disable the
MultiSocketMonitor and if Play() doesn't get called soon, it never
gets a chance to generate silence.  However if Play() gets called,
generating silence isn't necessary anymore...

Resulting from this misdesign (added by commit ccafe3f3cf in 0.21.3),
the silence generator didn't work reliably.
2019-06-28 18:04:49 +02:00
Max Kellermann
0c0a354753 output/alsa: add a new flag "waiting" for xrun management
In DispatchSockets(), when there was not enough data, but enough for
current playback, the method would disable the "active" flag so the
next Play() call would re-enable the MultiSocketMonitor.

This was an abuse of the flag which could result in a crash
in Cancel(), because that method asserts that the period_buffer is
empty, which it may be not.

The solution is to add anther flag called "waiting" which shares some
behavior with the old flag.
2019-06-28 18:04:49 +02:00
Max Kellermann
3c5f860fb8 output/alsa: Cancel() also affects "active" (documentation) 2019-06-28 18:04:49 +02:00
Max Kellermann
3da1fa88d0 output/alsa: fix comment typo 2019-06-28 18:04:49 +02:00
Max Kellermann
fac15aaffb output/alsa: fix comment typo 2019-06-28 14:39:54 +02:00
Max Kellermann
c926021599 output/alsa: always redo DrainInternal() after writing
Draining isn't finished just because the period_buffer has run empty.
It is only finished after snd_pcm_drain() has succeeded.
2019-06-28 09:10:16 +02:00
Max Kellermann
543776d9c9 output/alsa: check PCM state before calling snd_pcm_drain()
Apparently, if snd_pcm_drain() returns EAGAIN, it does not actually
want to be called again; the next call will snd_pcm_drain() will also
return EAGAIN, forever, even though the PCM state has meanwhile
switched to SND_PCM_STATE_SETUP.  This causes a busy loop; to fix
this, we should always check snd_pcm_state() to see if draining is
really required.
2019-06-28 08:55:25 +02:00
Max Kellermann
8bf3f9b874 input/tidal: deprecated because Tidal has changed the protocol
See https://github.com/MusicPlayerDaemon/MPD/issues/545
2019-06-26 23:14:07 +02:00
Max Kellermann
f07f8f7d88 decoder/wildmidi: add fallbacks for libwildmidi<0.4
Fix build breakage from commit ea639269d8
2019-06-26 23:13:23 +02:00
Max Kellermann
39b40ac1fd decoder/wildmidi: remove unused variable wildmidi_domain 2019-06-26 23:10:20 +02:00
Max Kellermann
ea639269d8 decoder/wildmidi: throw PluginUnavailable on WildMidi_Init() error
Closes https://github.com/MusicPlayerDaemon/MPD/issues/589
2019-06-26 22:40:27 +02:00
Max Kellermann
0abaa3ecc5 decoder/wildmidi: throw PluginUnavailable if config file does not exist
This makes the configuration error more visible, possibly addressing
one part of https://github.com/MusicPlayerDaemon/MPD/issues/589
2019-06-26 22:38:40 +02:00
Max Kellermann
c4d3efe71d decoder/List: handle exception PluginUnavailable 2019-06-26 22:02:54 +02:00
Max Kellermann
85e82e3d4d decoder/List: annotate exceptions thrown by DecoderPlugin::Init() 2019-06-26 22:01:45 +02:00
Max Kellermann
f44011519c meson.build: increase protocol version to 0.21.11
Commit 1eae9339f2 added support for
multiple "groups" in the "list" command, and this change allows
clients to detect that this behavior, which had been documented for
several years, is now implemented properly.
2019-06-18 15:35:38 +02:00
Max Kellermann
2c3eeb7194 MusicChunk: pad MusicChunkInfo to a multiple of 8 bytes
Workaround for a regression caused by commit
a06bf388d9, revealing a problem with
discarding odd numer of frames in the DSD_U32 and DoP converters,
causing distortions with DSD_U32 and DoP on 32 bit CPUs.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/469
2019-06-17 21:24:32 +02:00
Max Kellermann
79839db3a3 output/oss: return early if PcmExport::Export() returns empty array
This can happen if the DoP converter doesn't get enough source samples
for one destination quad.  This isn't a critical bug, because the OSS
plugin doesn't support DoP yet, but it's good to be prepared.
2019-06-17 21:07:30 +02:00
Max Kellermann
d478bdda8e pcm/Export: document that Export() may return an empty buffer 2019-06-17 21:07:29 +02:00
Max Kellermann
1eae9339f2 db/Interface: CollectUniqueTags() allows multiple "groups"
Instead of passing tag and group, pass an array of tags.  To support a
nested return value, return a nested std::map of std::maps.  Each key
specifies the tag value, and each value may be another nesting level.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/408
2019-06-16 10:39:29 +02:00
Max Kellermann
923c1b6220 doc/include: remove obsolete DocBook fragment 2019-06-11 09:29:20 +02:00
Max Kellermann
09884e608b increment version number to 0.21.11 2019-06-11 09:29:05 +02:00
Max Kellermann
e239009295 release v0.21.10 2019-06-05 22:32:32 +02:00
Max Kellermann
3fae2150f5 decoder/OpusReader: return StringView
Since we now don't duplicate all items, we can easily remove the 64kB
limit from OpusReader::ReadString() and instead silently ignore and
skip all strings which are longer than 4 kB.

This fixes a tag duplication bug with Opus file containing a very long
`METADATA_BLOCK_PICTURE` tag, which occurred because the Opus plugin
returned false after parsing all tags, and then the MPD core fell back
to FFmpeg which scanned the tags again.
2019-06-05 22:19:35 +02:00
cathugger
f9ca2f52c1 output/httpd: reject some well-known request paths
Return `404 not found` for some common well-known paths, as clients requesting them usually do that automatically and don't expect endless audio stram.

Closes 
2019-06-05 21:53:46 +02:00
cathugger
4b81cf0c2c output/httpd: use strncmp instead of memcmp
memcmp use may result in out of bounds access
2019-06-05 21:53:46 +02:00
Max Kellermann
e7acbf112c output/httpd: fix indent 2019-06-05 21:53:43 +02:00
Max Kellermann
304d45b551 Revert "player/Thread: remove unnecessary "pipe" check"
This reverts commit ff3e2c0514.  The
check was necessary, after all, because this is what checked whether
the decoder had finished the current or the next song.

> The "queued" flag can only possibly be set if the decoder is still
> decoding the current song or if the decoder is stopped.

That was wrong because ProcessCommand() sets `queued=true` and also
starts the decoder (if it was idle).

> This is also what the following assert() checks.

That was also wrong, because the assert() has two conditions.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/566
2019-05-31 17:23:12 +02:00
Max Kellermann
0f488dcecf doc/protocol.rst: binary responses do have a newline after all
Closes https://github.com/MusicPlayerDaemon/MPD/issues/568
2019-05-31 16:47:41 +02:00
Max Kellermann
17039aec70 doc/user.rst: more heading corrections
According to http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections
2019-05-31 16:30:06 +02:00
Max Kellermann
fb6cb07912 doc/developer.rst: remove outdated section about the clang static analyzer 2019-05-31 16:27:43 +02:00
Max Kellermann
e9e0e02db3 doc/user.rst: use ".. note:" 2019-05-31 16:26:52 +02:00
Max Kellermann
03507037e8 increment version number to 0.21.10 2019-05-31 16:16:56 +02:00
Max Kellermann
66a8fac25e release v0.21.9 2019-05-20 17:10:58 +02:00
Max Kellermann
1b902e00b4 doc/protocol.rst: several clarifications
Closes https://github.com/MusicPlayerDaemon/MPD/issues/340
2019-05-20 17:06:20 +02:00
Max Kellermann
923e66738c player/Thread: fix "single" mode race condition
If the decoder finishes decoding the current song between the two
IsIdle() checks, MPD stops playback instead of starting the decoder
for the next song.

This is usually not visible problem, because the main thread restarts
it via playlist::ResumePlayback(), but that way it, ignores "single"
mode.

As a workaround, this commit adds another "queued" check which
re-enters the player loop and checks again whether to start the
decoder.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/556
2019-05-20 16:22:01 +02:00
Max Kellermann
ff3e2c0514 player/Thread: remove unnecessary "pipe" check
The "queued" flag can only possibly be set if the decoder is still
decoding the current song or if the decoder is stopped.  This is also
what the following assert() checks.  This check was not necessary.
2019-05-20 16:20:59 +02:00
Max Kellermann
6922a2f55e input/buffered: check error in IsAvailable() 2019-05-17 12:43:45 +02:00
Max Kellermann
ca5a400dbe input/buffered: rethrow read_error in Check() 2019-05-16 22:08:33 +02:00
Max Kellermann
63fe4d1d17 input/buffered: wake up client thread on seek error 2019-05-16 22:05:25 +02:00
Max Kellermann
ca06d9d3bf input/buffered: fix deadlock bug 2019-05-16 21:11:03 +02:00
Max Kellermann
ed2db04f43 doc/mpd.conf.5: remove ALSA specific documentation
ALSA is just one out of many output plugins, and detailed plugin
documentation should only live in the user manual, without having
duplicates in the (brief) manpage.

Also move "mixer_type" to the "optional audio output parameters"
section; it is a generic option, not specific to ALSA.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/552
2019-05-13 22:51:48 +02:00
Max Kellermann
de0afa0e08 doc/mpd.conf.5: fix section indent 2019-05-13 22:51:45 +02:00
Max Kellermann
f0d3227d7b doc/protocol.rst: add references to audio_output_format 2019-05-13 22:46:23 +02:00
Max Kellermann
fb07a7cecc doc/user.rst: move audio format spec to section "Global Audio Format" 2019-05-13 22:39:49 +02:00
Max Kellermann
c6b08a4d48 doc/user.rst: add reference to audio_output_format 2019-05-13 22:39:44 +02:00
Max Kellermann
040e87ad8d doc/user.rst: more markup 2019-05-13 22:36:19 +02:00
Max Kellermann
d5521ead56 doc/user.rst: add missing space 2019-05-13 22:36:19 +02:00
Max Kellermann
f8468451c9 android/AndroidManifest.xml: increment versionCode after hotfix upload 2019-05-04 13:25:05 +02:00
Max Kellermann
65df6ca14e android/Settings: request READ_EXTERNAL_STORAGE permission
Using this API function requires SDK level 23.
2019-05-04 07:29:41 +02:00
Max Kellermann
36dec47bf7 android/build.py: link ARMv7 binary with libunwind
Fixes nullptr dereference when an exception gets thrown because there
is no ".eh_frame" section for unwinding.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/543
2019-05-03 20:15:50 +02:00
Max Kellermann
478cedcadf increment version number to 0.21.9 2019-05-03 20:15:33 +02:00
Max Kellermann
cabcbb059d release v0.21.8 2019-04-23 14:35:14 +02:00
Max Kellermann
5e21b2db3c doc/protocol.rst: "list file" is deprecated
Closes https://github.com/MusicPlayerDaemon/MPD/issues/526
2019-04-23 14:29:42 +02:00
Max Kellermann
3a0d6d96c1 input/smbclient: wrap in MaybeBufferedInputStream
This enables the input buffer for remote files and caches file
contents in MPD.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/376
2019-04-23 14:08:27 +02:00
Max Kellermann
f39d2d33c0 python/build/libs.py: upgrade Boost to 1.70.0 2019-04-23 14:08:27 +02:00
Max Kellermann
ead3dc6a92 LocateUri: pass URI plugin kind, optionally disables plugin verify
Commit b3a458338a added a LocateUri()
call to several playlist commands, which applied InputPlugin URI
scheme verification to playlist URIs.  This broke the SoundCloud
playlist plugin which uses "soundcloud://" URIs for which no input
plugin exists.

This commit allows the caller to specify the kind of plugin which
shall be used to verify the URI.  Right now, only "input" is
implemented; "storage" uses the "input" verification for now; and
"playlist" has no verification at all (for now).

Closes https://github.com/MusicPlayerDaemon/MPD/issues/528
2019-04-18 10:03:15 +02:00
Max Kellermann
7d814cc899 neighbor/smbclient: fix double smbc_closedir() call
There is already one call in ReadServers(), which is the correct place
to do it.
2019-04-18 09:40:56 +02:00
Max Kellermann
f5b4606c09 .travis.yml: switch to another PPA for a newer ninja version
Fixes Travis failure with Meson 0.50:

 ERROR: Could not detect Ninja v1.5 or newer
2019-04-18 09:40:30 +02:00
Max Kellermann
d6dbf64efb CommandLine: fix another build failure with -Ddatabase=false
Split several printf() calls to make it easier to deal with all those
#ifdefs.
2019-04-18 09:20:12 +02:00
Eugene Gorodinsky
8d18b4c24b Fix meson.build to work properly with '-Ddatabase=false' 2019-04-18 08:55:13 +02:00
Max Kellermann
fe8621906d systemd: add user socket unit
Copy the system socket unit to the "user" directory.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/530
2019-04-10 16:37:13 +02:00
Max Kellermann
b4fcbdb235 systemd/socket: use %t instead of hard-coding /run
This allows using the file as a user unit, where "%t" maps to
"$XDG_RUNTIME_DIR".

Proposed in https://github.com/MusicPlayerDaemon/MPD/issues/530
2019-04-10 16:34:40 +02:00
Max Kellermann
f4b5a28596 doc/protocol: mention that stickers are only implemented for songs
Closes https://github.com/MusicPlayerDaemon/MPD/issues/524
2019-04-10 16:33:17 +02:00
Max Kellermann
6cbd77fc57 doc/protocol.rst: mention "in seconds" where it was missing
Closes https://github.com/MusicPlayerDaemon/MPD/issues/523
2019-04-10 16:30:26 +02:00
cotko
1bc78e9f2c Fid move doc args 2019-04-10 13:16:58 +02:00
Max Kellermann
cb6282e0a7 doc/developer.rst: remove mailing list, refer to GitHub instead 2019-04-10 11:36:03 +02:00
Max Kellermann
f6941f9a44 event/SocketMonitor: don't cancel if OnSocketReady() returns false
Expect OnSocketReady() to cancel events.  If it returns false, the
SocketMonitor may be destructed already.  This fixes a use-after-free
bug in the "httpd" output plugin.
2019-04-04 10:24:58 +02:00
Max Kellermann
d2eb4df8fc event/{Fully,}BufferedSocket: add more API documentation 2019-04-04 10:24:58 +02:00
Max Kellermann
df33a898d7 zeroconf/Bonjour: fix OnSocketReady() return value
Keep the SocketMonitor registered.  This wrong return value was added
6 years ago in commit 72cf8dd8a0, andd
apparently, nobody ever noticed.
2019-04-04 10:24:29 +02:00
Max Kellermann
325c7b8e8b output/httpd: close client connection on error
This missing piece probably never really hurt, because
HttpdClient::OnSocketClosed() would be called right after a socket
error, but it's better to be explicit about closing on error.
2019-04-04 09:39:22 +02:00
Max Kellermann
380656d8c9 output/httpd: add missing mutex lock 2019-04-03 22:53:03 +02:00
Max Kellermann
9111bc2c21 output/httpd: add more API documentation about locking 2019-04-03 22:49:25 +02:00
Max Kellermann
37b54179d8 net/IPv[46]Address: add cast to void* to fix GCC9 build failure
Fixes:

 src/net/IPv4Address.hxx: In member function 'constexpr IPv4Address::operator SocketAddress() const':
 src/net/IPv4Address.hxx:171:24: error: a reinterpret_cast is not a constant expression
   171 |   return SocketAddress((const struct sockaddr *)&address,
       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 src/net/IPv6Address.hxx: In member function 'constexpr IPv6Address::operator SocketAddress() const':
 src/net/IPv6Address.hxx:138:24: error: a reinterpret_cast is not a constant expression
   138 |   return SocketAddress((const struct sockaddr *)&address,
       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Closes https://github.com/MusicPlayerDaemon/MPD/issues/522
2019-04-03 16:59:53 +02:00
Max Kellermann
511826763a increment version number to 0.21.8 2019-04-03 12:27:18 +02:00
Max Kellermann
ef10354d06 release v0.21.7 2019-04-03 12:18:29 +02:00
Max Kellermann
158458db5f python/build/libs.py: upgrade libnfs to 4.0.0 2019-04-03 11:37:33 +02:00
Max Kellermann
e183ab5cf8 python/build/libs.py: upgrade CURL to 7.64.1 2019-04-03 11:35:13 +02:00
Max Kellermann
fef839e2a9 python/build/libs.py: upgrade FFmpeg to 4.1.3 2019-04-03 11:34:32 +02:00
Max Kellermann
9776e43bbe android/AndroidManifest.xml: update version number 2019-04-03 11:28:59 +02:00
Max Kellermann
5201147ab1 input/curl: use std::throw_with_nested() instead of logging the exception
Let the caller decide what to do with the original exception.
2019-03-29 17:34:51 +01:00
Max Kellermann
fb7daa0d05 input/smbclient: use std::throw_with_nested() to construct PluginUnavailable
Preserve the original exception.
2019-03-29 17:32:23 +01:00
Max Kellermann
2e9f3d8b9f decoder/HybridDSD: downgrade log message to "debug"
This plugin is interesting only for a tiny fraction of MPD users, so
let's not spam everybody else's log with it.
2019-03-29 17:15:48 +01:00
Max Kellermann
976731ab6c command/playlist: invoke the RemoteTagScanner on all newly added songs
Closes https://github.com/MusicPlayerDaemon/MPD/issues/234
2019-03-29 17:01:31 +01:00
François Revol
0d8942e64a Haiku: remove redundant calls to delete_sem()
Fixes .

Semaphores are kernel-managed objects, calling delete_sem() twice is not more
dangerous than calling close() twice on an fd though, it would just return
an error.
2019-03-29 14:33:49 +01:00
François Revol
37a0f04712 Haiku: add version info to the resources like win32 does 2019-03-29 14:33:27 +01:00
François Revol
cde9348009 Haiku: fix adding resources
The custom_command was run in src/haiku/ and created a file with only resources inside.

Since xres edits the file in-place and meson doesn't like it, we have to run a shell script for now.
Maybe later I'll add proper support in meson.
2019-03-29 14:32:59 +01:00
François Revol
095e6e6ad4 Haiku: meson.build: fix linking (missing libs) 2019-03-29 14:32:19 +01:00
François Revol
9d0bf5e95c Haiku: fix build 2019-03-29 14:32:06 +01:00
Max Kellermann
8b327f1d9b filter/AutoConvert: implement Flush() 2019-03-24 22:42:06 +01:00
Max Kellermann
aef0507abb filter/Filter: fix typo in API doc 2019-03-24 22:34:11 +01:00
Max Kellermann
6bab3bcfea test/RunChromaprint: add missing override 2019-03-20 13:30:13 +01:00
Max Kellermann
a854595886 event/ServerSocket: runtime error if abstract sockets are unavailable 2019-03-20 13:09:16 +01:00
Max Kellermann
8fc3c5c612 event/ServerSocket: add HAVE_UN check to AddAbstract()
Closes https://github.com/MusicPlayerDaemon/MPD/issues/510
2019-03-20 13:06:09 +01:00
Max Kellermann
4f408bd952 event/ServerSocket, doc, ...: refer to AF_LOCAL as "local socket"
.. and not "UNIX domain socket.  Be consistent about the naming.
2019-03-20 12:57:26 +01:00
Max Kellermann
7de8fd04a4 doc/plugins.rst: add the Haiku plugin and mark it as unmaintained 2019-03-18 18:24:51 +01:00
Max Kellermann
8158bd218c doc/plugins.rst: add filter plugin reference 2019-03-18 18:05:18 +01:00
Max Kellermann
aa1d867b72 doc/user.rst: document the "filters" setting 2019-03-18 17:05:23 +01:00
Max Kellermann
34c8242133 doc/user.rst: add more links 2019-03-18 17:01:55 +01:00
Max Kellermann
e22bdee808 win32/res/meson.build: drop tilde suffix from version number before splitting
MPD sometimes uses version numbers like "0.22~git" to mark unreleased
versions.  That makes the win32 resource compiler unhappy, because it
expects numbers only.
2019-03-18 09:58:40 +01:00
Jörg Krause
7f87de783f src/lib/gcrypt/meson.build: use dependency() for quering linker flags
Since version 0.49.0 the Meson build system has native support for
finding and using the gcrypt library using the `dependency()` function.

`dependency()` has the advantage over `find_library()` as it queries the
required linker flags for proper linking with external libraries, e.g.
libgpg-error.

As the latest released version 1.8.4 of libgcrypt does not
provide a .pc file, using `libgcrypt-config` is the only way to query
the required linker flags.

Unfortunately, there is an issue when cross compiling mpd and the user does not
define `libgcrypt-config` in the cross file. If the user sets the qobuz feature
to `auto` and the target does not have libgcrypt installed, the Meson
build system will falsly assume libgcrypt is available for the target as
it uses the native `libgcrypt-config` on the host and pretend is has
found the library.

Therefore, we still rely on `find_library()` to workaround this buggy
behavior. This way, if qobuz feature detection is set to `auto`, the
feature is disabled in case there is no target libgcrypt available.

Fixes building mpd statically with the qobuz feature enabled. Otherwise
the build fails with undefined references because of the missing libgpg-error
dependency:

```
/sysroot/usr/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_strerror':
visibility.c:(.text+0x14): undefined reference to `gpg_strerror'
```
2019-03-18 09:12:19 +01:00
Jörg Krause
c66389a453 meson.build: require Meson 0.49.0
Meson 0.49.0 adds native support for `libgcrypt-config` which is
necessary for detecting libgcrypt dependencies, as the latest
version 1.8.4 of libgcrypt does not provide a .pc file.
2019-03-18 09:11:46 +01:00
Max Kellermann
b63c1a2144 increment version number to 0.21.7 2019-03-18 09:11:16 +01:00
Max Kellermann
808dd7cc54 release v0.21.6 2019-03-17 23:52:13 +01:00
Max Kellermann
62a129c18f PlaylistFile: ignore empty playlist names
Closes https://github.com/MusicPlayerDaemon/MPD/issues/465 and
https://github.com/MusicPlayerDaemon/MPD/pull/466
2019-03-17 23:46:36 +01:00
Max Kellermann
c18cd941aa lib/xiph: disable Tremor detection if libvorbis was found
And disable libvorbis detection if Tremor was explicitly enabled.

This fixes a crash bug caused by libvorbis/Tremor ABI conflict caused
by commit 4f7d52dbf2
2019-03-17 23:36:52 +01:00
Max Kellermann
6d12c22653 decoder/ogg: ignore the BOS packet after seek to the beginning of song
Previously, MPD would skip the current song after attempting to seek
to its beginnig, because that was a seek to offset 0.  At offset 0,
MPD will see the BOS packet again, which results in throwing
StopDecoder in MPDOpusDecoder::OnOggEnd().

Closes https://github.com/MusicPlayerDaemon/MPD/issues/470
2019-03-17 23:14:59 +01:00
Max Kellermann
b76d78e6ae output/sles: enable power saving mode 2019-03-17 18:04:40 +01:00
Jacob Vosmaer
0a6e484b1a output/plugins/OSXOutputPlugin: add boost meson dependency 2019-03-17 16:59:24 +01:00
Max Kellermann
0bb71f1f20 output/pulse: use pa_channel_map_init_extend() instead of _auto()
Unlike pa_channel_map_init_auto(), pa_channel_map_init_extend() does
not fail if there is no valid mapping for the given channel count, but
instead maps additional "AUX" channels.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/493
2019-03-16 14:03:10 +01:00
Max Kellermann
1aa7cdd602 decoder/opus: fix replay gain when there are no other tags
The `tag_builder.empty()` check was wrong for the SubmitReplayGain()
call.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/497
2019-03-16 13:55:19 +01:00
Max Kellermann
a4b8a0d801 doc/protocol.rst: clarify filter expressions with multiple tag values
Clarification for https://github.com/MusicPlayerDaemon/MPD/issues/505
2019-03-16 13:23:44 +01:00
Max Kellermann
3bf521d5ca song/TagSongFilter: apply negation properly to multiple tag values
The old implementation didn't make a lot of sense; the "!=" operator
was not actually the opposite of "==".

Closes https://github.com/MusicPlayerDaemon/MPD/issues/505
2019-03-16 13:23:02 +01:00
Max Kellermann
0acb55cde5 song/StringFilter: remove obsolete #if 2019-03-16 13:23:02 +01:00
Max Kellermann
6b89fd6100 song/StringFilter: make MatchWithoutNegation() public 2019-03-16 13:23:02 +01:00
Max Kellermann
52ce39dc3e test/TestSongFilter: unit test for song filters
A few of those tests fail due to bugs.
2019-03-16 13:23:02 +01:00
Max Kellermann
7a3e15d8e5 test/meson.build: add section for filter tests 2019-03-16 13:23:02 +01:00
Max Kellermann
cf66a60c60 test/MakeTag: add noexcept 2019-03-16 13:23:02 +01:00
Max Kellermann
9b26d451e4 test/MakeTag: remove static 2019-03-16 13:23:02 +01:00
Max Kellermann
137ffba1b4 test/test_translate_song: move MakeTag() to header 2019-03-16 13:23:02 +01:00
Max Kellermann
5c5dc1b7c0 meson.build: increase protocol version to 0.21.6
There is a minor new feature (commit 713c1f2ba9) and clients might be
interested in detecting it by the protocol version.
2019-03-16 13:23:02 +01:00
Max Kellermann
9e9418294a song/TagSongFilter: eliminate Match(TagItem) 2019-03-15 20:28:27 +01:00
Max Kellermann
b850eb74b7 song/TagSongFilter: add code comments 2019-03-15 19:54:29 +01:00
Max Kellermann
67d73a2aee song/TagSongFilter: improve lambda indent 2019-03-15 19:54:16 +01:00
Max Kellermann
fde9a470dd song/TagSongFilter: eliminate the std::fill_n() call 2019-03-15 19:35:58 +01:00
Max Kellermann
8d1f30e55b tag/Fallback: add API documentation 2019-03-15 19:23:10 +01:00
Max Kellermann
ddd2b60489 doc/protocol.rst: add missing operators to example expressions 2019-03-15 19:14:06 +01:00
Max Kellermann
8777737861 doc/protocol.rst: use double backticks for tag names 2019-03-15 19:11:30 +01:00
Max Kellermann
cb71f6dd04 doc/protocol.rst: clarify the meaning of the any tag type 2019-03-15 19:09:55 +01:00
Max Kellermann
1881b0e975 song/TagSongFilter: rename MatchNN() to Match()
The "NN" suffix used to mean "no negation", but that's not how it's
implemented today.
2019-03-15 19:06:56 +01:00
Max Kellermann
98b29f6d1c meson.build: remove the libwinpthread-1.dll dependency on Windows
Closes https://github.com/MusicPlayerDaemon/MPD/issues/507
2019-03-14 20:07:06 +01:00
Max Kellermann
59fdfd25cb command/database: fix "list" with filter expression
Disable the 0.11 compatibility mode if the only argument is a filter
expression.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/506
2019-03-14 19:50:09 +01:00
Max Kellermann
0d98677212 playlist/flac: copy the URI to fix use-after-free bug
Closes https://github.com/MusicPlayerDaemon/MPD/issues/508
2019-03-14 19:30:33 +01:00
Max Kellermann
38f0c16904 system/UniqueFileDescriptor: add CreatePipeNonBlock() 2019-02-27 23:30:56 +01:00
Max Kellermann
4fbf6b6c95 net/StaticSocketAddress: remove GetAddress() 2019-02-27 23:26:59 +01:00
Max Kellermann
1f8ff48168 net/StaticSocketAddress: add GetLocalRaw() 2019-02-27 23:26:00 +01:00
Max Kellermann
20b6e0d684 net/SocketDescriptor: add SetTcpUserTimeout() 2019-02-27 23:22:12 +01:00
Max Kellermann
713c1f2ba9 Merge branch 'feature/playlist' of git://github.com/miccoli/MPD 2019-02-27 13:49:22 +01:00
Stefano Miccoli
a149bc4c5d update protocol documentation for new semantics of playlist abs. name 2019-02-26 00:12:09 +01:00
Stefano Miccoli
b3a458338a allow loading playlists specified as absolute filesystem paths
implement for the "load" command the same logic used for the "add"
command: local clients can load playlist specified as absolute paths.

For relative paths the old logic is preserved: first look for a stored
playlist, then look in the music directory.
2019-02-26 00:12:09 +01:00
Max Kellermann
44422b2b2f event/ServerSocket, config/Net: abstract socket support 2019-02-25 13:08:33 +01:00
Max Kellermann
f10afd38b5 NEWS: mention the cdio_paranoia build failure fix 2019-02-25 13:08:33 +01:00
Thomas Zander
4c50a5e0b3 Ensure SEEK_SET is set on systems where stdio.h is not pulled in by accident. 2019-02-23 18:04:00 +01:00
Max Kellermann
f255a485b7 increment version number to 0.21.6 2019-02-22 15:28:03 +01:00
109 changed files with 1506 additions and 779 deletions
.travis.ymlNEWS
android
doc
meson.build
python/build
src
CommandLine.cxxLocateUri.cxxLocateUri.hxxMusicChunk.hxxPlaylistFile.cxxSongLoader.cxx
command
config
db
decoder
event
filter
haiku
input
lib
neighbor
net
output
pcm
player
playlist
song
system
tag
thread
util
zeroconf
systemd
test
win32/res

@@ -9,7 +9,7 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:mhier/libboost-latest'
- sourceline: 'ppa:saiarcot895/chromium-dev' # for ninja-build
- sourceline: 'ppa:mstipicevic/ninja-build-1-7-2'
- sourceline: 'ppa:deadsnakes/ppa' # for Python 3.7 (required by Meson)
packages:
- g++-6
@@ -34,7 +34,7 @@ matrix:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:mhier/libboost-latest'
- sourceline: 'ppa:saiarcot895/chromium-dev' # for ninja-build
- sourceline: 'ppa:mstipicevic/ninja-build-1-7-2'
- sourceline: 'ppa:deadsnakes/ppa' # for Python 3.7 (required by Meson)
packages:
- g++-8

75
NEWS

@@ -1,3 +1,78 @@
ver 0.21.11 (2019/07/03)
* input
- tidal: deprecated because Tidal has changed the protocol
* decoder
- wildmidi: log error if library initialization fails
* output
- alsa: fix busy loop while draining
- alsa: fix missing drain call
- alsa: improve xrun-avoiding silence generator
- alsa: log when generating silence due to slow decoder
- alsa, osx: fix distortions with DSD_U32 and DoP on 32 bit CPUs
* protocol
- fix "list" with multiple "group" levels
ver 0.21.10 (2019/06/05)
* decoder
- opus: fix duplicate tags
* output
- httpd: reject some well-known URIs
* fix crash bug (0.21.9 regression)
ver 0.21.9 (2019/05/20)
* input
- buffer: fix deadlock bug
* Android
- fix crash on ARMv7
- request storage permission on Android 6+
* fix spurious "single" mode bug
ver 0.21.8 (2019/04/23)
* input
- smbclient: download to buffer instead of throttling transfer
* output
- httpd: add missing mutex lock
- httpd: fix use-after-free bug
* playlist
- soundcloud: fix "Unsupported URI scheme" (0.21.6 regression)
* fix Bonjour bug
* fix build failure with GCC 9
* fix build failure with -Ddatabase=false
* systemd: add user socket unit
* doc: "list file" is deprecated
ver 0.21.7 (2019/04/03)
* input
- qobuz/tidal: scan tags when loading a playlist
* require Meson 0.49.0 for native libgcrypt-config support
* fix build failure with -Dlocal_socket=false
* Haiku
- fix build
- add version info
ver 0.21.6 (2019/03/17)
* protocol
- allow loading playlists specified as absolute filesystem paths
- fix negated filter expressions with multiple tag values
- fix "list" with filter expression
- omit empty playlist names in "listplaylists"
* input
- cdio_paranoia: fix build failure due to missing #include
* decoder
- opus: fix replay gain when there are no other tags
- opus: fix seeking to beginning of song
- vorbis: fix Tremor conflict resulting in crash
* output
- pulse: work around error with unusual channel count
- osx: fix build failure
* playlist
- flac: fix use-after-free bug
* support abstract sockets on Linux
* Windows
- remove the unused libwinpthread-1.dll dependency
* Android
- enable SLES power saving mode
ver 0.21.5 (2019/02/22)
* protocol
- fix deadlock in "albumart" command

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.musicpd"
android:installLocation="auto"
android:versionCode="27"
android:versionName="0.21.5">
android:versionCode="34"
android:versionName="0.21.11">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26"/>

@@ -138,6 +138,12 @@ class AndroidNdkToolchain:
libstdcxx_ldflags = libstdcxx_flags + ' -L' + libcxx_libs_path
libstdcxx_libs = '-lc++_static -lc++abi'
if self.is_armv7:
# On 32 bit ARM, clang generates no ".eh_frame" section;
# instead, the LLVM unwinder library is used for unwinding
# the stack after a C++ exception was thrown
libstdcxx_libs += ' -lunwind'
if use_cxx:
self.cxxflags += ' ' + libstdcxx_cxxflags
self.ldflags += ' ' + libstdcxx_ldflags

@@ -6,7 +6,7 @@ android_sdk = get_option('android_sdk')
android_abi = get_option('android_abi')
android_sdk_build_tools_version = '27.0.0'
android_sdk_platform = 'android-21'
android_sdk_platform = 'android-23'
android_build_tools_dir = join_paths(android_sdk, 'build-tools', android_sdk_build_tools_version)
android_sdk_platform_dir = join_paths(android_sdk, 'platforms', android_sdk_platform)

@@ -21,10 +21,12 @@ package org.musicpd;
import java.util.LinkedList;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -178,6 +180,14 @@ public class Settings extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
/* TODO: this sure is the wrong place to request
permissions - it will cause MPD to quit
immediately; we should request permissions when we
need them, but implementing that is complicated, so
for now, we do it here to give users a quick
solution for the problem */
requestAllPermissions();
setContentView(R.layout.settings);
mRunButton = (ToggleButton) findViewById(R.id.run);
mRunButton.setOnCheckedChangeListener(mOnRunChangeListener);
@@ -203,6 +213,31 @@ public class Settings extends Activity {
super.onCreate(savedInstanceState);
}
private void checkRequestPermission(String permission) {
if (checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED)
return;
try {
this.requestPermissions(new String[]{permission}, 0);
} catch (Exception e) {
Log.e(TAG, "requestPermissions(" + permission + ") failed",
e);
}
}
private void requestAllPermissions() {
if (android.os.Build.VERSION.SDK_INT < 23)
/* we don't need to request permissions on
this old Android version */
return;
/* starting with Android 6.0, we need to explicitly
request all permissions before using them;
mentioning them in the manifest is not enough */
checkRequestPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
}
private void connectClient() {
mClient = new Main.Client(this, new Main.Client.Callback() {

@@ -38,7 +38,7 @@ author = 'Max Kellermann'
# built documents.
#
# The short X.Y version.
version = '0.21.5'
version = '0.21.11'
# The full version, including alpha/beta/rc tags.
release = version

@@ -2,12 +2,12 @@ Developer's Manual
##################
Introduction
============
************
This is a guide for those who wish to hack on the MPD source code. MPD is an open project, and we are always happy about contributions. So far, more than 150 people have contributed patches. This document is work in progress. Most of it may be incomplete yet. Please help!
Code Style
==========
**********
* indent with tabs (width 8)
* don't write CPP when you can write C++: use inline functions and constexpr instead of macros
@@ -18,7 +18,6 @@ Code Style
* classes and functions names use CamelCase; variables are lower-case with words separated by underscore
Some example code:
~~~~~~~~~~~~~~~~~~
.. code-block:: c
@@ -33,7 +32,7 @@ Some example code:
}
Hacking The Source
==================
******************
MPD sources are managed in a git repository on
`Github <https://github.com/MusicPlayerDaemon/>`_.
@@ -59,7 +58,7 @@ possible, to be sure that you don't break any disabled code.
Don't mix several changes in one single patch. Create a separate patch for every change. Tools like :program:`stgit` help you with that. This way, we can review your patches more easily, and we can pick the patches we like most first.
Basic stgit usage
-----------------
=================
stgit allows you to create a set of patches and refine all of them: you can go back to any patch at any time, and re-edit it (both the code and the commit message). You can reorder patches and insert new patches at any position. It encourages creating separate patches for tiny changes.
@@ -94,35 +93,7 @@ When the whole patch series is finished, convert stgit patches to git commits:
stg commit
Submitting Patches
==================
******************
Send your patches to the mailing list:
Email: `mpd-devel <mpd-devel@musicpd.org>`_
:program:`git pull` requests are preferred.
Development Tools
=================
Clang Static Analyzer
---------------------
The `static analyzer <http://clang-analyzer.llvm.org/>`_ is a tool that helps find bugs. To run it on the MPD code base, install LLVM and clang. configure MPD to use clang:
.. code-block:: sh
./configure --enable-debug CXX=clang++ CC=clang ...
It is recommended to use :code:`--enable-debug`, because the analyzer
takes advantage of :dfn:`assert()` calls, which are only enabled in
the debug build.
Now run the analyzer:
.. code-block:: sh
scan-build --use-c++=clang++ --use-cc=clang make
The options :code:`--use-c++` and :code:`--use-cc` are necessary
because it invokes :command:`cc` for actually compiling the sources by
default. That breaks, because MPD requires a C99 compiler.
Submit pull requests on GitHub:
https://github.com/MusicPlayerDaemon/MPD/pulls

@@ -1,165 +0,0 @@
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE itemizedlist PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<itemizedlist>
<listitem>
<para>
<varname>artist</varname>: the artist name. Its meaning is not
well-defined; see <varname>composer</varname> and
<varname>performer</varname> for more specific tags.
</para>
</listitem>
<listitem>
<para>
<varname>artistsort</varname>: same as
<varname>artist</varname>, but for sorting. This usually omits
prefixes such as "The".
</para>
</listitem>
<listitem>
<para>
<varname>album</varname>: the album name.
</para>
</listitem>
<listitem>
<para>
<varname>albumsort</varname>: same as <varname>album</varname>,
but for sorting.
</para>
</listitem>
<listitem>
<para>
<varname>albumartist</varname>: on multi-artist albums, this is
the artist name which shall be used for the whole album. The
exact meaning of this tag is not well-defined.
</para>
</listitem>
<listitem>
<para>
<varname>albumartistsort</varname>: same as
<varname>albumartist</varname>, but for sorting.
</para>
</listitem>
<listitem>
<para>
<varname>title</varname>: the song title.
</para>
</listitem>
<listitem>
<para>
<varname>track</varname>: the decimal track number within the
album.
</para>
</listitem>
<listitem>
<para>
<varname>name</varname>: a name for this song. This is not the
song title. The exact meaning of this tag is not well-defined.
It is often used by badly configured internet radio stations
with broken tags to squeeze both the artist name and the song
title in one tag.
</para>
</listitem>
<listitem>
<para>
<varname>genre</varname>: the music genre.
</para>
</listitem>
<listitem>
<para>
<varname>date</varname>: the song's release date. This is
usually a 4-digit year.
</para>
</listitem>
<listitem>
<para>
<varname>composer</varname>: the artist who composed the song.
</para>
</listitem>
<listitem>
<para>
<varname>performer</varname>: the artist who performed the song.
</para>
</listitem>
<listitem>
<para>
<varname>comment</varname>: a human-readable comment about this
song. The exact meaning of this tag is not well-defined.
</para>
</listitem>
<listitem>
<para>
<varname>disc</varname>: the decimal disc number in a multi-disc
album.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_artistid</varname>: the artist id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_albumid</varname>: the album id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_albumartistid</varname>: the album artist
id in the <ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_trackid</varname>: the track id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_releasetrackid</varname>: the release track
id in the <ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
<listitem>
<para>
<varname>musicbrainz_workid</varname>: the work id in the
<ulink
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
database.
</para>
</listitem>
</itemizedlist>

@@ -140,7 +140,6 @@ of database.
.B auto_update_depth <N>
Limit the depth of the directories being watched, 0 means only watch
the music directory itself. There is no limit by default.
.TP
.SH REQUIRED AUDIO OUTPUT PARAMETERS
.TP
.B type <type>
@@ -164,57 +163,12 @@ Specifies how replay gain is applied. The default is "software",
which uses an internal software volume control. "mixer" uses the
configured (hardware) mixer control. "none" disables replay gain on
this audio output.
.SH OPTIONAL ALSA OUTPUT PARAMETERS
.TP
.B device <dev>
This specifies the device to use for audio output. The default is "default".
.TP
.B mixer_type <hardware, software or none>
Specifies which mixer should be used for this audio output: the
hardware mixer (available for ALSA, OSS and PulseAudio), the software
mixer or no mixer ("none"). By default, the hardware mixer is used
for devices which support it, and none for the others.
.TP
.B mixer_device <mixer dev>
This specifies which mixer to use. The default is "default". To use
the second sound card in a system, use "hw:1".
.TP
.B mixer_control <mixer ctrl>
This specifies which mixer control to use (sometimes referred to as
the "device"). The default is "PCM". Use "amixer scontrols" to see
the list of possible controls.
.TP
.B mixer_index <mixer index>
A number identifying the index of the named mixer control. This is
probably only useful if your alsa device has more than one
identically\-named mixer control. The default is "0". Use "amixer
scontrols" to see the list of controls with their indexes.
.TP
.B auto_resample <yes or no>
Setting this to "no" disables ALSA's software resampling, if the
hardware does not support a specific sample rate. This lets MPD do
the resampling. "yes" is the default and allows ALSA to resample.
.TP
.B auto_channels <yes or no>
Setting this to "no" disables ALSA's channel conversion, if the
hardware does not support a specific number of channels. Default: "yes".
.TP
.B auto_format <yes or no>
Setting this to "no" disables ALSA's sample format conversion, if the
hardware does not support a specific sample format. Default: "yes".
.TP
.B buffer_time <time in microseconds>
This sets the length of the hardware sample buffer in microseconds. Increasing
it may help to reduce or eliminate skipping on certain setups. Most users do
not need to change this. The default is 500000 microseconds (0.5 seconds).
.TP
.B period_time <time in microseconds>
This sets the time between hardware sample transfers in microseconds.
Increasing this can reduce CPU usage while lowering it can reduce underrun
errors on bandwidth-limited devices. Some users have reported good results
with this set to 50000, but not all devices support values this high. Most
users do not need to change this. The default is 256000000 / sample_rate(kHz),
or 5804 microseconds for CD-quality audio.
.SH FILES
.TP
.BI ~/.mpdconf

@@ -4,10 +4,10 @@ Plugin reference
.. _database_plugins:
Database plugins
----------------
================
simple
~~~~~~
------
The default plugin. Stores a copy of the database in memory. A file is used for permanent storage.
@@ -25,7 +25,7 @@ The default plugin. Stores a copy of the database in memory. A file is used for
- Compress the database file using gzip? Enabled by default (if built with zlib).
proxy
~~~~~
-----
Provides access to the database of another :program:`MPD` instance using libmpdclient. This is useful when you run mount the music directory via NFS/SMB, and the file server already runs a :program:`MPD` instance. Only the file server needs to update the database.
@@ -45,30 +45,30 @@ Provides access to the database of another :program:`MPD` instance using libmpdc
- Send TCP keepalive packets to the "master" :program:`MPD` instance? This option can help avoid certain firewalls dropping inactive connections, at the expensive of a very small amount of additional network traffic. Disabled by default.
upnp
~~~~
----
Provides access to UPnP media servers.
Storage plugins
---------------
===============
local
~~~~~
-----
The default plugin which gives :program:`MPD` access to local files. It is used when music_directory refers to a local directory.
curl
~~~~
----
A WebDAV client using libcurl. It is used when :code:`music_directory` contains a http:// or https:// URI, for example :samp:`https://the.server/dav/`.
smbclient
~~~~~~~~~
---------
Load music files from a SMB/CIFS server. It is used when :code:`music_directory` contains a smb:// URI, for example :samp:`smb://myfileserver/Music`.
nfs
~~~
---
Load music files from a NFS server. It is used when :code:`music_directory` contains a nfs:// URI according to RFC2224, for example :samp:`nfs://servername/path`.
@@ -81,7 +81,7 @@ This plugin uses libnfs, which supports only NFS version 3. Since :program:`MPD`
Don't fear: "insecure" does not mean that your NFS server is insecure. A few decades ago, people thought the concept of "privileged ports" would make network services "secure", which was a fallacy. The absence of this obsolete "security" measure means little.
udisks
~~~~~~
------
Mount file systems (e.g. USB sticks or other removable media) using
the udisks2 daemon via D-Bus. To obtain a valid udisks2 URI, consult
@@ -106,29 +106,30 @@ MPD user.
.. _neighbor_plugin:
Neighbor plugins
----------------
================
smbclient
~~~~~~~~~
---------
Provides a list of SMB/CIFS servers on the local network.
udisks
~~~~~~
------
Queries the udisks2 daemon via D-Bus and obtain a list of file systems (e.g. USB sticks or other removable media).
upnp
~~~~
----
Provides a list of UPnP servers on the local network.
.. _input_plugins:
Input plugins
-------------
=============
alsa
~~~~
----
Allows :program:`MPD` on Linux to play audio directly from a soundcard using the scheme alsa://. Audio is formatted as 44.1 kHz 16-bit stereo (CD format). Examples:
@@ -141,7 +142,7 @@ Allows :program:`MPD` on Linux to play audio directly from a soundcard using the
mpc add alsa://hw:1,0 plays audio from device hw:1,0 cdio_paranoia
cdio_paranoia
~~~~~~~~~~~~~
-------------
Plays audio CDs using libcdio. The URI has the form: "cdda://[DEVICE][/TRACK]". The simplest form cdda:// plays the whole disc in the default drive.
@@ -157,7 +158,7 @@ Plays audio CDs using libcdio. The URI has the form: "cdda://[DEVICE][/TRACK]".
- Request CDParanoia cap the extraction speed to Nx normal CD audio rotation speed, keeping the drive quiet.
curl
~~~~
----
Opens remote files or streams over HTTP using libcurl.
@@ -179,22 +180,22 @@ Note that unless overridden by the below settings (e.g. by setting them to a bla
- Verify the certificate's name against host? `More information <http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html>`_.
ffmpeg
~~~~~~
------
Access to various network protocols implemented by the FFmpeg library: gopher://, rtp://, rtsp://, rtmp://, rtmpt://, rtmps://
file
~~~~
----
Opens local files
mms
~~~
---
Plays streams with the MMS protocol using `libmms <https://launchpad.net/libmms>`_.
nfs
~~~
---
Allows :program:`MPD` to access files on NFSv3 servers without actually mounting them (i.e. in userspace, without help from the kernel's VFS layer). All URIs with the nfs:// scheme are used according to RFC2224. Example:
@@ -205,7 +206,7 @@ Allows :program:`MPD` to access files on NFSv3 servers without actually mounting
Note that this usually requires enabling the "insecure" flag in the server's /etc/exports file, because :program:`MPD` cannot bind to so-called "privileged" ports. Don't fear: this will not make your file server insecure; the flag was named in a time long ago when privileged ports were thought to be meaningful for security. By today's standards, NFSv3 is not secure at all, and if you believe it is, you're already doomed.
smbclient
~~~~~~~~~
---------
Allows :program:`MPD` to access files on SMB/CIFS servers (e.g. Samba or Microsoft Windows). All URIs with the smb:// scheme are used. Example:
@@ -214,7 +215,7 @@ Allows :program:`MPD` to access files on SMB/CIFS servers (e.g. Samba or Microso
mpc add smb://servername/sharename/filename.ogg
qobuz
~~~~~
-----
Play songs from the commercial streaming service Qobuz. It plays URLs in the form qobuz://track/ID, e.g.:
@@ -240,10 +241,15 @@ Play songs from the commercial streaming service Qobuz. It plays URLs in the for
- The `Qobuz format identifier <https://github.com/Qobuz/api-documentation/blob/master/endpoints/track/getFileUrl.md#parameters>`_, i.e. a number which chooses the format and quality to be requested from Qobuz. The default is "5" (320 kbit/s MP3).
tidal
~~~~~
-----
Play songs from the commercial streaming service `Tidal <http://tidal.com/>`_. It plays URLs in the form tidal://track/ID, e.g.:
.. warning::
This plugin is currently defunct because Tidal has changed the
protocol and decided not to share documentation.
.. code-block:: none
mpc add tidal://track/59727857
@@ -266,10 +272,10 @@ Play songs from the commercial streaming service `Tidal <http://tidal.com/>`_. I
.. _decoder_plugins:
Decoder plugins
---------------
===============
adplug
~~~~~~
------
Decodes AdLib files using libadplug.
@@ -283,17 +289,17 @@ Decodes AdLib files using libadplug.
- The sample rate that shall be synthesized by the plugin. Defaults to 48000.
audiofile
~~~~~~~~~
---------
Decodes WAV and AIFF files using libaudiofile.
faad
~~~~
----
Decodes AAC files using libfaad.
ffmpeg
~~~~~~
------
Decodes various codecs using FFmpeg.
@@ -309,12 +315,12 @@ Decodes various codecs using FFmpeg.
- Sets the FFmpeg muxer option probesize, which specifies probing size in bytes, i.e. the size of the data to analyze to get stream information. The `FFmpeg formats documentation <https://ffmpeg.org/ffmpeg-formats.html>`_ has more information.
flac
~~~~
----
Decodes FLAC files using libFLAC.
dsdiff
~~~~~~
------
Decodes DFF files containing DSDIFF data (e.g. SACD rips).
@@ -328,12 +334,12 @@ Decodes DFF files containing DSDIFF data (e.g. SACD rips).
- Decode the least significant bit first. Default is no.
dsf
~~~
---
Decodes DSF files containing DSDIFF data (e.g. SACD rips).
fluidsynth
~~~~~~~~~~
----------
MIDI decoder based on `FluidSynth <http://www.fluidsynth.org/>`_.
@@ -349,7 +355,7 @@ MIDI decoder based on `FluidSynth <http://www.fluidsynth.org/>`_.
- The absolute path of the soundfont file. Defaults to :file:`/usr/share/sounds/sf2/FluidR3_GM.sf2`.
gme
~~~
---
Video game music file emulator based on `game-music-emu <https://bitbucket.org/mpyne/game-music-emu/wiki/Home>`_.
@@ -363,7 +369,7 @@ Video game music file emulator based on `game-music-emu <https://bitbucket.org/m
- Enable more accurate sound emulation.
hybrid_dsd
~~~~~~~~~~
----------
`Hybrid-DSD
<http://dsdmaster.blogspot.de/p/bitperfect-introduces-hybrid-dsd-file.html>`_
@@ -386,12 +392,12 @@ of the file is better.
- This specifies whether to support gapless playback of MP3s which have the necessary headers. Useful if your MP3s have headers with incorrect information. If you have such MP3s, it is highly recommended that you fix them using `vbrfix <http://www.willwap.co.uk/Programs/vbrfix.php>`_ instead of disabling gapless MP3 playback. The default is to support gapless MP3 playback.
mad
~~~
---
Decodes MP3 files using `libmad <http://www.underbit.com/products/mad/>`_.
mikmod
~~~~~~
------
Module player based on `MikMod <http://mikmod.sourceforge.net/>`_.
@@ -407,7 +413,7 @@ Module player based on `MikMod <http://mikmod.sourceforge.net/>`_.
- Sets the sample rate generated by libmikmod. Default is 44100.
modplug
~~~~~~~
-------
Module player based on MODPlug.
@@ -421,27 +427,27 @@ Module player based on MODPlug.
- Number of times to loop the module if it uses backward loops. Default is 0 which prevents looping. -1 loops forever.
mpcdec
~~~~~~
------
Decodes Musepack files using `libmpcdec <http://www.musepack.net/>`_.
mpg123
~~~~~~
------
Decodes MP3 files using `libmpg123 <http://www.mpg123.de/>`_.
opus
~~~~
----
Decodes Opus files using `libopus <http://www.opus-codec.org/>`_.
pcm
~~~
---
Read raw PCM samples. It understands the "audio/L16" MIME type with parameters "rate" and "channels" according to RFC 2586. It also understands the MPD-specific MIME type "audio/x-mpd-float".
sidplay
~~~~~~~
-------
C64 SID decoder based on `libsidplayfp <https://sourceforge.net/projects/sidplay-residfp/>`_ or `libsidplay2 <https://sourceforge.net/projects/sidplay2/>`_.
@@ -463,23 +469,23 @@ C64 SID decoder based on `libsidplayfp <https://sourceforge.net/projects/sidplay
- Only libsidplayfp. Absolute path to basic rom image file.
sndfile
~~~~~~~
-------
Decodes WAV and AIFF files using `libsndfile <http://www.mega-nerd.com/libsndfile/>`_.
vorbis
~~~~~~
------
Decodes Ogg-Vorbis files using `libvorbis <http://www.xiph.org/ogg/vorbis/>`_.
wavpack
~~~~~~~
-------
Decodes WavPack files using `libwavpack <http://www.wavpack.com/>`_.
wildmidi
~~~~~~~~
--------
MIDI decoder based on `libwildmidi <http://www.mindwerks.net/projects/wildmidi/>`_.
@@ -495,10 +501,11 @@ MIDI decoder based on `libwildmidi <http://www.mindwerks.net/projects/wildmidi/>
.. _encoder_plugins:
Encoder plugins
---------------
===============
flac
~~~~
----
Encodes into `FLAC <https://xiph.org/flac/>`_ (lossless).
.. list-table::
@@ -511,7 +518,7 @@ Encodes into `FLAC <https://xiph.org/flac/>`_ (lossless).
- Sets the libFLAC compression level. The levels range from 0 (fastest, least compression) to 8 (slowest, most compression).
lame
~~~~
----
Encodes into MP3 using the `LAME <http://lame.sourceforge.net/>`_ library.
@@ -527,12 +534,12 @@ Encodes into MP3 using the `LAME <http://lame.sourceforge.net/>`_ library.
- Sets the bit rate in kilobit per second. Cannot be used with quality.
null
~~~~
----
Does not encode anything, passes the input PCM data as-is.
shine
~~~~~
-----
Encodes into MP3 using the `Shine <https://github.com/savonet/shine>`_ library.
@@ -546,7 +553,7 @@ Encodes into MP3 using the `Shine <https://github.com/savonet/shine>`_ library.
- Sets the bit rate in kilobit per second.
twolame
~~~~~~~
-------
Encodes into MP2 using the `TwoLAME <http://www.twolame.org/>`_ library.
@@ -562,7 +569,7 @@ Encodes into MP2 using the `TwoLAME <http://www.twolame.org/>`_ library.
- Sets the bit rate in kilobit per second. Cannot be used with quality.
opus
~~~~
----
Encodes into `Ogg Opus <http://www.opus-codec.org/>`_.
@@ -584,7 +591,7 @@ Encodes into `Ogg Opus <http://www.opus-codec.org/>`_.
.. _vorbis_plugin:
vorbis
~~~~~~
------
Encodes into `Ogg Vorbis <http://www.vorbis.com/>`_.
@@ -600,13 +607,13 @@ Encodes into `Ogg Vorbis <http://www.vorbis.com/>`_.
- Sets the bit rate in kilobit per second. Cannot be used with quality.
wave
~~~~
----
Encodes into WAV (lossless).
.. _resampler_plugins:
Resampler plugins
-----------------
=================
The resampler can be configured in a block named resampler, for example:
@@ -629,12 +636,12 @@ The following table lists the resampler options valid for all plugins:
- The name of the plugin.
internal
~~~~~~~~
--------
A resampler built into :program:`MPD`. Its quality is very poor, but its CPU usage is low. This is the fallback if :program:`MPD` was compiled without an external resampler.
libsamplerate
~~~~~~~~~~~~~
-------------
A resampler using `libsamplerate <http://www.mega-nerd.com/SRC/>`_ a.k.a. Secret Rabbit Code (SRC).
@@ -667,7 +674,7 @@ The following converter types are provided by libsamplerate:
- Linear interpolator, very fast, poor quality.
soxr
~~~~
----
A resampler using `libsoxr <http://sourceforge.net/projects/soxr/>`_, the SoX Resampler library
@@ -690,13 +697,15 @@ Valid quality values for libsoxr:
* "low"
* "quick"
.. _output_plugins:
Output plugins
--------------
==============
.. _alsa_plugin:
alsa
~~~~
----
The `Advanced Linux Sound Architecture (ALSA) <http://www.alsa-project.org/>`_ plugin uses libasound. It is recommended if you are using Linux.
@@ -755,7 +764,7 @@ The following attributes can be configured at runtime using the outputset comman
ao
~~
--
The ao plugin uses the portable `libao <https://www.xiph.org/ao/>`_ library. Use only if there is no native plugin for your operating system.
.. list-table::
@@ -772,7 +781,8 @@ The ao plugin uses the portable `libao <https://www.xiph.org/ao/>`_ library. Use
- This specifies how many bytes to write to the audio device at once. This parameter is to work around a bug in older versions of libao on sound cards with very small buffers. The default is 1024.
sndio
~~~~~
-----
The sndio plugin uses the `sndio <http://www.sndio.org/>`_ library. It should normally be used on OpenBSD.
.. list-table::
@@ -787,7 +797,7 @@ The sndio plugin uses the `sndio <http://www.sndio.org/>`_ library. It should no
- Set the application buffer time in milliseconds.
fifo
~~~~
----
The fifo plugin writes raw PCM data to a FIFO (First In, First Out) file. The data can be read by another program.
@@ -800,8 +810,18 @@ The fifo plugin writes raw PCM data to a FIFO (First In, First Out) file. The da
* - **path P**
- This specifies the path of the FIFO to write to. Must be an absolute path. If the path does not exist, it will be created when MPD is started, and removed when MPD is stopped. The FIFO will be created with the same user and group as MPD is running as. Default permissions can be modified by using the builtin shell command umask. If a FIFO already exists at the specified path it will be reused, and will not be removed when MPD is stopped. You can use the "mkfifo" command to create this, and then you may modify the permissions to your liking.
haiku
-----
Use the SoundPlayer API on the Haiku operating system.
This plugin is unmaintained and contains known bugs. It will be
removed soon, unless there is a new maintainer.
jack
~~~~
----
The jack plugin connects to a `JACK server <http://jackaudio.org/>`_.
.. list-table::
@@ -824,7 +844,8 @@ The jack plugin connects to a `JACK server <http://jackaudio.org/>`_.
- Sets the size of the ring buffer for each channel. Do not configure this value unless you know what you're doing.
httpd
~~~~~
-----
The httpd plugin creates a HTTP server, similar to `ShoutCast <http://www.shoutcast.com/>`_ / `IceCast <http://icecast.org/>`_. HTTP streaming clients like mplayer, VLC, and mpv can connect to it.
It is highly recommended to configure a fixed format, because a stream cannot switch its audio format on-the-fly when the song changes.
@@ -838,14 +859,15 @@ It is highly recommended to configure a fixed format, because a stream cannot sw
* - **port P**
- Binds the HTTP server to the specified port.
* - **bind_to_address ADDR**
- Binds the HTTP server to the specified address (IPv4, IPv6 or UNIX socket). Multiple addresses in parallel are not supported.
- Binds the HTTP server to the specified address (IPv4, IPv6 or local socket). Multiple addresses in parallel are not supported.
* - **encoder NAME**
- Chooses an encoder plugin. A list of encoder plugins can be found in the encoder plugin reference :ref:`encoder_plugins`.
* - **max_clients MC**
- Sets a limit, number of concurrent clients. When set to 0 no limit will apply.
null
~~~~
----
The null plugin does nothing. It discards everything sent to it.
.. list-table::
@@ -860,7 +882,8 @@ The null plugin does nothing. It discards everything sent to it.
.. _oss_plugin:
oss
~~~
---
The "Open Sound System" plugin is supported on most Unix platforms.
On Linux, OSS has been superseded by ALSA. Use the ALSA output plugin :ref:`alsa_plugin` instead of this one on Linux.
@@ -888,7 +911,7 @@ The according hardware mixer plugin understands the following settings:
- Choose a mixer control, defaulting to PCM.
openal
~~~~~~
------
The "OpenAL" plugin uses `libopenal <http://kcat.strangesoft.net/openal.html>`_. It is supported on many platforms. Use only if there is no native plugin for your operating system.
.. list-table::
@@ -901,7 +924,7 @@ The "OpenAL" plugin uses `libopenal <http://kcat.strangesoft.net/openal.html>`_.
- Sets the device which should be used. This can be any valid OpenAL device name. If not specified, then libopenal will choose a default device.
osx
~~~
---
The "Mac OS X" plugin uses Apple's CoreAudio API.
.. list-table::
@@ -922,7 +945,7 @@ The "Mac OS X" plugin uses Apple's CoreAudio API.
The channel map may not refer to outputs that do not exist according to the format. If the format is "*:*:1" (mono) and you have a four-channel sound card then "-1,-1,0,0" (dual mono output on the second pair of sound card outputs) is a valid channel map but "-1,-1,0,1" is not because the second channel ('1') does not exist when the output is mono.
pipe
~~~~
----
The pipe plugin starts a program and writes raw PCM data into its standard input.
@@ -938,7 +961,7 @@ The pipe plugin starts a program and writes raw PCM data into its standard input
.. _pulse_plugin:
pulse
~~~~~
-----
The pulse plugin connects to a `PulseAudio <http://www.freedesktop.org/wiki/Software/PulseAudio/>`_ server. Requires libpulse.
.. list-table::
@@ -955,7 +978,7 @@ The pulse plugin connects to a `PulseAudio <http://www.freedesktop.org/wiki/Soft
- Specifies a linear scaling coefficient (ranging from 0.5 to 5.0) to apply when adjusting volume through :program:`MPD`. For example, chosing a factor equal to ``"0.7"`` means that setting the volume to 100 in :program:`MPD` will set the PulseAudio volume to 70%, and a factor equal to ``"3.5"`` means that volume 100 in :program:`MPD` corresponds to a 350% PulseAudio volume.
recorder
~~~~~~~~
--------
The recorder plugin writes the audio played by :program:`MPD` to a file. This may be useful for recording radio streams.
.. list-table::
@@ -967,13 +990,13 @@ The recorder plugin writes the audio played by :program:`MPD` to a file. This ma
* - **path P**
- Write to this file.
* - **format_path P**
- An alternative to path which provides a format string referring to tag values. The special tag iso8601 emits the current date and time in `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ format (UTC). Every time a new song starts or a new tag gets received from a radio station, a new file is opened. If the format does not render a file name, nothing is recorded. A tag name enclosed in percent signs ('%') is replaced with the tag value. Example: :file:`~/.mpd/recorder/%artist% - %title%.ogg`. Square brackets can be used to group a substring. If none of the tags referred in the group can be found, the whole group is omitted. Example: [~/.mpd/recorder/[%artist% - ]%title%.ogg] (this omits the dash when no artist tag exists; if title also doesn't exist, no file is written). The operators "|" (logical "or") and "&" (logical "and") can be used to select portions of the format string depending on the existing tag values. Example: ~/.mpd/recorder/[%title%|%name%].ogg (use the "name" tag if no title exists)
- An alternative to path which provides a format string referring to tag values. The special tag iso8601 emits the current date and time in `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ format (UTC). Every time a new song starts or a new tag gets received from a radio station, a new file is opened. If the format does not render a file name, nothing is recorded. A tag name enclosed in percent signs ('%') is replaced with the tag value. Example: :file:`-/.mpd/recorder/%artist% - %title%.ogg`. Square brackets can be used to group a substring. If none of the tags referred in the group can be found, the whole group is omitted. Example: [-/.mpd/recorder/[%artist% - ]%title%.ogg] (this omits the dash when no artist tag exists; if title also doesn't exist, no file is written). The operators "|" (logical "or") and "&" (logical "and") can be used to select portions of the format string depending on the existing tag values. Example: -/.mpd/recorder/[%title%|%name%].ogg (use the "name" tag if no title exists)
* - **encoder NAME**
- Chooses an encoder plugin. A list of encoder plugins can be found in the encoder plugin reference :ref:`encoder_plugins`.
shout
~~~~~
-----
The shout plugin connects to a ShoutCast or IceCast server using libshout. It forwards tags to this server.
You must set a format.
@@ -1017,7 +1040,7 @@ You must set a format.
.. _sles_output:
sles
~~~~
----
Plugin using the `OpenSL ES <https://www.khronos.org/opensles/>`__
audio API. Its primary use is local playback on Android, where
@@ -1025,7 +1048,7 @@ audio API. Its primary use is local playback on Android, where
solaris
~~~~~~~
-------
The "Solaris" plugin runs only on SUN Solaris, and plays via /dev/audio.
.. list-table::
@@ -1037,46 +1060,80 @@ The "Solaris" plugin runs only on SUN Solaris, and plays via /dev/audio.
* - **device PATH**
- Sets the path of the audio device, defaults to /dev/audio.
.. _filter_plugins:
Filter plugins
==============
normalize
---------
Normalize the volume during playback (at the expensve of quality).
null
----
A no-op filter. Audio data is returned as-is.
route
-----
Reroute channels.
.. list-table::
:widths: 20 80
:header-rows: 1
* - Setting
- Description
* - **routes "0>0, 1>1, ..."**
- Specifies the channel mapping.
.. _playlist_plugins:
Playlist plugins
----------------
================
asx
~~~
---
Reads .asx playlist files.
cue
~~~
---
Reads .cue files.
embcue
~~~~~~
------
Reads CUE sheets from the "CUESHEET" tag of song files.
m3u
~~~
---
Reads .m3u playlist files.
extm3u
~~~~~~
------
Reads extended .m3u playlist files.
flac
~~~~
----
Reads the cuesheet metablock from a FLAC file.
pls
~~~
---
Reads .pls playlist files.
rss
~~~
---
Reads music links from .rss files.
soundcloud
~~~~~~~~~~
----------
Download playlist from SoundCloud. It accepts URIs starting with soundcloud://.
.. list-table::
@@ -1089,5 +1146,5 @@ Download playlist from SoundCloud. It accepts URIs starting with soundcloud://.
- An API key to access the SoundCloud servers.
xspf
~~~~
----
Reads XSPF playlist files.

@@ -14,6 +14,9 @@ Once the client is connected to the server, they conduct a
conversation until the client closes the connection. The
conversation flow is always initiated by the client.
All data between the client and the server is encoded in
UTF-8.
The client transmits a command sequence, terminated by the
newline character ``\n``. The server will
respond with one or more lines, the last of which will be a
@@ -42,9 +45,6 @@ quotation marks.
Argument strings are separated from the command and any other
arguments by linear white-space (' ' or '\\t').
All data between the client and the server is encoded in
UTF-8.
Responses
=========
@@ -52,6 +52,28 @@ A command returns ``OK`` on completion or
``ACK some error`` on failure. These
denote the end of command execution.
Some commands return more data before the response ends with ``OK``.
Each line is usually in the form ``NAME: VALUE``. Example::
foo: bar
OK
.. _binary:
Binary Responses
----------------
Some commands can return binary data. This is initiated by a line
containing ``binary: 1234`` (followed as usual by a newline). After
that, the specified number of bytes of binary data follows, then a
newline, and finally the ``OK`` line. Example::
foo: bar
binary: 42
<42 bytes>
OK
Failure responses
-----------------
@@ -112,9 +134,9 @@ list begins with `command_list_begin` or
`command_list_ok_begin` and ends with
`command_list_end`.
It does not execute any commands until the list has ended.
The return value is whatever the return for a list of commands
is. On success for all commands,
It does not execute any commands until the list has ended. The
response is a concatentation of all individual responses.
On success for all commands,
``OK`` is returned. If a command
fails, no more commands are executed and the appropriate
``ACK`` error is returned. If
@@ -144,15 +166,20 @@ syntax::
``EXPRESSION`` is a string enclosed in parantheses which can be one
of:
- ``(TAG == 'VALUE')``: match a tag value.
``(TAG != 'VALUE')``: mismatch a tag value.
The special tag "*any*" checks all
tag values.
*albumartist* looks for
- ``(TAG == 'VALUE')``: match a tag value; if there are multiple
values of the given type, at least one must match.
``(TAG != 'VALUE')``: mismatch a tag value; if there are multiple
values of the given type, none of them must match.
The special tag ``any`` checks all
tag types.
``AlbumArtist`` looks for
``VALUE`` in ``AlbumArtist``
and falls back to ``Artist`` tags if
``AlbumArtist`` does not exist.
``VALUE`` is what to find.
An empty value string means: match only if the given tag type does
not exist at all; this implies that negation with an empty value
checks for the existence of the given tag type.
- ``(TAG contains 'VALUE')`` checks if the given value is a substring
of the tag value.
@@ -173,12 +200,13 @@ of:
file's time stamp with the given value (ISO 8601 or UNIX
time stamp).
- ``(AudioFormat == 'SAMPLERATE:BITS:CHANNELS')``:
compares the audio format with the given value.
- ``(AudioFormat == 'SAMPLERATE:BITS:CHANNELS')``: compares the audio
format with the given value. See :ref:`audio_output_format` for a
detailed explanation.
- ``(AudioFormat =~ 'SAMPLERATE:BITS:CHANNELS')``:
matches the audio format with the given mask (i.e. one
or more attributes may be "*").
or more attributes may be ``*``).
- ``(!EXPRESSION)``: negate an expression. Note that each expression
must be enclosed in parantheses, e.g. :code:`(!(artist == 'VALUE'))`
@@ -207,11 +235,11 @@ backslash.
Example expression which matches an artist named ``foo'bar"``::
(artist "foo\'bar\"")
(Artist == "foo\'bar\"")
At the protocol level, the command must look like this::
find "(artist \"foo\\'bar\\\"\")"
find "(Artist == \"foo\\'bar\\\"\")"
The double quotes enclosing the artist name must be escaped because
they are inside a double-quoted ``find`` parameter. The single quote
@@ -409,15 +437,18 @@ Querying :program:`MPD`'s status
- ``songid``: playlist songid of the current song stopped on or playing
- ``nextsong`` [#since_0_15]_: playlist song number of the next song to be played
- ``nextsongid`` [#since_0_15]_: playlist songid of the next song to be played
- ``time``: total time elapsed (of current playing/paused song)
- ``time``: total time elapsed (of current playing/paused song) in seconds
(deprecated, use ``elapsed`` instead)
- ``elapsed`` [#since_0_16]_: Total time elapsed within the current song, but with higher resolution.
- ``elapsed`` [#since_0_16]_: Total time elapsed within the
current song in seconds, but with higher resolution.
- ``duration`` [#since_0_20]_: Duration of the current song in seconds.
- ``bitrate``: instantaneous bitrate in kbps
- ``xfade``: ``crossfade`` in seconds
- ``mixrampdb``: ``mixramp`` threshold in dB
- ``mixrampdelay``: ``mixrampdelay`` in seconds
- ``audio``: The format emitted by the decoder plugin during playback, format: ``*samplerate:bits:channels*``. Check the user manual for a detailed explanation.
- ``audio``: The format emitted by the decoder plugin during
playback, format: ``samplerate:bits:channels``. See
:ref:`audio_output_format` for a detailed explanation.
- ``updating_db``: ``job id``
- ``error``: if there is an error, returns message here
@@ -432,7 +463,7 @@ Querying :program:`MPD`'s status
- ``albums``: number of albums
- ``songs``: number of songs
- ``uptime``: daemon uptime in seconds
- ``db_playtime``: sum of all song times in the db
- ``db_playtime``: sum of all song times in the database in seconds
- ``db_update``: last db update in UNIX time
- ``playtime``: time length of music played
@@ -594,7 +625,7 @@ Whenever possible, ids should be used.
Deletes the song ``SONGID`` from the
playlist
:command:`move {FROM} [{START:END} | {TO}]`
:command:`move [{FROM} | {START:END}] {TO}`
Moves the song at ``FROM`` or range of songs
at ``START:END`` [#since_0_15]_ to ``TO``
in the playlist.
@@ -714,7 +745,9 @@ and without the `.m3u` suffix).
Some of the commands described in this section can be used to
run playlist plugins instead of the hard-coded simple
`m3u` parser. They can access playlists in
the music directory (relative path including the suffix) or
the music directory (relative path including the suffix),
playlists in arbitrary location (absolute path including the suffix;
allowed only for clients that are connected via local socket), or
remote playlists (absolute URI with a supported scheme).
:command:`listplaylist {NAME}`
@@ -783,7 +816,7 @@ The music database
Returns the file size and actual number
of bytes read at the requested offset, followed
by the chunk requested as raw bytes, then a
by the chunk requested as raw bytes (see :ref:`binary`), then a
newline and the completion code.
Example::
@@ -791,8 +824,7 @@ The music database
albumart
size: 1024768
binary: 8192
<8192 bytes>
OK
<8192 bytes>OK
:command:`count {FILTER} [group {GROUPTYPE}]`
Count the number of songs and their total playtime in
@@ -853,8 +885,7 @@ The music database
:command:`list {TYPE} {FILTER} [group {GROUPTYPE}]`
Lists unique tags values of the specified type.
``TYPE`` can be any tag supported by
:program:`MPD` or
*file*.
:program:`MPD`.
Additional arguments may specify a :ref:`filter <filter_syntax>`.
The *group* keyword may be used
@@ -865,6 +896,10 @@ The music database
list album group albumartist
``list file`` was implemented in an early :program:`MPD` version,
but does not appear to make a lot of sense. It still works (to
avoid breaking compatibility), but is deprecated.
.. _command_listall:
:command:`listall [URI]`
@@ -924,7 +959,7 @@ The music database
This command may be used to list metadata of remote
files (e.g. URI beginning with "http://" or "smb://").
Clients that are connected via UNIX domain socket may
Clients that are connected via local socket may
use this command to read the tags of an arbitrary local
file (URI is an absolute path).
@@ -1046,7 +1081,8 @@ Stickers
"Stickers" [#since_0_15]_ are pieces of
information attached to existing
:program:`MPD` objects (e.g. song files,
directories, albums). Clients can create arbitrary name/value
directories, albums; but currently, they are only implemented for
song). Clients can create arbitrary name/value
pairs. :program:`MPD` itself does not assume
any special meaning in them.
@@ -1215,7 +1251,7 @@ Reflection
:command:`config`
Dumps configuration values that may be interesting for
the client. This command is only permitted to "local"
clients (connected via UNIX domain socket).
clients (connected via local socket).
The following response attributes are available:

@@ -54,7 +54,7 @@ Download the source tarball from the `MPD home page <https://musicpd.org>`_ and
In any case, you need:
* a C++14 compiler (e.g. gcc 6.0 or clang 3.9)
* `Meson 0.47.2 <http://mesonbuild.com/>`__ and `Ninja
* `Meson 0.49.0 <http://mesonbuild.com/>`__ and `Ninja
<https://ninja-build.org/>`__
* Boost 1.58
* pkg-config
@@ -365,10 +365,14 @@ More information can be found in the :ref:`decoder_plugins` reference.
Configuring encoder plugins
---------------------------
Encoders are used by some of the output plugins (such as shout). The encoder settings are included in the audio_output section.
Encoders are used by some of the output plugins (such as shout). The
encoder settings are included in the ``audio_output`` section, see :ref:`config_audio_output`.
More information can be found in the :ref:`encoder_plugins` reference.
.. _config_audio_output:
Configuring audio outputs
-------------------------
@@ -398,14 +402,9 @@ The following table lists the audio_output options valid for all plugins:
- The name of the plugin
* - **name**
- The name of the audio output. It is visible to the client. Some plugins also use it internally, e.g. as a name registered in the PULSE server.
* - **format**
- 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.
Any of the three attributes may be an asterisk to specify that this attribute should not be enforced, example: 48000:16:*. *:*:* is equal to not having a format specification.
The following values are valid for bits: 8 (signed 8 bit integer samples), 16, 24 (signed 24 bit integer samples padded to 32 bit), 32 (signed 32 bit integer samples), f (32 bit floating point, -1.0 to 1.0), "dsd" means DSD (Direct Stream Digital). For DSD, there are special cases such as "dsd64", which allows you to omit the sample rate (e.g. dsd512:2 for stereo DSD512, i.e. 22.5792 MHz).
The sample rate is special for DSD: :program:`MPD` counts the number of bytes, not bits. Thus, a DSD "bit" rate of 22.5792 MHz (DSD512) is 2822400 from :program:`MPD`'s point of view (44100*512/8).
* - **format samplerate:bits:channels**
- Always open the audio output with the specified audio format, regardless of the format of the input file. This is optional for most plugins.
See :ref:`audio_output_format` for a detailed description of the value.
* - **enabed yes|no**
- Specifies whether this audio output is enabled when :program:`MPD` is started. By default, all audio outputs are enabled. This is just the default setting when there is no state file; with a state file, the previous state is restored.
* - **tags yes|no**
@@ -421,6 +420,15 @@ The following table lists the audio_output options valid for all plugins:
implement an external mixer :ref:`external_mixer`) or no mixer
(:samp:`none`). By default, the hardware mixer is used for
devices which support it, and none for the others.
* - **filters "name,...**"
- The specified configured filters are instantiated in the given
order. Each filter name refers to a ``filter`` block, see
:ref:`config_filter`.
More information can be found in the :ref:`output_plugins` reference.
.. _config_filter:
Configuring filters
-------------------
@@ -436,6 +444,9 @@ To configure a filter, add a :code:`filter` block to :file:`mpd.conf`:
name "software volume"
}
Configured filters may then be added to the ``filters`` setting of an
``audio_output`` section, see :ref:`config_audio_output`.
The following table lists the filter options valid for all plugins:
.. list-table::
@@ -449,6 +460,9 @@ The following table lists the filter options valid for all plugins:
* - **name**
- The name of the filter
More information can be found in the :ref:`filter_plugins` reference.
Configuring playlist plugins
----------------------------
@@ -485,13 +499,34 @@ reference.
Audio Format Settings
---------------------
Global Audio Format
~~~~~~~~~~~~~~~~~~~
.. _audio_output_format:
The setting audio_output_format forces :program:`MPD` to use one audio format for all outputs. Doing that is usually not a good idea. The values are the same as in format in the audio_output section.
Global Audio Format
^^^^^^^^^^^^^^^^^^^
The setting ``audio_output_format`` forces :program:`MPD` to use one
audio format for all outputs. Doing that is usually not a good idea.
The value is specified as ``samplerate:bits:channels``.
Any of the three attributes may be an asterisk to specify that this
attribute should not be enforced, example: ``48000:16:*``.
``*:*:*`` is equal to not having a format specification.
The following values are valid for bits: ``8`` (signed 8 bit integer
samples), ``16``, ``24`` (signed 24 bit integer samples padded to 32
bit), ``32`` (signed 32 bit integer samples), ``f`` (32 bit floating
point, -1.0 to 1.0), ``dsd`` means DSD (Direct Stream Digital). For
DSD, there are special cases such as ``dsd64``, which allows you to
omit the sample rate (e.g. ``dsd512:2`` for stereo DSD512,
i.e. 22.5792 MHz).
The sample rate is special for DSD: :program:`MPD` counts the number
of bytes, not bits. Thus, a DSD "bit" rate of 22.5792 MHz (DSD512) is
2822400 from :program:`MPD`'s point of view (44100*512/8).
Resampler
~~~~~~~~~
^^^^^^^^^
Sometimes, music needs to be resampled before it can be played; for example, CDs use a sample rate of 44,100 Hz while many cheap audio chips can only handle 48,000 Hz. Resampling reduces the quality and consumes a lot of CPU. There are different options, some of them optimized for high quality and others for low CPU usage, but you can't have both at the same time. Often, the resampler is the component that is responsible for most of :program:`MPD`'s CPU usage. Since :program:`MPD` comes with high quality defaults, it may appear that :program:`MPD` consumes more CPU than other software.
@@ -504,7 +539,7 @@ Client Connections
.. _listeners:
Listeners
~~~~~~~~~
^^^^^^^^^
The setting :code:`bind_to_address` specifies which addresses
:program:`MPD` listens on for connections from clients. It can be
@@ -531,6 +566,12 @@ choice::
bind_to_address "/var/run/mpd/socket"
On Linux, local sockets can be bound to a name without a socket inode
on the filesystem; MPD implements this by prepending ``@`` to the
address::
bind_to_address "@mpd"
If no port is specified, the default port is 6600. This default can
be changed with the port setting::
@@ -541,7 +582,7 @@ used.
Permissions and Passwords
~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^
By default, all clients are unauthenticated and have a full set of permissions. This can be restricted with the settings :code:`default_permissions` and :code:`password`.
@@ -604,7 +645,7 @@ Other Settings
Section :ref:`tags` contains a list of supported tags.
The State File
~~~~~~~~~~~~~~
^^^^^^^^^^^^^^
The state file is a file where :program:`MPD` saves and restores its state (play queue, playback position etc.) to keep it persistent across restarts and reboots. It is an optional setting.
@@ -622,7 +663,7 @@ The State File
- Auto-save the state file this number of seconds after each state change. Defaults to 120 (2 minutes).
The Sticker Database
~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^
"Stickers" are pieces of information attached to songs. Some clients
use them to store ratings and other volatile data. This feature
@@ -639,7 +680,7 @@ requires :program:`SQLite`, compile-time configure option
- The location of the sticker database.
Resource Limitations
~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^
These settings are various limitations to prevent :program:`MPD` from using too many resources (denial of service).
@@ -661,7 +702,7 @@ These settings are various limitations to prevent :program:`MPD` from using too
- The maximum size of the output buffer to a client (maximum response size). Default is 8192 (8 MiB).
Buffer Settings
~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^
Do not change these unless you know what you are doing.
@@ -675,7 +716,7 @@ Do not change these unless you know what you are doing.
- Adjust the size of the internal audio buffer. Default is 4096 (4 MiB).
Zeroconf
~~~~~~~~
^^^^^^^^
If Zeroconf support (`Avahi <http://avahi.org/>`_ or Apple's Bonjour)
was enabled at compile time with :code:`-Dzeroconf=...`,
@@ -761,10 +802,12 @@ You can verify whether the real-time scheduler is active with the ps command:
The CLS column shows the CPU scheduler; TS is the normal scheduler; FF and RR are real-time schedulers. In this example, two threads use the real-time scheduler: the output thread and the rtio (real-time I/O) thread; these two are the important ones. The database update thread uses the idle scheduler ("IDL in ps), which only gets CPU when no other process needs it.
Note
~~~~
.. note::
There is a rumor that real-time scheduling improves audio quality. That is not true. All it does is reduce the probability of skipping (audio buffer xruns) when the computer is under heavy load.
There is a rumor that real-time scheduling improves audio
quality. That is not true. All it does is reduce the probability of
skipping (audio buffer xruns) when the computer is under heavy
load.
Using MPD
*********
@@ -792,7 +835,7 @@ Depending on the size of your music collection and the speed of the storage, thi
To exclude a file from the update, create a file called :file:`.mpdignore` in its parent directory. Each line of that file may contain a list of shell wildcards. Matching files in the current directory and all subdirectories are excluded.
Mounting other storages into the music directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:program:`MPD` has various storage plugins of which multiple instances can be "mounted" into the music directory. This way, you can use local music, file servers and USB sticks at the same time. Example:
@@ -860,7 +903,7 @@ To verify if :program:`MPD` converts the audio format, enable verbose logging, a
.. code-block:: none
decoder: audio_format=44100:24:2, seekable=true
output: opened plugin=alsa name="An ALSA output"audio_format=44100:16:2
output: opened plugin=alsa name="An ALSA output" audio_format=44100:16:2
output: converting from 44100:24:2
This example shows that a 24 bit file is being played, but the sound chip cannot play 24 bit. It falls back to 16 bit, discarding 8 bit.
@@ -887,7 +930,7 @@ Check list for bit-perfect playback:
device (:samp:`hw:0,0` or similar).
* Don't use software volume (setting :code:`mixer_type`).
* Don't force :program:`MPD` to use a specific audio format (settings
:code:`format`, :code:`audio_output_format`).
:code:`format`, :ref:`audio_output_format <audio_output_format>`).
* Verify that you are really doing bit-perfect playback using :program:`MPD`'s verbose log and :file:`/proc/asound/card*/pcm*p/sub*/hw_params`. Some DACs can also indicate the audio format.
Direct Stream Digital (DSD)
@@ -938,18 +981,18 @@ Support
-------
Getting Help
~~~~~~~~~~~~
^^^^^^^^^^^^
The :program:`MPD` project runs a `forum <https://forum.musicpd.org/>`_ and an IRC channel (#mpd on Freenode) for requesting help. Visit the MPD help page for details on how to get help.
Common Problems
~~~~~~~~~~~~~~~
^^^^^^^^^^^^^^^
1. Database
^^^^^^^^^^^
"""""""""""
Question: I can't see my music in the MPD database!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Check your :code:`music_directory` setting.
* Does the MPD user have read permission on all music files, and read+execute permission on all music directories (and all of their parent directories)?
@@ -957,22 +1000,22 @@ Question: I can't see my music in the MPD database!
* Did you enable all relevant decoder plugins at compile time? :command:`mpd --version` will tell you.
Question: MPD doesn't read ID3 tags!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* You probably compiled :program:`MPD` without libid3tag. :command:`mpd --version` will tell you.
2. Playback
^^^^^^^^^^^
"""""""""""
Question: I can't hear music on my client!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* That problem usually follows a misunderstanding of the nature of :program:`MPD`. :program:`MPD` is a remote-controlled music player, not a music distribution system. Usually, the speakers are connected to the box where :program:`MPD` runs, and the :program:`MPD` client only sends control commands, but the client does not actually play your music.
:program:`MPD` has output plugins which allow hearing music on a remote host (such as httpd), but that is not :program:`MPD`'s primary design goal.
Question: "Device or resource busy"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This ALSA error means that another program uses your sound hardware exclusively. You can stop that program to allow :program:`MPD` to use it.
@@ -991,7 +1034,7 @@ Your bug report should contain:
* be clear about what you expect MPD to do, and what is actually happening
MPD crashes
~~~~~~~~~~~
^^^^^^^^^^^
All :program:`MPD` crashes are bugs which must be fixed by a developer, and you should write a bug report. (Many crash bugs are caused by codec libraries used by :program:`MPD`, and then that library must be fixed; but in any case, the :program:`MPD` `bug tracker <https://github.com/MusicPlayerDaemon/MPD/issues>`_ is a good place to report it first if you don't know.)

@@ -1,8 +1,8 @@
project(
'mpd',
['c', 'cpp'],
version: '0.21.5',
meson_version: '>= 0.47.2',
version: '0.21.11',
meson_version: '>= 0.49.0',
default_options: [
'c_std=c99',
'cpp_std=c++14'
@@ -20,7 +20,7 @@ conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PROTOCOL_VERSION', '0.21.4')
conf.set_quoted('PROTOCOL_VERSION', '0.21.11')
conf.set_quoted('SYSTEM_CONFIG_FILE_LOCATION', join_paths(get_option('prefix'), get_option('sysconfdir'), 'mpd.conf'))
common_cppflags = [
@@ -367,8 +367,10 @@ basic_dep = declare_dependency(
if enable_database
subdir('src/storage')
subdir('src/db')
else
storage_glue_dep = dependency('', required: false)
endif
subdir('src/db')
if neighbor_glue_dep.found()
sources += 'src/command/NeighborCommands.cxx'
@@ -390,6 +392,7 @@ more_deps = []
if is_android
subdir('src/java')
target_type = 'shared_library'
target_name = 'mpd'
link_args += [
'-Wl,--no-undefined,-shared,-Bsymbolic',
'-llog',
@@ -399,12 +402,20 @@ if is_android
declare_dependency(sources: [classes_jar]),
java_dep,
]
elif is_haiku
target_type = 'executable'
target_name = 'mpd.nores'
link_args += [
'-lnetwork',
'-lbe',
]
else
target_type = 'executable'
target_name = 'mpd'
endif
mpd = build_target(
'mpd',
target_name,
sources,
target_type: target_type,
include_directories: inc,
@@ -443,6 +454,14 @@ endif
if is_haiku
subdir('src/haiku')
custom_target(
'mpd',
output: 'mpd',
input: [mpd, rsrc],
command: [addres, '@OUTPUT@', '@INPUT0@', '@INPUT1@'],
install: true,
install_dir: get_option('bindir'),
)
endif
configure_file(output: 'config.h', configuration: conf)

@@ -112,8 +112,8 @@ liblame = AutotoolsProject(
)
ffmpeg = FfmpegProject(
'http://ffmpeg.org/releases/ffmpeg-4.1.1.tar.xz',
'373749824dfd334d84e55dff406729edfd1606575ee44dd485d97d45ea4d2d86',
'http://ffmpeg.org/releases/ffmpeg-4.1.3.tar.xz',
'0c3020452880581a8face91595b239198078645e7d7184273b8bcc7758beb63d',
'lib/libavcodec.a',
[
'--disable-shared', '--enable-static',
@@ -341,8 +341,8 @@ ffmpeg = FfmpegProject(
)
curl = AutotoolsProject(
'http://curl.haxx.se/download/curl-7.64.0.tar.xz',
'2f2f13fa34d44aa29cb444077ad7dc4dc6d189584ad552e0aaeb06e608af6001',
'http://curl.haxx.se/download/curl-7.64.1.tar.xz',
'9252332a7f871ce37bfa7f78bdd0a0e3924d8187cc27cb57c76c9474a7168fb3',
'lib/libcurl.a',
[
'--disable-shared', '--enable-static',
@@ -375,8 +375,8 @@ libexpat = AutotoolsProject(
)
libnfs = AutotoolsProject(
'https://github.com/sahlberg/libnfs/archive/libnfs-3.0.0.tar.gz',
'445d92c5fc55e4a5b115e358e60486cf8f87ee50e0103d46a02e7fb4618566a5',
'https://github.com/sahlberg/libnfs/archive/libnfs-4.0.0.tar.gz',
'6ee77e9fe220e2d3e3b1f53cfea04fb319828cc7dbb97dd9df09e46e901d797d',
'lib/libnfs.a',
[
'--disable-shared', '--enable-static',
@@ -387,12 +387,12 @@ libnfs = AutotoolsProject(
'--disable-utils', '--disable-examples',
],
base='libnfs-libnfs-3.0.0',
base='libnfs-libnfs-4.0.0',
autoreconf=True,
)
boost = BoostProject(
'http://downloads.sourceforge.net/project/boost/boost/1.69.0/boost_1_69_0.tar.bz2',
'8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406',
'http://downloads.sourceforge.net/project/boost/boost/1.70.0/boost_1_70_0.tar.bz2',
'430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778',
'include/boost/version.hpp',
)

@@ -108,17 +108,17 @@ static constexpr Domain cmdline_domain("cmdline");
gcc_noreturn
static void version(void)
{
printf("Music Player Daemon " VERSION " (%s)\n"
printf("Music Player Daemon " VERSION " (%s)"
"\n"
"Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
"Copyright 2008-2018 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"
"warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
GIT_VERSION);
#ifdef ENABLE_DATABASE
"\n"
"Database plugins:\n",
GIT_VERSION);
printf("\n"
"Database plugins:\n");
for (auto i = database_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
@@ -129,18 +129,18 @@ static void version(void)
for (auto i = storage_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
printf("\n"
printf("\n");
#endif
#ifdef ENABLE_NEIGHBOR_PLUGINS
"\n"
printf("\n"
"Neighbor plugins:\n");
for (auto i = neighbor_plugins; *i != nullptr; ++i)
printf(" %s", (*i)->name);
printf("\n"
#endif
printf("\n"
"\n"
"Decoders plugins:\n");

@@ -55,14 +55,26 @@ LocateFileUri(const char *uri, const Client *client
}
static LocatedUri
LocateAbsoluteUri(const char *uri
LocateAbsoluteUri(UriPluginKind kind, const char *uri
#ifdef ENABLE_DATABASE
, const Storage *storage
#endif
)
{
if (!uri_supported_scheme(uri))
throw std::runtime_error("Unsupported URI scheme");
switch (kind) {
case UriPluginKind::INPUT:
case UriPluginKind::STORAGE: // TODO: separate check for storage plugins
if (!uri_supported_scheme(uri))
throw std::runtime_error("Unsupported URI scheme");
break;
case UriPluginKind::PLAYLIST:
/* for now, no validation for playlist URIs; this is
more complicated because there are three ways to
identify which plugin to use: URI scheme, filename
suffix and MIME type */
break;
}
#ifdef ENABLE_DATABASE
if (storage != nullptr) {
@@ -76,7 +88,8 @@ LocateAbsoluteUri(const char *uri
}
LocatedUri
LocateUri(const char *uri, const Client *client
LocateUri(UriPluginKind kind,
const char *uri, const Client *client
#ifdef ENABLE_DATABASE
, const Storage *storage
#endif
@@ -100,7 +113,7 @@ LocateUri(const char *uri, const Client *client
#endif
);
else if (uri_has_scheme(uri))
return LocateAbsoluteUri(uri
return LocateAbsoluteUri(kind, uri
#ifdef ENABLE_DATABASE
, storage
#endif

@@ -41,6 +41,12 @@ class Client;
class Storage;
#endif
enum class UriPluginKind {
INPUT,
STORAGE,
PLAYLIST,
};
struct LocatedUri {
enum class Type {
/**
@@ -84,7 +90,8 @@ struct LocatedUri {
* that feature is disabled if this parameter is nullptr
*/
LocatedUri
LocateUri(const char *uri, const Client *client
LocateUri(UriPluginKind kind,
const char *uri, const Client *client
#ifdef ENABLE_DATABASE
, const Storage *storage
#endif

@@ -43,7 +43,15 @@ struct MusicChunk;
/**
* Meta information for #MusicChunk.
*/
struct MusicChunkInfo {
struct alignas(8) MusicChunkInfo {
/* align to multiple of 8 bytes, which adds padding at the
end, so the size of MusicChunk::data is also a multiple of
8 bytes; this is a workaround for a bug in the DSD_U32 and
DoP converters which require processing 8 bytes at a time,
discarding the remainder */
/* TODO: once all converters have been fixed, we should remove
this workaround */
/** the next chunk in a linked list */
MusicChunkPtr next;
@@ -119,6 +127,10 @@ struct MusicChunk : MusicChunkInfo {
/** the data (probably PCM) */
uint8_t data[CHUNK_SIZE - sizeof(MusicChunkInfo)];
/* TODO: remove this check once all converters have been fixed
(see comment in struct MusicChunkInfo for details) */
static_assert(sizeof(data) % 8 == 0, "Wrong alignment");
/**
* Prepares appending to the music chunk. Returns a buffer
* where you may write into. After you are finished, call

@@ -134,7 +134,9 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
const auto *const name_fs_end =
FindStringSuffix(name_fs_str,
PATH_LITERAL(PLAYLIST_FILE_SUFFIX));
if (name_fs_end == nullptr)
if (name_fs_end == nullptr ||
/* no empty playlist names (raw file name = ".m3u") */
name_fs_end == name_fs_str)
return false;
FileInfo fi;

@@ -94,7 +94,8 @@ SongLoader::LoadSong(const char *uri_utf8) const
assert(uri_utf8 != nullptr);
#endif
const auto located_uri = LocateUri(uri_utf8, client
const auto located_uri = LocateUri(UriPluginKind::INPUT,
uri_utf8, client
#ifdef ENABLE_DATABASE
, storage
#endif

@@ -266,9 +266,12 @@ handle_list(Client &client, Request args, Response &r)
}
std::unique_ptr<SongFilter> filter;
TagType group = TAG_NUM_OF_ITEM_TYPES;
std::vector<TagType> tag_types;
if (args.size == 1) {
if (args.size == 1 &&
/* parantheses are the syntax for filter expressions: no
compatibility mode */
args.front()[0] != '(') {
/* for compatibility with < 0.12.0 */
if (tagType != TAG_ALBUM) {
r.FormatError(ACK_ERROR_ARG,
@@ -281,20 +284,31 @@ handle_list(Client &client, Request args, Response &r)
args.shift()));
}
if (args.size >= 2 &&
StringIsEqual(args[args.size - 2], "group")) {
while (args.size >= 2 &&
StringIsEqual(args[args.size - 2], "group")) {
const char *s = args[args.size - 1];
group = tag_name_parse_i(s);
const auto group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FormatError(ACK_ERROR_ARG,
"Unknown tag type: %s", s);
return CommandResult::ERROR;
}
if (group == tagType ||
std::find(tag_types.begin(), tag_types.end(),
group) != tag_types.end()) {
r.Error(ACK_ERROR_ARG, "Conflicting group");
return CommandResult::ERROR;
}
tag_types.emplace_back(group);
args.pop_back();
args.pop_back();
}
tag_types.emplace_back(tagType);
if (!args.empty()) {
filter.reset(new SongFilter());
try {
@@ -307,13 +321,9 @@ handle_list(Client &client, Request args, Response &r)
filter->Optimize();
}
if (tagType < TAG_NUM_OF_ITEM_TYPES && tagType == group) {
r.Error(ACK_ERROR_ARG, "Conflicting group");
return CommandResult::ERROR;
}
PrintUniqueTags(r, client.GetPartition(),
tagType, group, filter.get());
{&tag_types.front(), tag_types.size()},
filter.get());
return CommandResult::OK;
}

@@ -218,7 +218,7 @@ handle_read_comments(Client &client, Request args, Response &r)
const char *const uri = args.front();
const auto located_uri = LocateUri(uri, &client
const auto located_uri = LocateUri(UriPluginKind::INPUT, uri, &client
#ifdef ENABLE_DATABASE
, nullptr
#endif
@@ -331,7 +331,7 @@ handle_album_art(Client &client, Request args, Response &r)
const char *uri = args.front();
size_t offset = args.ParseUnsigned(1);
const auto located_uri = LocateUri(uri, &client
const auto located_uri = LocateUri(UriPluginKind::INPUT, uri, &client
#ifdef ENABLE_DATABASE
, nullptr
#endif

@@ -99,7 +99,7 @@ handle_listfiles(Client &client, Request args, Response &r)
/* default is root directory */
const auto uri = args.GetOptional(0, "");
const auto located_uri = LocateUri(uri, &client
const auto located_uri = LocateUri(UriPluginKind::STORAGE, uri, &client
#ifdef ENABLE_DATABASE
, nullptr
#endif
@@ -219,7 +219,7 @@ handle_lsinfo(Client &client, Request args, Response &r)
compatibility, work around this here */
uri = "";
const auto located_uri = LocateUri(uri, &client
const auto located_uri = LocateUri(UriPluginKind::INPUT, uri, &client
#ifdef ENABLE_DATABASE
, nullptr
#endif

@@ -20,6 +20,7 @@
#include "config.h"
#include "PlaylistCommands.hxx"
#include "Request.hxx"
#include "Instance.hxx"
#include "db/DatabasePlaylist.hxx"
#include "CommandError.hxx"
#include "PlaylistSave.hxx"
@@ -27,6 +28,7 @@
#include "PlaylistError.hxx"
#include "db/PlaylistVector.hxx"
#include "SongLoader.hxx"
#include "song/DetachedSong.hxx"
#include "BulkEdit.hxx"
#include "playlist/PlaylistQueue.hxx"
#include "playlist/Print.hxx"
@@ -38,6 +40,7 @@
#include "util/UriUtil.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ChronoUtil.hxx"
#include "LocateUri.hxx"
bool
playlist_commands_available() noexcept
@@ -66,22 +69,43 @@ handle_save(Client &client, Request args, gcc_unused Response &r)
CommandResult
handle_load(Client &client, Request args, gcc_unused Response &r)
{
const auto uri = LocateUri(UriPluginKind::PLAYLIST, args.front(),
&client
#ifdef ENABLE_DATABASE
, nullptr
#endif
);
RangeArg range = args.ParseOptional(1, RangeArg::All());
const ScopeBulkEdit bulk_edit(client.GetPartition());
auto &playlist = client.GetPlaylist();
const unsigned old_size = playlist.GetLength();
const SongLoader loader(client);
playlist_open_into_queue(args.front(),
playlist_open_into_queue(uri,
range.start, range.end,
client.GetPlaylist(),
playlist,
client.GetPlayerControl(), loader);
/* invoke the RemoteTagScanner on all newly added songs */
auto &instance = client.GetInstance();
const unsigned new_size = playlist.GetLength();
for (unsigned i = old_size; i < new_size; ++i)
instance.LookupRemoteTag(playlist.queue.Get(i).GetURI());
return CommandResult::OK;
}
CommandResult
handle_listplaylist(Client &client, Request args, Response &r)
{
const char *const name = args.front();
const auto name = LocateUri(UriPluginKind::PLAYLIST, args.front(),
&client
#ifdef ENABLE_DATABASE
, nullptr
#endif
);
if (playlist_file_print(r, client.GetPartition(), SongLoader(client),
name, false))
@@ -93,7 +117,12 @@ handle_listplaylist(Client &client, Request args, Response &r)
CommandResult
handle_listplaylistinfo(Client &client, Request args, Response &r)
{
const char *const name = args.front();
const auto name = LocateUri(UriPluginKind::PLAYLIST, args.front(),
&client
#ifdef ENABLE_DATABASE
, nullptr
#endif
);
if (playlist_file_print(r, client.GetPartition(), SongLoader(client),
name, true))

@@ -83,7 +83,8 @@ handle_add(Client &client, Request args, Response &r)
here */
uri = "";
const auto located_uri = LocateUri(uri, &client
const auto located_uri = LocateUri(UriPluginKind::INPUT, uri,
&client
#ifdef ENABLE_DATABASE
, nullptr
#endif

@@ -29,6 +29,8 @@ ServerSocketAddGeneric(ServerSocket &server_socket, const char *address, unsigne
server_socket.AddPort(port);
} else if (address[0] == '/' || address[0] == '~') {
server_socket.AddPath(ParsePath(address));
} else if (address[0] == '@') {
server_socket.AddAbstract(address);
} else {
server_socket.AddHost(address, port);
}

@@ -23,14 +23,14 @@
class ServerSocket;
/**
* Sets the address or unix socket of a ServerSocket instance
* Sets the address or local socket of a ServerSocket instance
* There are three possible ways
* 1) Set address to a valid ip address and specify port.
* server_socket will listen on this address/port tuple.
* 2) Set address to null and specify port.
* server_socket will listen on ANY address on that port.
* 3) Set address to a path of a unix socket. port is ignored.
* server_socket will listen on this unix socket.
* 3) Set address to a path of a local socket. port is ignored.
* server_socket will listen on this local socket.
*
* Throws #std::runtime_error on error.
*

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -35,6 +35,7 @@
#include "Interface.hxx"
#include "fs/Traits.hxx"
#include "util/ChronoUtil.hxx"
#include "util/RecursiveMap.hxx"
#include <functional>
@@ -186,42 +187,29 @@ PrintSongUris(Response &r, Partition &partition,
}
static void
PrintUniqueTags(Response &r, TagType tag_type,
const std::set<std::string> &values)
PrintUniqueTags(Response &r, ConstBuffer<TagType> tag_types,
const RecursiveMap<std::string> &map) noexcept
{
const char *const name = tag_item_names[tag_type];
for (const auto &i : values)
r.Format("%s: %s\n", name, i.c_str());
}
const char *const name = tag_item_names[tag_types.front()];
tag_types.pop_front();
static void
PrintGroupedUniqueTags(Response &r, TagType tag_type, TagType group,
const std::map<std::string, std::set<std::string>> &groups)
{
if (group == TAG_NUM_OF_ITEM_TYPES) {
for (const auto &i : groups)
PrintUniqueTags(r, tag_type, i.second);
return;
}
for (const auto &i : map) {
r.Format("%s: %s\n", name, i.first.c_str());
const char *const group_name = tag_item_names[group];
for (const auto &i : groups) {
r.Format("%s: %s\n", group_name, i.first.c_str());
PrintUniqueTags(r, tag_type, i.second);
if (!tag_types.empty())
PrintUniqueTags(r, tag_types, i.second);
}
}
void
PrintUniqueTags(Response &r, Partition &partition,
TagType type, TagType group,
ConstBuffer<TagType> tag_types,
const SongFilter *filter)
{
assert(type < TAG_NUM_OF_ITEM_TYPES);
const Database &db = partition.GetDatabaseOrThrow();
const DatabaseSelection selection("", true, filter);
PrintGroupedUniqueTags(r, type, group,
db.CollectUniqueTags(selection, type, group));
PrintUniqueTags(r, tag_types,
db.CollectUniqueTags(selection, tag_types));
}

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
#include <stdint.h>
template<typename T> struct ConstBuffer;
enum TagType : uint8_t;
class TagMask;
class SongFilter;
@@ -45,7 +46,7 @@ PrintSongUris(Response &r, Partition &partition,
void
PrintUniqueTags(Response &r, Partition &partition,
TagType type, TagType group,
ConstBuffer<TagType> tag_types,
const SongFilter *filter);
#endif

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -25,15 +25,14 @@
#include "util/Compiler.h"
#include <chrono>
#include <map>
#include <set>
#include <string>
struct DatabasePlugin;
struct DatabaseStats;
struct DatabaseSelection;
struct LightSong;
class TagMask;
template<typename Key> class RecursiveMap;
template<typename T> struct ConstBuffer;
class Database {
const DatabasePlugin &plugin;
@@ -106,13 +105,14 @@ public:
}
/**
* Collect unique values of the given tag type.
* Collect unique values of the given tag types. Each item in
* the #tag_types parameter results in one nesting level in
* the return value.
*
* Throws on error.
*/
virtual std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type,
TagType group=TAG_NUM_OF_ITEM_TYPES) const = 0;
virtual RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
ConstBuffer<TagType> tag_types) const = 0;
/**
* Throws on error.

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -21,36 +21,32 @@
#include "Interface.hxx"
#include "song/LightSong.hxx"
#include "tag/VisitFallback.hxx"
#include "util/ConstBuffer.hxx"
#include "util/RecursiveMap.hxx"
static void
CollectTags(std::set<std::string> &result,
const Tag &tag,
TagType tag_type) noexcept
CollectUniqueTags(RecursiveMap<std::string> &result,
const Tag &tag,
ConstBuffer<TagType> tag_types) noexcept
{
VisitTagWithFallbackOrEmpty(tag, tag_type, [&result](const char *value){
result.emplace(value);
if (tag_types.empty())
return;
const auto tag_type = tag_types.shift();
VisitTagWithFallbackOrEmpty(tag, tag_type, [&result, &tag, tag_types](const char *value){
CollectUniqueTags(result[value], tag, tag_types);
});
}
static void
CollectGroupTags(std::map<std::string, std::set<std::string>> &result,
const Tag &tag,
TagType tag_type,
TagType group) noexcept
{
VisitTagWithFallbackOrEmpty(tag, group, [&](const char *group_name){
CollectTags(result[group_name], tag, tag_type);
});
}
std::map<std::string, std::set<std::string>>
RecursiveMap<std::string>
CollectUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type, TagType group)
ConstBuffer<TagType> tag_types)
{
std::map<std::string, std::set<std::string>> result;
RecursiveMap<std::string> result;
db.Visit(selection, [&result, tag_type, group](const LightSong &song){
CollectGroupTags(result, song.tag, tag_type, group);
db.Visit(selection, [&result, tag_types](const LightSong &song){
CollectUniqueTags(result, song.tag, tag_types);
});
return result;

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -29,9 +29,11 @@
class TagMask;
class Database;
struct DatabaseSelection;
template<typename Key> class RecursiveMap;
template<typename T> struct ConstBuffer;
std::map<std::string, std::set<std::string>>
RecursiveMap<std::string>
CollectUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type, TagType group);
ConstBuffer<TagType> tag_types);
#endif

@@ -9,6 +9,11 @@ db_api_dep = declare_dependency(
link_with: db_api,
)
if not enable_database
db_glue_dep = db_api_dep
subdir_done()
endif
subdir('plugins')
db_glue_sources = [

@@ -38,6 +38,8 @@
#include "tag/Tag.hxx"
#include "tag/Mask.hxx"
#include "tag/ParseName.hxx"
#include "util/ConstBuffer.hxx"
#include "util/RecursiveMap.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
#include "protocol/Ack.hxx"
@@ -127,9 +129,8 @@ public:
VisitSong visit_song,
VisitPlaylist visit_playlist) const override;
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type,
TagType group) const override;
RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
ConstBuffer<TagType> tag_types) const override;
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
@@ -412,8 +413,7 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
static bool
SendGroup(mpd_connection *connection, TagType group)
{
if (group == TAG_NUM_OF_ITEM_TYPES)
return true;
assert(group != TAG_NUM_OF_ITEM_TYPES);
#if LIBMPDCLIENT_CHECK_VERSION(2,12,0)
const auto tag = Convert(group);
@@ -428,6 +428,19 @@ SendGroup(mpd_connection *connection, TagType group)
#endif
}
static bool
SendGroup(mpd_connection *connection, ConstBuffer<TagType> group)
{
while (!group.empty()) {
if (!SendGroup(connection, group.back()))
return false;
group.pop_back();
}
return true;
}
ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
const ConfigBlock &block)
:Database(proxy_db_plugin),
@@ -568,7 +581,8 @@ ProxyDatabase::OnSocketReady(gcc_unused unsigned flags) noexcept
if (!is_idle) {
// TODO: can this happen?
IdleMonitor::Schedule();
return false;
SocketMonitor::Cancel();
return true;
}
unsigned idle = (unsigned)mpd_recv_idle(connection, false);
@@ -586,7 +600,8 @@ ProxyDatabase::OnSocketReady(gcc_unused unsigned flags) noexcept
idle_received |= idle;
is_idle = false;
IdleMonitor::Schedule();
return false;
SocketMonitor::Cancel();
return true;
}
void
@@ -981,17 +996,20 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
helper.Commit();
}
std::map<std::string, std::set<std::string>>
RecursiveMap<std::string>
ProxyDatabase::CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type, TagType group) const
ConstBuffer<TagType> tag_types) const
try {
// TODO: eliminate the const_cast
const_cast<ProxyDatabase *>(this)->EnsureConnected();
enum mpd_tag_type tag_type2 = Convert(tag_type);
enum mpd_tag_type tag_type2 = Convert(tag_types.back());
if (tag_type2 == MPD_TAG_COUNT)
throw std::runtime_error("Unsupported tag");
auto group = tag_types;
group.pop_back();
if (!mpd_search_db_tags(connection, tag_type2) ||
!SendConstraints(connection, selection) ||
!SendGroup(connection, group))
@@ -1000,44 +1018,33 @@ try {
if (!mpd_search_commit(connection))
ThrowError(connection);
std::map<std::string, std::set<std::string>> result;
RecursiveMap<std::string> result;
std::vector<RecursiveMap<std::string> *> position;
position.emplace_back(&result);
if (group == TAG_NUM_OF_ITEM_TYPES) {
auto &values = result[std::string()];
while (auto *pair = mpd_recv_pair(connection)) {
AtScopeExit(this, pair) {
mpd_return_pair(connection, pair);
};
while (auto *pair = mpd_recv_pair(connection)) {
AtScopeExit(this, pair) {
mpd_return_pair(connection, pair);
};
const auto current_type = tag_name_parse_i(pair->name);
if (current_type == TAG_NUM_OF_ITEM_TYPES)
continue;
const auto current_type = tag_name_parse_i(pair->name);
if (current_type == TAG_NUM_OF_ITEM_TYPES)
continue;
auto it = std::find(tag_types.begin(), tag_types.end(),
current_type);
if (it == tag_types.end())
continue;
if (current_type == tag_type)
values.emplace(pair->value);
}
} else {
std::set<std::string> *current_group = nullptr;
size_t i = std::distance(tag_types.begin(), it);
if (i > position.size())
continue;
while (auto *pair = mpd_recv_pair(connection)) {
AtScopeExit(this, pair) {
mpd_return_pair(connection, pair);
};
if (i + 1 < position.size())
position.resize(i + 1);
const auto current_type = tag_name_parse_i(pair->name);
if (current_type == TAG_NUM_OF_ITEM_TYPES)
continue;
if (current_type == tag_type) {
if (current_group == nullptr)
current_group = &result[std::string()];
current_group->emplace(pair->value);
} else if (current_type == group) {
current_group = &result[pair->value];
}
}
auto &parent = *position[i];
position.emplace_back(&parent[pair->value]);
}
if (!mpd_response_finish(connection))

@@ -42,6 +42,8 @@
#include "fs/FileSystem.hxx"
#include "util/CharUtil.hxx"
#include "util/Domain.hxx"
#include "util/ConstBuffer.hxx"
#include "util/RecursiveMap.hxx"
#include "Log.hxx"
#ifdef ENABLE_ZLIB
@@ -329,11 +331,11 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
"No such directory");
}
std::map<std::string, std::set<std::string>>
RecursiveMap<std::string>
SimpleDatabase::CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type, TagType group) const
ConstBuffer<TagType> tag_types) const
{
return ::CollectUniqueTags(*this, selection, tag_type, group);
return ::CollectUniqueTags(*this, selection, tag_types);
}
DatabaseStats

@@ -122,9 +122,8 @@ public:
VisitSong visit_song,
VisitPlaylist visit_playlist) const override;
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type,
TagType group) const override;
RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
ConstBuffer<TagType> tag_types) const override;
DatabaseStats GetStats(const DatabaseSelection &selection) const override;

@@ -40,10 +40,11 @@
#include "tag/Mask.hxx"
#include "fs/Traits.hxx"
#include "Log.hxx"
#include "util/ConstBuffer.hxx"
#include "util/RecursiveMap.hxx"
#include "util/SplitString.hxx"
#include <string>
#include <set>
#include <assert.h>
#include <string.h>
@@ -97,9 +98,8 @@ public:
VisitSong visit_song,
VisitPlaylist visit_playlist) const override;
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
TagType tag_type,
TagType group) const override;
RecursiveMap<std::string> CollectUniqueTags(const DatabaseSelection &selection,
ConstBuffer<TagType> tag_types) const override;
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
@@ -624,11 +624,11 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
helper.Commit();
}
std::map<std::string, std::set<std::string>>
RecursiveMap<std::string>
UpnpDatabase::CollectUniqueTags(const DatabaseSelection &selection,
TagType tag, TagType group) const
ConstBuffer<TagType> tag_types) const
{
return ::CollectUniqueTags(*this, selection, tag, group);
return ::CollectUniqueTags(*this, selection, tag_types);
}
DatabaseStats

@@ -20,6 +20,8 @@
#include "config.h"
#include "DecoderList.hxx"
#include "DecoderPlugin.hxx"
#include "PluginUnavailable.hxx"
#include "Log.hxx"
#include "config/Data.hxx"
#include "config/Block.hxx"
#include "plugins/AudiofileDecoderPlugin.hxx"
@@ -45,6 +47,7 @@
#include "plugins/FluidsynthDecoderPlugin.hxx"
#include "plugins/SidplayDecoderPlugin.hxx"
#include "util/Macros.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
@@ -147,8 +150,17 @@ decoder_plugin_init_all(const ConfigData &config)
if (param != nullptr)
param->SetUsed();
if (plugin.Init(*param))
decoder_plugins_enabled[i] = true;
try {
if (plugin.Init(*param))
decoder_plugins_enabled[i] = true;
} catch (const PluginUnavailable &e) {
FormatError(e,
"Decoder plugin '%s' is unavailable",
plugin.name);
} catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize decoder plugin '%s'",
plugin.name));
}
}
}

@@ -39,8 +39,8 @@ InitHybridDsdDecoder(const ConfigBlock &block)
without a DSD DAC, the PCM (=ALAC) part of the file is
better */
if (block.GetBlockParam("enabled") == nullptr) {
LogInfo(hybrid_dsd_domain,
"The Hybrid DSD decoder is disabled because it was not explicitly enabled");
LogDebug(hybrid_dsd_domain,
"The Hybrid DSD decoder is disabled because it was not explicitly enabled");
return false;
}

@@ -208,10 +208,12 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
TagBuilder tag_builder;
AddTagHandler h(tag_builder);
if (ScanOpusTags(packet.packet, packet.bytes, &rgi, h) &&
!tag_builder.empty()) {
client.SubmitReplayGain(&rgi);
if (!ScanOpusTags(packet.packet, packet.bytes, &rgi, h))
return;
client.SubmitReplayGain(&rgi);
if (!tag_builder.empty()) {
Tag tag = tag_builder.Commit();
auto cmd = client.SubmitTag(input_stream, std::move(tag));
if (cmd != DecoderCommand::NONE)

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2018 The Music Player Daemon Project
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#ifndef MPD_OPUS_READER_HXX
#define MPD_OPUS_READER_HXX
#include "util/StringView.hxx"
#include <algorithm>
#include <stdint.h>
@@ -81,18 +83,16 @@ public:
return ReadWord(length) && Skip(length);
}
char *ReadString() {
StringView ReadString() {
uint32_t length;
if (!ReadWord(length) || length >= 65536)
if (!ReadWord(length))
return nullptr;
const char *src = (const char *)Read(length);
if (src == nullptr)
return nullptr;
char *dest = new char[length + 1];
*std::copy_n(src, length, dest) = 0;
return dest;
return {src, length};
}
};

@@ -24,6 +24,8 @@
#include "tag/ParseName.hxx"
#include "ReplayGainInfo.hxx"
#include <string>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
@@ -91,18 +93,25 @@ ScanOpusTags(const void *data, size_t size,
return false;
while (n-- > 0) {
char *p = r.ReadString();
if (p == nullptr)
const auto s = r.ReadString();
if (s == nullptr)
return false;
char *eq = strchr(p, '=');
if (eq != nullptr && eq > p) {
*eq = 0;
if (s.size >= 4096)
continue;
ScanOneOpusTag(p, eq + 1, rgi, handler);
}
const auto eq = s.Find('=');
if (eq == nullptr || eq == s.data)
continue;
delete[] p;
auto name = s, value = s;
name.SetEnd(eq);
value.MoveFront(eq + 1);
const std::string name2(name.data, name.size);
const std::string value2(value.data, value.size);
ScanOneOpusTag(name2.c_str(), value2.c_str(), rgi, handler);
}
return true;

@@ -20,18 +20,18 @@
#include "WildmidiDecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "tag/Handler.hxx"
#include "util/Domain.hxx"
#include "util/ScopeExit.hxx"
#include "util/StringFormat.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/FileSystem.hxx"
#include "fs/Path.hxx"
#include "Log.hxx"
#include "PluginUnavailable.hxx"
extern "C" {
#include <wildmidi_lib.h>
}
static constexpr Domain wildmidi_domain("wildmidi");
static constexpr AudioFormat wildmidi_audio_format{48000, SampleFormat::S16, 2};
static bool
@@ -43,14 +43,27 @@ wildmidi_init(const ConfigBlock &block)
if (!FileExists(path)) {
const auto utf8 = path.ToUTF8();
FormatDebug(wildmidi_domain,
"configuration file does not exist: %s",
utf8.c_str());
return false;
throw PluginUnavailable(StringFormat<1024>("configuration file does not exist: %s",
utf8.c_str()));
}
return WildMidi_Init(path.c_str(), wildmidi_audio_format.sample_rate,
0) == 0;
#ifdef LIBWILDMIDI_VERSION
/* WildMidi_ClearError() requires libwildmidi 0.4 */
WildMidi_ClearError();
AtScopeExit() { WildMidi_ClearError(); };
#endif
if (WildMidi_Init(path.c_str(), wildmidi_audio_format.sample_rate,
0) != 0) {
#ifdef LIBWILDMIDI_VERSION
/* WildMidi_GetError() requires libwildmidi 0.4 */
throw PluginUnavailable(WildMidi_GetError());
#else
throw PluginUnavailable("WildMidi_Init() failed");
#endif
}
return true;
}
static void

@@ -110,15 +110,9 @@ BufferedSocket::OnSocketReady(unsigned flags) noexcept
if (flags & READ) {
assert(!input.IsFull());
if (!ReadToBuffer())
if (!ReadToBuffer() || !ResumeInput())
return false;
if (!ResumeInput())
/* we must return "true" here or
SocketMonitor::Dispatch() will call
Cancel() on a freed object */
return true;
if (!input.IsFull())
ScheduleRead();
}

@@ -46,6 +46,11 @@ public:
using SocketMonitor::Close;
private:
/**
* @return the number of bytes read from the socket, 0 if the
* socket isn't ready for reading, -1 on error (the socket has
* been closed and probably destructed)
*/
ssize_t DirectRead(void *data, size_t length) noexcept;
/**

@@ -45,6 +45,11 @@ public:
}
private:
/**
* @return the number of bytes written to the socket, 0 if the
* socket isn't ready for writing, -1 on error (the socket has
* been closed and probably destructed)
*/
ssize_t DirectWrite(const void *data, size_t length) noexcept;
protected:

@@ -392,7 +392,29 @@ ServerSocket::AddPath(AllocatedPath &&path)
#else /* !HAVE_UN */
(void)path;
throw std::runtime_error("UNIX domain socket support is disabled");
throw std::runtime_error("Local socket support is disabled");
#endif /* !HAVE_UN */
}
void
ServerSocket::AddAbstract(const char *name)
{
#if !defined(__linux__)
(void)name;
throw std::runtime_error("Abstract sockets are only available on Linux");
#elif !defined(HAVE_UN)
(void)name;
throw std::runtime_error("Local socket support is disabled");
#else
assert(name != nullptr);
assert(*name == '@');
AllocatedSocketAddress address;
address.SetLocal(name);
AddAddress(std::move(address));
#endif
}

@@ -90,7 +90,7 @@ public:
void AddHost(const char *hostname, unsigned port);
/**
* Add a listener on a Unix domain socket.
* Add a listener on a local socket.
*
* Throws #std::runtime_error on error.
*
@@ -99,6 +99,16 @@ public:
*/
void AddPath(AllocatedPath &&path);
/**
* Add a listener on an abstract local socket (Linux specific).
*
* Throws on error.
*
* @param name the abstract socket name, starting with a '@'
* instead of a null byte
*/
void AddAbstract(const char *name);
/**
* Add a socket descriptor that is accepting connections. After this
* has been called, don't call server_socket_open(), because the

@@ -33,8 +33,8 @@ SocketMonitor::Dispatch(unsigned flags) noexcept
{
flags &= GetScheduledFlags();
if (flags != 0 && !OnSocketReady(flags) && IsDefined())
Cancel();
if (flags != 0)
OnSocketReady(flags);
}
SocketMonitor::~SocketMonitor() noexcept

@@ -65,7 +65,7 @@ public:
/**
* Flush pending data and return it. This should be called
* repepatedly until it returns nullptr.
* repeatedly until it returns nullptr.
*/
virtual ConstBuffer<void> Flush();
};

@@ -56,6 +56,7 @@ public:
}
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
ConstBuffer<void> Flush() override;
};
class PreparedAutoConvertFilter final : public PreparedFilter {
@@ -104,6 +105,18 @@ AutoConvertFilter::FilterPCM(ConstBuffer<void> src)
return filter->FilterPCM(src);
}
ConstBuffer<void>
AutoConvertFilter::Flush()
{
if (convert != nullptr) {
auto result = convert->Flush();
if (!result.IsNull())
return filter->FilterPCM(result);
}
return filter->Flush();
}
std::unique_ptr<PreparedFilter>
autoconvert_filter_new(std::unique_ptr<PreparedFilter> filter) noexcept
{

3
src/haiku/add_resources.sh Executable file

@@ -0,0 +1,3 @@
#!/bin/sh
cp "$2" "$1" && xres -o "$1" -- "$3" && mimeset -f "$1" || (rm -f "$1"; exit 1)

@@ -1,18 +1,26 @@
rc = meson.find_program('rc')
xres = meson.find_program('xres')
haiku_conf = configuration_data()
haiku_conf.set('VERSION', meson.project_version())
splitted_version = meson.project_version().split('~')[0].split('.')
haiku_conf.set('VERSION_MAJOR', splitted_version[0])
haiku_conf.set('VERSION_MINOR', splitted_version.get(1, '0'))
haiku_conf.set('VERSION_REVISION', splitted_version.get(2, '0'))
haiku_conf.set('VERSION_EXTRA', splitted_version.get(3, '0'))
mpd_rdef = configure_file(
input: 'mpd.rdef.in',
output: 'mpd.rdef',
configuration: haiku_conf,
)
rc = find_program('rc')
xres = find_program('xres')
rsrc = custom_target(
'mpd.rsrc',
output: 'mpd.rsrc',
input: 'mpd.rdef',
input: mpd_rdef,
command: [rc, '-o', '@OUTPUT@', '@INPUT@'],
)
custom_target(
'mpd.rsrc',
output: 'mpd',
input: [mpd, rsrc],
command: [xres, '-o', '@OUTPUT@', '--', '@INPUT@'],
install: true,
install_dir: get_option('bindir'),
)
addres = files('add_resources.sh')

@@ -2,7 +2,15 @@ resource app_signature "application/x-vnd.MusicPD";
resource app_flags B_BACKGROUND_APP;
// TODO: resource app_version {};
resource app_version {
major = @VERSION_MAJOR@,
middle = @VERSION_MINOR@,
minor = @VERSION_REVISION@,
variety = B_APPV_ALPHA,
internal = @VERSION_EXTRA@,
short_info = "Music Player Daemon @VERSION@",
long_info = "Music Player Daemon @VERSION@ ©The Music Player Daemon Project"
};
resource vector_icon {
$"6E6369661F050102031604BEE29BBEC5403EC540BEE29B4A10004A10000001C6"

@@ -59,6 +59,9 @@ BufferedInputStream::~BufferedInputStream() noexcept
void
BufferedInputStream::Check()
{
if (read_error)
std::rethrow_exception(read_error);
if (input)
input->Check();
}
@@ -101,7 +104,7 @@ BufferedInputStream::IsEOF() noexcept
bool
BufferedInputStream::IsAvailable() noexcept
{
return IsEOF() || buffer.Read(offset).HasData();
return IsEOF() || buffer.Read(offset).HasData() || read_error;
}
size_t
@@ -164,6 +167,32 @@ BufferedInputStream::RunThread() noexcept
idle = false;
seek = false;
client_cond.signal();
} else if (!idle && !read_error &&
offset != input->GetOffset() &&
!IsAvailable()) {
/* a past Seek() call was a no-op because data
was already available at that position, but
now we've reached a new position where
there is no more data in the buffer, and
our input is reading somewhere else (maybe
stuck at the end of the file); to find a
way out, we now seek our input to our
reading position to be able to fill our
buffer */
try {
input->Seek(offset);
} catch (...) {
/* this is really a seek error, but we
register it as a read_error,
because seek_error is only checked
by Seek(), and at our frontend (our
own InputStream interface) is in
"read" mode */
read_error = std::current_exception();
client_cond.signal();
InvokeOnAvailable();
}
} else if (!idle && !read_error &&
input->IsAvailable() && !input->IsEOF()) {
const auto read_offset = input->GetOffset();

@@ -306,9 +306,8 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
{
try {
curl_init = new CurlInit(event_loop);
} catch (const std::runtime_error &e) {
LogError(e);
throw PluginUnavailable(e.what());
} catch (...) {
std::throw_with_nested(PluginUnavailable("CURL initialization failed"));
}
const auto version_info = curl_version_info(CURLVERSION_FIRST);

@@ -22,14 +22,13 @@
#include "lib/smbclient/Mutex.hxx"
#include "../InputStream.hxx"
#include "../InputPlugin.hxx"
#include "../MaybeBufferedInputStream.hxx"
#include "PluginUnavailable.hxx"
#include "system/Error.hxx"
#include "util/ASCII.hxx"
#include <libsmbclient.h>
#include <stdexcept>
class SmbclientInputStream final : public InputStream {
SMBCCTX *ctx;
int fd;
@@ -72,9 +71,8 @@ input_smbclient_init(EventLoop &, const ConfigBlock &)
{
try {
SmbclientInit();
} catch (const std::runtime_error &e) {
// TODO: use std::throw_with_nested()?
throw PluginUnavailable(e.what());
} catch (...) {
std::throw_with_nested(PluginUnavailable("libsmbclient initialization failed"));
}
// TODO: create one global SMBCCTX here?
@@ -115,8 +113,9 @@ input_smbclient_open(const char *uri,
throw MakeErrno(e, "smbc_fstat() failed");
}
return std::make_unique<SmbclientInputStream>(uri, mutex,
ctx, fd, st);
return std::make_unique<MaybeBufferedInputStream>
(std::make_unique<SmbclientInputStream>(uri, mutex,
ctx, fd, st));
}
size_t

@@ -180,6 +180,8 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block)
if (password == nullptr)
throw PluginUnavailable("No Tidal password configured");
FormatWarning(tidal_domain, "The Tidal input plugin is deprecated because Tidal has changed the protocol and doesn't share documentation");
tidal_audioquality = block.GetBlockValue("audioquality", "HIGH");
tidal_session = new TidalSessionManager(event_loop, base_url, token,

@@ -43,6 +43,8 @@
#include <stdexcept>
#include <utility>
#include <cstdio>
class CdromDrive {
cdrom_drive_t *drv = nullptr;

@@ -1,4 +1,17 @@
# Since version 0.49.0 Meson has native libgcrypt dependency support, which has
# the advantage over find_library() as it uses libgcrypt-config to query the
# required linker flags.
# However, we still need to use find_library() first, to prevent Meson
# falsly assuming a target libgcrypt is available in case there is no
# libgcrypt-config entry in the cross file and libgcrypt is installed on the
# host. In this case, Meson will falsly use the native libgcrypt-config and
# will falsly assume it has found the gcrypt library for the target.
#
# See: https://github.com/MusicPlayerDaemon/MPD/pull/495
gcrypt_dep = c_compiler.find_library('gcrypt', required: get_option('qobuz'))
if gcrypt_dep.found()
gcrypt_dep = dependency('libgcrypt')
endif
if not gcrypt_dep.found()
subdir_done()
endif

@@ -20,6 +20,7 @@
#include "OggVisitor.hxx"
#include <stdexcept>
#include <utility>
void
OggVisitor::EndStream()
@@ -51,7 +52,13 @@ OggVisitor::ReadNextPage()
inline void
OggVisitor::HandlePacket(const ogg_packet &packet)
{
const bool _post_seek = std::exchange(post_seek, false);
if (packet.b_o_s) {
if (_post_seek)
/* ignore the BOS packet after seeking */
return;
EndStream();
has_stream = true;
OnOggBeginning(packet);
@@ -97,4 +104,6 @@ OggVisitor::PostSeek()
/* find the next Ogg page and feed it into the stream */
sync.ExpectPageSeekIn(stream);
post_seek = true;
}

@@ -39,6 +39,14 @@ class OggVisitor {
bool has_stream = false;
/**
* This is true after seeking; its one-time effect is to
* ignore the BOS packet, just in case we have been seeking to
* the beginning of the file, because that would disrupt
* playback.
*/
bool post_seek = false;
public:
explicit OggVisitor(Reader &reader)
:sync(reader), stream(0) {}

@@ -1,7 +1,20 @@
libflac_dep = dependency('flac', version: '>= 1.2', required: get_option('flac'))
libopus_dep = dependency('opus', required: get_option('opus'))
libvorbis_dep = dependency('vorbis', required: get_option('vorbis'))
libvorbisidec_dep = dependency('vorbisidec', required: get_option('tremor'))
if get_option('tremor').enabled()
# no libvorbis if Tremor was explicitly enabled
libvorbis_dep = dependency('', required: false)
else
libvorbis_dep = dependency('vorbis', required: get_option('vorbis'))
endif
if libvorbis_dep.found()
# no Tremor if libvorbis is used
libvorbisidec_dep = dependency('', required: false)
else
# attempt to auto-detect Tremor only if libvorbis was disabled or not found
libvorbisidec_dep = dependency('vorbisidec', required: get_option('tremor'))
endif
if get_option('vorbis').enabled() and get_option('tremor').enabled()
error('Cannot build both, the Vorbis decoder AND the Tremor (Vorbis fixed-point) decoder')

@@ -150,8 +150,6 @@ ReadServers(NeighborExplorer::List &list, int fd)
smbc_dirent *e;
while ((e = smbc_readdir(fd)) != nullptr)
ReadEntry(list, *e);
smbc_closedir(fd);
}
static void

@@ -168,7 +168,7 @@ public:
}
constexpr operator SocketAddress() const noexcept {
return SocketAddress((const struct sockaddr *)&address,
return SocketAddress((const struct sockaddr *)(const void *)&address,
sizeof(address));
}

@@ -135,7 +135,7 @@ public:
}
constexpr operator SocketAddress() const noexcept {
return SocketAddress((const struct sockaddr *)&address,
return SocketAddress((const struct sockaddr *)(const void *)&address,
sizeof(address));
}

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -315,6 +315,13 @@ SocketDescriptor::SetTcpDeferAccept(const int &seconds) noexcept
return SetOption(IPPROTO_TCP, TCP_DEFER_ACCEPT, &seconds, sizeof(seconds));
}
bool
SocketDescriptor::SetTcpUserTimeout(const unsigned &milliseconds) noexcept
{
return SetOption(IPPROTO_TCP, TCP_USER_TIMEOUT,
&milliseconds, sizeof(milliseconds));
}
bool
SocketDescriptor::SetV6Only(bool value) noexcept
{

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -188,6 +188,12 @@ public:
bool SetCork(bool value=true) noexcept;
bool SetTcpDeferAccept(const int &seconds) noexcept;
/**
* Setter for TCP_USER_TIMEOUT.
*/
bool SetTcpUserTimeout(const unsigned &milliseconds) noexcept;
bool SetV6Only(bool value) noexcept;
/**

@@ -35,7 +35,7 @@ socket_bind_listen(int domain, int type, int protocol,
throw MakeSocketError("Failed to create socket");
#ifdef HAVE_UN
if (domain == AF_UNIX) {
if (domain == AF_LOCAL) {
/* Prevent access until right permissions are set */
fchmod(fd.Get(), 0);
}

@@ -32,7 +32,7 @@ class SocketAddress;
/**
* Creates a socket listening on the specified address. This is a
* shortcut for socket(), bind() and listen().
* When a unix socket is created (domain == AF_UNIX), its
* When a local socket is created (domain == AF_LOCAL), its
* permissions will be stripped down to prevent unauthorized
* access. The caller is responsible to apply proper permissions
* at a later point.

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
#include "config.h"
#include "StaticSocketAddress.hxx"
#include "util/StringView.hxx"
#include <algorithm>
@@ -50,6 +51,16 @@ StaticSocketAddress::operator=(SocketAddress other) noexcept
return *this;
}
#ifdef HAVE_UN
StringView
StaticSocketAddress::GetLocalRaw() const noexcept
{
return SocketAddress(*this).GetLocalRaw();
}
#endif
#ifdef HAVE_TCP
bool

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2017 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -66,14 +66,6 @@ public:
return reinterpret_cast<const struct sockaddr *>(&address);
}
struct sockaddr *GetAddress() noexcept {
return reinterpret_cast<struct sockaddr *>(&address);
}
const struct sockaddr *GetAddress() const noexcept {
return reinterpret_cast<const struct sockaddr *>(&address);
}
constexpr size_type GetCapacity() const noexcept {
return sizeof(address);
}
@@ -109,6 +101,14 @@ public:
address.ss_family = AF_UNSPEC;
}
#ifdef HAVE_UN
/**
* @see SocketAddress::GetLocalRaw()
*/
gcc_pure
StringView GetLocalRaw() const noexcept;
#endif
#ifdef HAVE_TCP
/**
* Extract the port number. Returns 0 if not applicable.

@@ -106,7 +106,7 @@ ToString(SocketAddress address) noexcept
{
#ifdef HAVE_UN
if (address.GetFamily() == AF_LOCAL)
/* return path of UNIX domain sockets */
/* return path of local socket */
return LocalAddressToString(*(const sockaddr_un *)address.GetAddress(),
address.GetSize());
#endif

@@ -27,6 +27,7 @@
#include "../OutputAPI.hxx"
#include "mixer/MixerList.hxx"
#include "pcm/PcmExport.hxx"
#include "system/PeriodClock.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "util/Manual.hxx"
@@ -56,6 +57,17 @@ class AlsaOutput final
DeferEvent defer_invalidate_sockets;
/**
* This timer is used to re-schedule the #MultiSocketMonitor
* after it had been disabled to wait for the next Play() call
* to deliver more data. This timer is necessary to start
* generating silence if Play() doesn't get called soon enough
* to avoid the xrun.
*/
TimerEvent silence_timer;
PeriodClock throttle_silence_log;
Manual<PcmExport> pcm_export;
/**
@@ -109,6 +121,8 @@ class AlsaOutput final
*/
snd_pcm_uframes_t period_frames;
std::chrono::steady_clock::duration effective_period_duration;
/**
* If snd_pcm_avail() goes above this value and no more data
* is available in the #ring_buffer, we need to play some
@@ -128,13 +142,20 @@ class AlsaOutput final
bool work_around_drain_bug;
/**
* After Open(), has this output been activated by a Play()
* command?
* After Open() or Cancel(), has this output been activated by
* a Play() command?
*
* Protected by #mutex.
*/
bool active;
/**
* Is this output waiting for more data?
*
* Protected by #mutex.
*/
bool waiting;
/**
* Do we need to call snd_pcm_prepare() before the next write?
* It means that we put the device to SND_PCM_STATE_SETUP by
@@ -176,7 +197,7 @@ class AlsaOutput final
Alsa::PeriodBuffer period_buffer;
/**
* Protects #cond, #error, #active, #drain.
* Protects #cond, #error, #active, #waiting, #drain.
*/
mutable Mutex mutex;
@@ -248,6 +269,12 @@ private:
return active;
}
gcc_pure
bool LockIsActiveAndNotWaiting() const noexcept {
const std::lock_guard<Mutex> lock(mutex);
return active && !waiting;
}
/**
* Activate the output by registering the sockets in the
* #EventLoop. Before calling this, filling the ring buffer
@@ -260,10 +287,11 @@ private:
* was never unlocked
*/
bool Activate() noexcept {
if (active)
if (active && !waiting)
return false;
active = true;
waiting = false;
const ScopeUnlock unlock(mutex);
defer_invalidate_sockets.Schedule();
@@ -330,9 +358,23 @@ private:
const std::lock_guard<Mutex> lock(mutex);
error = std::current_exception();
active = false;
waiting = false;
cond.signal();
}
/**
* Callback for @silence_timer
*/
void OnSilenceTimer() noexcept {
{
const std::lock_guard<Mutex> lock(mutex);
assert(active);
waiting = false;
}
MultiSocketMonitor::InvalidateSockets();
}
/* virtual methods from class MultiSocketMonitor */
std::chrono::steady_clock::duration PrepareSockets() noexcept override;
void DispatchSockets() noexcept override;
@@ -344,6 +386,7 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
:AudioOutput(FLAG_ENABLE_DISABLE),
MultiSocketMonitor(_loop),
defer_invalidate_sockets(_loop, BIND_THIS_METHOD(InvalidateSockets)),
silence_timer(_loop, BIND_THIS_METHOD(OnSilenceTimer)),
device(block.GetBlockValue("device", "")),
#ifdef ENABLE_DSD
dop_setting(block.GetBlockValue("dop", false) ||
@@ -500,8 +543,9 @@ AlsaOutput::Setup(AudioFormat &audio_format,
alsa_period_size = 1;
period_frames = alsa_period_size;
effective_period_duration = audio_format.FramesToTime<decltype(effective_period_duration)>(period_frames);
/* generate silence if there's less than once period of data
/* generate silence if there's less than one period of data
in the ALSA-PCM buffer */
max_avail_frames = hw_result.buffer_size - hw_result.period_size;
@@ -684,6 +728,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
period_buffer.Allocate(period_frames, out_frame_size);
active = false;
waiting = false;
must_prepare = false;
written = false;
error = {};
@@ -766,7 +811,7 @@ AlsaOutput::DrainInternal()
/* need to call CopyRingToPeriodBuffer() and
WriteFromPeriodBuffer() again in the next
iteration, so don't finish the drain just yet */
return period_buffer.IsEmpty();
return false;
}
if (!written)
@@ -774,6 +819,24 @@ AlsaOutput::DrainInternal()
don't need to drain it */
return true;
switch (snd_pcm_state(pcm)) {
case SND_PCM_STATE_PREPARED:
case SND_PCM_STATE_RUNNING:
/* these states require a call to snd_pcm_drain() */
break;
case SND_PCM_STATE_DRAINING:
/* already draining, but not yet finished; this is
probably a spurious epoll event, and we should wait
for the next one */
return false;
default:
/* all other states cannot be drained, and we're
done */
return true;
}
/* .. and finally drain the ALSA hardware buffer */
int result;
@@ -827,9 +890,11 @@ AlsaOutput::CancelInternal() noexcept
ring_buffer->reset();
active = false;
waiting = false;
MultiSocketMonitor::Reset();
defer_invalidate_sockets.Cancel();
silence_timer.Cancel();
}
void
@@ -858,6 +923,7 @@ AlsaOutput::Close() noexcept
BlockingCall(GetEventLoop(), [this](){
MultiSocketMonitor::Reset();
defer_invalidate_sockets.Cancel();
silence_timer.Cancel();
});
period_buffer.Free();
@@ -912,7 +978,7 @@ AlsaOutput::Play(const void *chunk, size_t size)
std::chrono::steady_clock::duration
AlsaOutput::PrepareSockets() noexcept
{
if (!LockIsActive()) {
if (!LockIsActiveAndNotWaiting()) {
ClearSocketList();
return std::chrono::steady_clock::duration(-1);
}
@@ -977,28 +1043,42 @@ try {
whenever more data arrives */
/* the same applies when there is still enough
data in the ALSA-PCM buffer (determined by
snd_pcm_avail()); this can happend at the
snd_pcm_avail()); this can happen at the
start of playback, when our ring_buffer is
smaller than the ALSA-PCM buffer */
{
const std::lock_guard<Mutex> lock(mutex);
active = false;
waiting = true;
cond.signal();
}
/* avoid race condition: see if data has
arrived meanwhile before disabling the
event (but after clearing the "active"
event (but after setting the "waiting"
flag) */
if (!CopyRingToPeriodBuffer()) {
MultiSocketMonitor::Reset();
defer_invalidate_sockets.Cancel();
/* just in case Play() doesn't get
called soon enough, schedule a
timer which generates silence
before the xrun occurs */
/* the timer fires in half of a
period; this short duration may
produce a few more wakeups than
necessary, but should be small
enough to avoid the xrun */
silence_timer.Schedule(effective_period_duration / 2);
}
return;
}
if (throttle_silence_log.CheckUpdate(std::chrono::seconds(5)))
FormatWarning(alsa_output_domain, "Decoder is too slow; playing silence to avoid xrun");
/* insert some silence if the buffer has not enough
data yet, to avoid ALSA xrun */
period_buffer.FillWithSilence(silence, out_frame_size);

@@ -140,9 +140,6 @@ HaikuOutput::Close() noexcept
HaikuOutput::~HaikuOutput()
{
delete_sem(new_buffer);
delete_sem(buffer_done);
finalize_application();
}

@@ -670,12 +670,13 @@ OssOutput::Play(const void *chunk, size_t size)
#ifdef AFMT_S24_PACKED
const auto e = pcm_export->Export({chunk, size});
if (e.empty())
return size;
chunk = e.data;
size = e.size;
#endif
assert(size > 0);
while (true) {
ret = fd.Write(chunk, size);
if (ret > 0) {

@@ -581,8 +581,8 @@ PulseOutput::SetupStream(const pa_sample_spec &ss)
/* WAVE-EX is been adopted as the speaker map for most media files */
pa_channel_map chan_map;
pa_channel_map_init_auto(&chan_map, ss.channels,
PA_CHANNEL_MAP_WAVEEX);
pa_channel_map_init_extend(&chan_map, ss.channels,
PA_CHANNEL_MAP_WAVEEX);
stream = pa_stream_new(context, name, &ss, &chan_map);
if (stream == nullptr)
throw MakePulseError(context,

@@ -71,10 +71,10 @@ HttpdClient::HandleLine(const char *line) noexcept
assert(state != State::RESPONSE);
if (state == State::REQUEST) {
if (memcmp(line, "HEAD /", 6) == 0) {
if (strncmp(line, "HEAD /", 6) == 0) {
line += 6;
head_method = true;
} else if (memcmp(line, "GET /", 5) == 0) {
} else if (strncmp(line, "GET /", 5) == 0) {
line += 5;
} else {
/* only GET is supported */
@@ -83,8 +83,19 @@ HttpdClient::HandleLine(const char *line) noexcept
return false;
}
/* blacklist some well-known request paths */
if ((strncmp(line, "favicon.ico", 11) == 0 &&
(line[11] == '\0' || line[11] == ' ')) ||
(strncmp(line, "robots.txt", 10) == 0 &&
(line[10] == '\0' || line[10] == ' ')) ||
(strncmp(line, "sitemap.xml", 11) == 0 &&
(line[11] == '\0' || line[11] == ' ')) ||
(strncmp(line, ".well-known/", 12) == 0)) {
should_reject = true;
}
line = strchr(line, ' ');
if (line == nullptr || memcmp(line + 1, "HTTP/", 5) != 0) {
if (line == nullptr || strncmp(line + 1, "HTTP/", 5) != 0) {
/* HTTP/0.9 without request headers */
if (head_method)
@@ -129,14 +140,21 @@ HttpdClient::SendResponse() noexcept
assert(state == State::RESPONSE);
if (metadata_requested) {
if (should_reject) {
response =
"HTTP/1.1 404 not found\r\n"
"Content-Type: text/plain\r\n"
"Connection: close\r\n"
"\r\n"
"404 not found";
} else if (metadata_requested) {
allocated =
icy_server_metadata_header(httpd.name, httpd.genre,
httpd.website,
httpd.content_type,
metaint);
response = allocated.c_str();
} else { /* revert to a normal HTTP request */
} else { /* revert to a normal HTTP request */
snprintf(buffer, sizeof(buffer),
"HTTP/1.1 200 OK\r\n"
"Content-Type: %s\r\n"
@@ -154,7 +172,7 @@ HttpdClient::SendResponse() noexcept
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
Close();
LockClose();
return false;
}
@@ -415,7 +433,7 @@ HttpdClient::OnSocketInput(void *data, size_t length) noexcept
if (!SendResponse())
return InputResult::CLOSED;
if (head_method) {
if (head_method || should_reject) {
LockClose();
return InputResult::CLOSED;
}
@@ -428,6 +446,7 @@ void
HttpdClient::OnSocketError(std::exception_ptr ep) noexcept
{
LogError(ep);
LockClose();
}
void

@@ -83,6 +83,11 @@ class HttpdClient final
*/
bool head_method = false;
/**
* Should we reject this request?
*/
bool should_reject = false;
/* ICY */
/**
@@ -142,6 +147,8 @@ public:
/**
* Frees the client and removes it from the server's client list.
*
* Caller must lock the mutex.
*/
void Close() noexcept;

@@ -208,10 +208,15 @@ public:
return HasClients();
}
/**
* Caller must lock the mutex.
*/
void AddClient(UniqueSocketDescriptor fd) noexcept;
/**
* Removes a client from the httpd_output.clients linked list.
*
* Caller must lock the mutex.
*/
void RemoveClient(HttpdClient &client) noexcept;
@@ -239,10 +244,14 @@ public:
/**
* Broadcasts data from the encoder to all clients.
*
* Mutext must not be locked.
*/
void BroadcastFromEncoder();
/**
* Mutext must not be locked.
*
* Throws #std::runtime_error on error.
*/
void EncodeAndPlay(const void *chunk, size_t size);
@@ -251,6 +260,9 @@ public:
size_t Play(const void *chunk, size_t size) override;
/**
* Mutext must not be locked.
*/
void CancelAllClients() noexcept;
void Cancel() noexcept override;

@@ -76,7 +76,10 @@ if is_darwin
audiounit_dep = declare_dependency(
link_args: [
'-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreServices',
]
],
dependencies: [
boost_dep,
],
)
else
audiounit_dep = dependency('', required: false)

@@ -229,6 +229,14 @@ SlesOutput::Open(AudioFormat &audio_format)
SL_ANDROID_KEY_STREAM_TYPE,
&stream_type,
sizeof(stream_type));
/* MPD doesn't care much about latency, so let's
configure power saving mode */
SLuint32 performance_mode = SL_ANDROID_PERFORMANCE_POWER_SAVING;
(*android_config)->SetConfiguration(android_config,
SL_ANDROID_KEY_PERFORMANCE_MODE,
&performance_mode,
sizeof(performance_mode));
}
result = play_object.Realize(false);

@@ -173,7 +173,8 @@ public:
* Export a PCM buffer.
*
* @param src the source PCM buffer
* @return the destination buffer (may be a pointer to the source buffer)
* @return the destination buffer; may be empty (and may be a
* pointer to the source buffer)
*/
ConstBuffer<void> Export(ConstBuffer<void> src) noexcept;

@@ -996,7 +996,7 @@ Player::Run() noexcept
}
}
if (dc.IsIdle() && queued && dc.pipe == pipe) {
if (dc.IsIdle() && queued && IsDecoderAtCurrentSong()) {
/* the decoder has finished the current song;
make it decode the next song */
@@ -1058,6 +1058,16 @@ Player::Run() noexcept
SongBorder();
} else if (dc.IsIdle()) {
if (queued)
/* the decoder has just stopped,
between the two IsIdle() checks,
probably while UnlockCheckOutputs()
left the mutex unlocked; to restart
the decoder instead of stopping
playback completely, let's re-enter
this loop */
continue;
/* check the size of the pipe again, because
the decoder thread may have added something
since we last checked */

@@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "LocateUri.hxx"
#include "PlaylistAny.hxx"
#include "PlaylistStream.hxx"
#include "PlaylistMapper.hxx"
@@ -25,17 +26,26 @@
#include "config.h"
std::unique_ptr<SongEnumerator>
playlist_open_any(const char *uri,
playlist_open_any(const LocatedUri &located_uri,
#ifdef ENABLE_DATABASE
const Storage *storage,
#endif
Mutex &mutex)
{
return uri_has_scheme(uri)
? playlist_open_remote(uri, mutex)
: playlist_mapper_open(uri,
switch (located_uri.type) {
case LocatedUri::Type::ABSOLUTE:
return playlist_open_remote(located_uri.canonical_uri, mutex);
case LocatedUri::Type::PATH:
return playlist_open_path(located_uri.path, mutex);
case LocatedUri::Type::RELATIVE:
return playlist_mapper_open(located_uri.canonical_uri,
#ifdef ENABLE_DATABASE
storage,
#endif
mutex);
}
gcc_unreachable();
}

@@ -34,7 +34,7 @@ class Storage;
* music or playlist directory.
*/
std::unique_ptr<SongEnumerator>
playlist_open_any(const char *uri,
playlist_open_any(const LocatedUri &located_uri,
#ifdef ENABLE_DATABASE
const Storage *storage,
#endif

@@ -18,6 +18,7 @@
*/
#include "config.h"
#include "LocateUri.hxx"
#include "PlaylistQueue.hxx"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
@@ -63,7 +64,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
}
void
playlist_open_into_queue(const char *uri,
playlist_open_into_queue(const LocatedUri &uri,
unsigned start_index, unsigned end_index,
playlist &dest, PlayerControl &pc,
const SongLoader &loader)
@@ -78,7 +79,7 @@ playlist_open_into_queue(const char *uri,
if (playlist == nullptr)
throw PlaylistError::NoSuchList();
playlist_load_into_queue(uri, *playlist,
playlist_load_into_queue(uri.canonical_uri, *playlist,
start_index, end_index,
dest, pc, loader);
}

@@ -49,7 +49,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
* play queue.
*/
void
playlist_open_into_queue(const char *uri,
playlist_open_into_queue(const LocatedUri &uri,
unsigned start_index, unsigned end_index,
playlist &dest, PlayerControl &pc,
const SongLoader &loader);

@@ -18,6 +18,7 @@
*/
#include "config.h"
#include "LocateUri.hxx"
#include "Print.hxx"
#include "PlaylistAny.hxx"
#include "PlaylistSong.hxx"
@@ -55,7 +56,7 @@ playlist_provider_print(Response &r,
bool
playlist_file_print(Response &r, Partition &partition,
const SongLoader &loader,
const char *uri, bool detail)
const LocatedUri &uri, bool detail)
{
Mutex mutex;
@@ -71,6 +72,6 @@ playlist_file_print(Response &r, Partition &partition,
if (playlist == nullptr)
return false;
playlist_provider_print(r, loader, uri, *playlist, detail);
playlist_provider_print(r, loader, uri.canonical_uri, *playlist, detail);
return true;
}

@@ -34,6 +34,6 @@ struct Partition;
bool
playlist_file_print(Response &r, Partition &partition,
const SongLoader &loader,
const char *uri, bool detail);
const LocatedUri &uri, bool detail);
#endif

@@ -34,7 +34,7 @@
#include <FLAC/metadata.h>
class FlacPlaylist final : public SongEnumerator {
const char *const uri;
const std::string uri;
FLAC__StreamMetadata *const cuesheet;
const unsigned sample_rate;

@@ -22,13 +22,10 @@
#include <assert.h>
inline bool
bool
StringFilter::MatchWithoutNegation(const char *s) const noexcept
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(s != nullptr);
#endif
#ifdef HAVE_PCRE
if (regex)

@@ -105,7 +105,9 @@ public:
gcc_pure
bool Match(const char *s) const noexcept;
private:
/**
* Like Match(), but ignore the "negated" flag.
*/
gcc_pure
bool MatchWithoutNegation(const char *s) const noexcept;
};

@@ -35,43 +35,41 @@ TagSongFilter::ToExpression() const noexcept
}
bool
TagSongFilter::MatchNN(const TagItem &item) const noexcept
TagSongFilter::Match(const Tag &tag) const noexcept
{
return (type == TAG_NUM_OF_ITEM_TYPES || item.type == type) &&
filter.Match(item.value);
}
bool
TagSongFilter::MatchNN(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);
bool visited_types[TAG_NUM_OF_ITEM_TYPES]{};
for (const auto &i : tag) {
visited_types[i.type] = true;
if (MatchNN(i))
return true;
if ((type == TAG_NUM_OF_ITEM_TYPES || i.type == type) &&
filter.MatchWithoutNegation(i.value))
return !filter.IsNegated();
}
if (type < TAG_NUM_OF_ITEM_TYPES && !visited_types[type]) {
/* if the specified tag is not present, try the
fallback tags */
bool result = false;
if (ApplyTagFallback(type,
[&](TagType tag2) {
if (!visited_types[tag2])
return false;
if (ApplyTagFallback(type, [&](TagType tag2) {
if (!visited_types[tag2])
/* we already know that this tag type
isn't present, so let's bail out
without checking again */
return false;
for (const auto &item : tag) {
if (item.type == tag2 &&
filter.Match(item.value)) {
result = true;
break;
}
}
for (const auto &item : tag) {
if (item.type == tag2 &&
filter.MatchWithoutNegation(item.value)) {
result = true;
break;
}
}
return true;
}))
return result;
return true;
}))
return result != filter.IsNegated();
/* If the search critieron was not visited during the
sweep through the song's tag, it means this field
@@ -80,14 +78,14 @@ TagSongFilter::MatchNN(const Tag &tag) const noexcept
then it's a match as well and we should return
true. */
if (filter.empty())
return true;
return !filter.IsNegated();
}
return false;
return filter.IsNegated();
}
bool
TagSongFilter::Match(const LightSong &song) const noexcept
{
return MatchNN(song.tag);
return Match(song.tag);
}

@@ -68,8 +68,7 @@ public:
bool Match(const LightSong &song) const noexcept override;
private:
bool MatchNN(const Tag &tag) const noexcept;
bool MatchNN(const TagItem &tag) const noexcept;
bool Match(const Tag &tag) const noexcept;
};
#endif

@@ -79,6 +79,11 @@ public:
return FileDescriptor::CreatePipe(r, w);
}
static bool CreatePipeNonBlock(UniqueFileDescriptor &r,
UniqueFileDescriptor &w) noexcept {
return FileDescriptor::CreatePipeNonBlock(r, w);
}
static bool CreatePipe(FileDescriptor &r, FileDescriptor &w) noexcept;
#endif

@@ -22,6 +22,11 @@
#include <utility>
/**
* Invoke the given function for all fallback tags of the given
* #TagType, until the function returns true (or until there are no
* more fallback tags).
*/
template<typename F>
bool
ApplyTagFallback(TagType type, F &&f) noexcept
@@ -43,6 +48,11 @@ ApplyTagFallback(TagType type, F &&f) noexcept
return false;
}
/**
* Invoke the given function for the given #TagType and all of its
* fallback tags, until the function returns true (or until there are
* no more fallback tags).
*/
template<typename F>
bool
ApplyTagWithFallback(TagType type, F &&f) noexcept

@@ -1,4 +1,11 @@
threads_dep = dependency('threads')
if is_windows
# avoid the unused libwinpthread-1.dll dependency on Windows; MPD
# doesn't use the pthread API on Windows, but this is what Meson
# unhelpfully detects for us
threads_dep = []
else
threads_dep = dependency('threads')
endif
conf.set('HAVE_PTHREAD_SETNAME_NP', compiler.has_function('pthread_setname_np', dependencies: threads_dep))

41
src/util/RecursiveMap.hxx Normal file

@@ -0,0 +1,41 @@
/*
* Copyright 2019 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RECURSIVE_MAP_HXX
#define RECURSIVE_MAP_HXX
#include <map>
/**
* A #std::map which contains instances of itself.
*/
template<typename Key>
class RecursiveMap : public std::map<Key, RecursiveMap<Key>> {};
#endif

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