Compare commits

...

1477 Commits

Author SHA1 Message Date
Max Kellermann
8bfdb4ed0c release v0.18.11 2014-05-12 18:20:26 +02:00
Max Kellermann
70bd35abe2 decoder/OggUtil: allow skipping up to 32 kB after seek
Fixes missing song length on high-latency Opus files.

According to tests with 320 kbit/s opus files with 60ms packets, we
need to skip up to 29 kB.
2014-04-29 11:56:05 +02:00
Max Kellermann
0efb67b51e DeferredMonitor: fix race condition when using GLib event loop
Turns out the lock-free code using atomics was not thread-safe.  The
given callback could be invoked by GLib before the source_id attribute
was assigned.  This commit changes the DeferredMonitor class to use a
Mutex to block the event loop until source_id is assigned.  This bug
does not exist in the 0.19 branch because it does not use the GLib
main loop anymore.
2014-04-26 22:11:23 +02:00
Max Kellermann
54ebf2a699 configure.ac: prepare for 0.18.11 2014-04-26 22:08:08 +02:00
Max Kellermann
d0119548c1 release v0.18.10 2014-04-10 13:36:38 +02:00
Marcello Desantis
95ac6071b9 decoder/sndfile: work around libsndfile bug on partial read 2014-04-09 23:58:56 +02:00
Weng Xuetian
3a4e667078 PlaylistEdit: don't interrupt playback when current song gets deleted 2014-04-09 23:10:14 +02:00
Max Kellermann
ce18c36ed9 decoder/ffmpeg: handle unknown stream start time 2014-03-18 09:16:09 +01:00
Max Kellermann
8e39cf62e7 decoder/ffmpeg: pass AVSEEK_FLAG_ANY to av_seek_frame()
This corrects a major mistake from commit 724a59aa - there was one
small thing that commit was supposed to do, and it failed.
AV_TIME_BASE is not a seek flag.
2014-03-18 09:10:36 +01:00
Max Kellermann
a9e351e00d decoder/gme: fix memory leak in container_scan() 2014-03-06 13:12:39 +01:00
Max Kellermann
d65841a2db configure.ac: prepare for 0.18.10 2014-03-06 13:08:30 +01:00
Max Kellermann
2784d65618 release v0.18.9 2014-03-02 11:25:01 +01:00
Max Kellermann
47ea69233b output/alsa: remove the obsolete Raspberry Pi workaround
Has been superseded by the previous commit.
2014-03-02 11:22:04 +01:00
Max Kellermann
a884e37de1 output/alsa: call snd_pcm_prepare() after snd_pcm_drop()
Don't wait for an optimistic write to fail.  This is an improved
workaround for the infamous Raspberry Pi bug (see commit af991765).
It works much better and comes without the negative side effects.  The
old workaround is now obsolete.
2014-03-02 11:12:25 +01:00
Max Kellermann
0102a8665a event/SignalMonitor: fix build failure due to missing signal.h include 2014-03-02 10:21:31 +01:00
Max Kellermann
d34ae0850c AllCommands: "findadd" requires the "add" permission 2014-02-27 23:08:22 +01:00
Max Kellermann
6526de024a output/pulse: remove bogus g_free() call 2014-02-24 21:23:49 +01:00
Max Kellermann
5e1e92626c event/SignalMonitor: unblock signals after fork
Fixes hanging child process in the "pipe" output plugin.
2014-02-18 19:13:50 +01:00
Max Kellermann
7fee85c80a configure.ac: fix linker failure when libvorbis/libogg are static
Link libvorbisfile first, followed to libvorbis and finally libogg.
This order is necessary because libvorbisfile depends on libvorbis.
2014-02-18 18:39:19 +01:00
Max Kellermann
5d87a274a5 configure.ac: link the Vorbis encoder with libogg
Fixes another linker failure.  Similar to commit ea406875
2014-02-17 19:42:38 +01:00
Max Kellermann
57e862712a configure.ac: prepare for 0.18.9 2014-02-09 22:58:14 +01:00
Max Kellermann
ddb5390d88 release v0.18.8 2014-02-07 00:06:31 +01:00
Max Kellermann
fce20e514e NEWS: fix 0.18.7 release year 2014-02-07 00:06:31 +01:00
Max Kellermann
af66ed2505 doc/user: document the RoarAudio output plugin 2014-02-06 21:46:29 +01:00
Max Kellermann
ea4068757d configure.ac: link the Vorbis encoder with libvorbis
Since the encoder plugin uses a libvorbis function (and not only
libvorbisenc functions), we need to link with libvorbis explicitly.
2014-02-06 21:32:50 +01:00
Max Kellermann
2b10ecfa37 IcyMetadataParser: more robust tag parser
Allow semicolons and single quotes in the stream title.  This is not
part of any specification, but found in real life.
2014-01-27 10:08:21 +01:00
Max Kellermann
f7eb2b697e test/test_icy_parser: unit test for IcyMetaDataParser.cxx 2014-01-27 09:51:31 +01:00
Max Kellermann
da67260c95 new developer mailing list 2014-01-20 17:20:57 +01:00
Max Kellermann
ab9c9068d4 Queue: rename struct queue to Queue
Works around a build failure on Solaris because annoyingly, Solaris
reserves the name "queue".  This rename was pending anyway.
2014-01-20 08:57:46 +01:00
Max Kellermann
6b4d7d7315 Queue: make the constructor "explicit" 2014-01-20 08:57:41 +01:00
Max Kellermann
313d1d5d83 decoder/ffmpeg: support libav v10_alpha1 2014-01-15 11:33:18 +01:00
Max Kellermann
b7d6133593 decoder/ffmpeg: include cleanup 2014-01-15 11:31:51 +01:00
Max Kellermann
5b6bb114ad decoder/ffmpeg: check for av_samples_get_buffer_size() errors
Fixes potential nullptr dereference.
2014-01-15 11:25:58 +01:00
Max Kellermann
56f082c9d4 util/PeakBuffer: fix nullptr dereference when peak_size==0 2014-01-15 11:24:29 +01:00
Max Kellermann
a1b798e555 SongFilter, TagConfig: cast TAG_NUM_OF_ITEM_TYPES to integer
Fixes clang warning.
2014-01-15 11:23:41 +01:00
Max Kellermann
c91e08fbfd OutputAPI: fix typo in include guard 2014-01-15 11:22:59 +01:00
Max Kellermann
f882434547 configure.ac: prepare for 0.18.8 2014-01-15 11:22:06 +01:00
Max Kellermann
05ad335ae9 release v0.18.7 2014-01-13 11:39:27 +01:00
Max Kellermann
7faeb2ff2b configure.ac: reject libmpcdec SV7 in configure script
Look for symbol "mpc_demux_init" which does not exist in SV7.  This
avoids build failures when SV7 was found by configure.ac.
2014-01-11 21:02:12 +01:00
Max Kellermann
fdd76b3461 decoder/faad: fix memory leak 2014-01-08 22:11:00 +01:00
Max Kellermann
e490e5d0ab playlist/pls: don't free stack buffer 2014-01-08 19:50:44 +01:00
Max Kellermann
3a05c421e0 doc/user: fix typo 2014-01-07 18:06:58 +01:00
Max Kellermann
afc70c120e util/UriUtil: uri_get_suffix() fails if name begins with dot
A file called ".jpg" is not a JPEG file with an empty name; it is
merely a hidden file.
2013-12-29 17:40:51 +01:00
Max Kellermann
d7f80eab68 configure.ac: improved check for libyajl 1.0
If we have libyajl 2.0.1 (without a pkg-config file), our configure.ac
would assume this is the libyajl 1.0 API, because the function
yajl_alloc() exists in both.  This commit changes the library check to
the function yajl_parse_complete() which was removed in the 2.0 API.
This fixes build failure with libyajl 2.0.1.
2013-12-29 14:12:33 +01:00
Max Kellermann
e30b356eb0 daemon: no initgroups() when already running as the configured user
We can assume that initgroups() would be a no-op in that case, however
initgroups() is not allowed for unprivileged users anyway.
2013-12-29 13:59:05 +01:00
Max Kellermann
09a0803116 Daemon: fix typo in comment 2013-12-29 13:59:05 +01:00
Max Kellermann
20ffedc745 Daemon: simplify nested "if" 2013-12-29 13:57:12 +01:00
Max Kellermann
0b1ad27ba8 Daemon: fix typo in cast 2013-12-29 13:47:29 +01:00
Max Kellermann
6a1b2f0387 configure.ac: prepare for 0.18.7 2013-12-29 10:40:59 +01:00
Max Kellermann
fb34519b96 release v0.18.6 2013-12-24 12:01:01 +01:00
Max Kellermann
91fed47648 PlayerThread: log the last song that was played 2013-12-24 11:58:10 +01:00
Max Kellermann
c05691b546 OutputControl: update both ReplayGainFilters
The "mode" of the second ReplayGainFilter was never set, and thus
replay gain was never applied to the new song during cross-fade.
2013-12-24 11:53:21 +01:00
Steven O'Brien
6b3b8c6f2e fix FfmpegDecoderPlugin to use relative timestamps 2013-12-20 22:28:33 +01:00
Max Kellermann
a191db84f2 util/Error: add missing <algorithm> include
For std::move().
2013-12-19 10:58:20 +01:00
Michal Smucr
e4d69f38b0 riff: recognize upper-case "ID3" chunk name
Some tagging libraries (eg. TagLib) produce that variant.
2013-12-19 09:35:54 +01:00
Max Kellermann
97fc001180 input/cdio: fix typo in #include path
Broken by commit 3b0fea5f
2013-12-17 08:58:00 +01:00
Max Kellermann
42a09ff17a mixer/alsa: fix deadlock
This deadlock was a regression by commit 8e38b4f8.  Since we currently
can't resolve this, let's revert the commit, and add a GLib specific
workaround for the build failure.
2013-12-15 19:07:25 +01:00
Max Kellermann
c170fed6f9 .gitignore: ignore "test-driver"
File generated by automake version 1.14.
2013-12-14 12:33:20 +01:00
Max Kellermann
8e38b4f83c mixer/alsa: use BlockingCall() instead of EventLoop::AddCall()
This is safer, and works without epoll().  Fixes a build failure with
uClibc, which does not support epoll().
2013-12-13 14:35:36 +01:00
Max Kellermann
db4ae19246 doc/mpd.conf.5: remove redundant documentation
The real and detailed documentation is in the user manual.
2013-12-11 21:04:28 +01:00
Max Kellermann
82a89c6bfe doc/user: document the "ao" output
Move from doc/mpd.conf.5.
2013-12-11 21:03:11 +01:00
Max Kellermann
166c70cab3 doc/user: document the "fifo" output
Move from doc/mpd.conf.5.
2013-12-11 20:58:06 +01:00
Max Kellermann
de78fe38c8 doc/user: document shout option "protocol" 2013-12-11 20:54:42 +01:00
mobidyc
96fa69ff6b SongUpdate: accept files without metadata
If the file was recognized by a decoder plugin, accept it - don't
require metadata.
2013-12-10 19:34:35 +01:00
Max Kellermann
39d94bd3ea TagFile: add return value API documentation 2013-12-10 19:32:26 +01:00
Lukas Stabe
695ca29274 output/osx: fix build failure 2013-12-10 19:19:31 +01:00
Max Kellermann
02e8da6c98 NEWS: add openal line 2013-12-10 19:19:27 +01:00
Lukas Stabe
0ea5f4ac3a output/openal: check __APPLE__ instead of HAVE_OSX
On OSX, the configure-flag --enable-osx is used to enable the
unsupported osx output. It sets the HAVE_OSX preprocessor define.

src/output/OpenALOutputPlugin.cxx uses this define to determine wether
it is building on OSX, and imports different headers (which have
nothing to do with the osx output) depending on wether or not it is
set.
2013-12-02 13:08:52 +01:00
Max Kellermann
47c50c079d decoder/ffmpeg: use IgnoreError instead of local Error instance 2013-11-28 00:05:26 +01:00
Gaetan Bisson
3b0fea5fae input/cdio_paranoia: support libcdio-paranoia 0.90 2013-11-27 08:25:17 +01:00
Max Kellermann
443516cdda configure.ac: prepare for 0.18.6 2013-11-27 08:25:17 +01:00
Max Kellermann
57e0cc5442 release v0.18.5 2013-11-23 18:30:12 +01:00
Max Kellermann
73f45d87d5 decoder/{dsf,dsdiff}: eliminate useless assignments 2013-11-23 18:30:12 +01:00
Max Kellermann
ae88ba986e archive/iso9660: eliminate useless assignments 2013-11-23 18:30:12 +01:00
Max Kellermann
d6247902ec input/curl: work around stream resume bug (fixed in libcurl 7.32.0) 2013-11-23 12:13:41 +01:00
Max Kellermann
a566c28a49 input/curl: add global variable "curl_version" 2013-11-23 12:08:46 +01:00
Max Kellermann
2eddb63a83 input/curl: dump version number 2013-11-23 12:02:39 +01:00
Max Kellermann
fc7d5b055d PcmResampleLibsamplerate: clip 24 bit data
Using pcm_resample_lsr_32() for 24 bit samples works, but may cause 24
bit overflows.  This commit makes 24 bit a special case with explicit
clipping.
2013-11-22 23:27:56 +01:00
Max Kellermann
87c8953e8e PcmResample: un-inline Resample24() 2013-11-22 23:24:40 +01:00
Max Kellermann
45d27a52f1 PcmUtils: add function PcmClampN() 2013-11-22 23:24:40 +01:00
Max Kellermann
d22acc59c9 db/proxy: implement method GetUpdateStamp() 2013-11-22 00:45:27 +01:00
Max Kellermann
c064e8d62f DatabasePlugin: add method GetUpdateStamp()
Refactor SimpleDatabase::GetLastModified() to be generic for all
plugins.  Remove the SimpleDatabase assumption from db_stats_print(),
allowing it to be implemented by all database plugins.
2013-11-22 00:35:29 +01:00
Max Kellermann
099a2cb586 Stats: print db statistics only if db is available
Fixes crash on "stats" in certain configurations.
2013-11-22 00:27:37 +01:00
Max Kellermann
042fe2a9d0 Stats: print more unsigned integers 2013-11-22 00:23:27 +01:00
Max Kellermann
ff1c1107f3 Stats: auto-reload statistics with proxy plugin 2013-11-22 00:19:28 +01:00
Max Kellermann
41a3fd0fd0 Stats: use struct DatabaseStats
Eliminate redundant declaration.
2013-11-22 00:12:12 +01:00
Max Kellermann
b9169a5670 Stats: move the GTimer variable out of struct stats 2013-11-22 00:10:53 +01:00
Max Kellermann
2ecd5fa28d Stats: don't export the global variable "stats"
Unused outside of Stats.cxx.
2013-11-22 00:08:43 +01:00
Max Kellermann
e719b6cc41 Stats: print db_update as unsigned integer 2013-11-22 00:04:58 +01:00
Max Kellermann
67b8124a1d Mapper: _get_music_directory_utf8() may return nullptr
If no music_directory is configured, return nullptr instead of an
empty string.  This fixes a crash when db_file is configured without
music_directory.
2013-11-22 00:02:17 +01:00
Florian Schlichting
51ec499c89 system/ByteOrder: testing for endianness in a more general way
Fixes build tests on ia64 and mipsel by testing for endianness in a
more general / portable way.
2013-11-21 23:04:49 +01:00
Max Kellermann
3a4df25db2 util/ByteOrder: add comments 2013-11-21 23:04:31 +01:00
Max Kellermann
37cf78ef45 util/ByteOrder: indent the preprocessor directives
Improve readability.
2013-11-21 23:03:28 +01:00
Max Kellermann
727c622659 configure.ac: auto-detect fluidsynth by default
The option "--enable-fluidsynth" was documented to be "auto" by
default, when it was really "no".
2013-11-21 22:50:58 +01:00
Max Kellermann
74a778e65f configure.ac: prepare for 0.18.5 2013-11-18 20:03:30 +01:00
Denis Krjuchkov
1fc0c9fe8a NEWS: add version 0.18.5 change log 2013-11-18 16:40:00 +06:00
Denis Krjuchkov
740d8ec5ab system/fd_util.h: avoid symbol conflict with statically linked libmpdclient 2013-11-18 16:35:22 +06:00
Denis Krjuchkov
0bcc477d46 decoder/OggFind.cxx: include stdio.h for SEEK_END definition 2013-11-18 16:28:39 +06:00
Max Kellermann
35297f8d4f release v0.18.4 2013-11-13 18:26:01 +01:00
Max Kellermann
6f4202408c doc/example: remove "format" and "audio_output_format"
Just an attempt to prevent users from shooting themselves in the foot
by uncommenting these lines without knowing what they're doing.
2013-11-11 17:18:29 +01:00
Max Kellermann
0b6548a282 util/RefCount: no "constexpr" with libc++
Not supported by libc++.
2013-11-11 12:27:16 +01:00
Max Kellermann
faf5821816 util/LazyRandomEngine: make min()/max() static+constexpr
Required for building with libc++.
2013-11-11 12:27:15 +01:00
Max Kellermann
188673b746 output/httpd: don't use incomplete template argument with libc++ 2013-11-11 08:31:50 +01:00
Max Kellermann
287c70e361 filter/route, ...: add missing stdlib.h includes 2013-11-11 08:20:09 +01:00
Max Kellermann
f6b44af998 DespotifyUtils: add missing stdio.h include 2013-11-11 08:20:09 +01:00
Max Kellermann
84c3d9674f DecoderAPI: add missing math.h include 2013-11-11 08:18:54 +01:00
Jurgen Kramer
47d3758820 decoder/dsdiff: fix byte order bug 2013-11-10 16:49:39 +01:00
Max Kellermann
573ff3a24f DecoderThread: add missing <functional> include 2013-11-09 09:54:12 +01:00
Max Kellermann
32fcc22cb3 configure.ac: prepare for 0.18.4 2013-11-09 09:52:51 +01:00
Max Kellermann
daba1238b5 release v0.18.3 2013-11-08 12:55:12 +01:00
Max Kellermann
d125567f4a doc/developer: add text from the wiki 2013-11-08 12:54:16 +01:00
Max Kellermann
993eca9327 Makefile.am: disable dist-bzip2
bzip2-compressed tarballs are obsolete, xz is better and widely
understood.
2013-11-08 12:29:56 +01:00
Max Kellermann
e314844a4d doc: show .tar.xz in sample unpack command 2013-11-08 12:29:04 +01:00
Max Kellermann
017bc564af doc: replace the remaining wikia links 2013-11-08 12:26:07 +01:00
Max Kellermann
e076ff9085 DecoderAPI: log without holding mutex 2013-11-08 12:15:05 +01:00
Max Kellermann
2789493a5f PlayerThread: fix stuck MPD after song change (0.18.2 regression)
Commit 77c63511 caused MPD to become stuck right after a song change.
The problem was that at some point, the MusicBuffer became full, and
the DecoderThread working on the next song waits for the PlayerThread.
However, the PlayerThread was stuck in a loop of g_usleep() calls, and
never bothered to tell the DecoderThread that the MusicBuffer is not
full anymore.  This bug is very old, but its chance to occur went from
nearly 0% to nearly 100%.

The fix is to wake up the DecoderThread before waiting for it.  As a
side effect, I replaced the g_usleep() call with a Cond::Wait() call.
2013-11-08 12:02:21 +01:00
Max Kellermann
4ed0635447 DecoderInternal: simplify need_chunks()
Remove the "do_wait" parameter which is always true.  Check only
command==NONE and merge the "return" statements.
2013-11-08 11:59:56 +01:00
Max Kellermann
1904e504be DecoderInternal: don't wake up player in need_chunks
Nothing of interest happens here.  No need to wake up the player.
2013-11-08 11:58:23 +01:00
Max Kellermann
834715ea2f configure.ac: prepare for 0.18.3 2013-11-08 11:57:37 +01:00
Max Kellermann
380a3bbff4 release v0.18.2 2013-11-07 18:48:04 +01:00
Max Kellermann
6219326e02 doc: more information about "close" 2013-11-07 18:41:53 +01:00
Max Kellermann
6c4de5106b doc: remove documentation on obsolete tcp_keep_alive options 2013-11-07 18:39:55 +01:00
Max Kellermann
e936705840 doc: add link to user manual 2013-11-07 18:36:55 +01:00
Max Kellermann
9b2603b6f6 doc: update current maintainer 2013-11-07 18:34:57 +01:00
Max Kellermann
88856b847c doc: update Mantis link 2013-11-07 18:34:04 +01:00
Max Kellermann
f679878f7b doc/user: add more documentation for the proxy database plugin 2013-11-07 18:31:56 +01:00
Max Kellermann
f33acf8758 input/cdio_paranoia: add setting "default_byte_order"
Allows big-endian users to configure the fallback byte order to
little-endian.  Without this setting, MPD assumes native byte order if
the CD drive can't decide.
2013-11-07 18:17:54 +01:00
Max Kellermann
a846a4c643 AvahiPoll: don't close the dbus socket
Avoid closing it twice.
2013-11-07 01:10:07 +01:00
Max Kellermann
899c2bb9cc input/curl: unregister removed sockets from epoll
Fixes a crash bug.  See code comment.
2013-11-07 01:10:07 +01:00
Max Kellermann
f8f95e2dbd OutputControl: reduce the number of OutputThread wakeups
Wake up the OutputThread only if it hasn't already been woken up and
if it isn't already in the playback loop.
2013-11-06 23:51:17 +01:00
Max Kellermann
77c63511d8 PlayerThread: reduce the number of DecoderThread wakeups
After the number of decoded chunks has fallen below the threshold, the
PlayerThread woke up the DecoderThread over and over.  This commit
adds a boolean flag that avoids these duplicate wakeups, and thus
reduces the number of system calls.
2013-11-06 23:51:17 +01:00
Max Kellermann
0be5a6ab2b DecoderControl: reduce the number of PlayerThread wakeups
Wake up the PlayerThread only if it is really waiting for the decoder.
This greatly reduces the number of system calls in the DecoderThread.
2013-11-06 23:51:17 +01:00
Max Kellermann
9802e74859 DecoderInternal: lock DecoderControl in _flush_chunk()
Must hold the Mutex to signal the Cond object safely.
2013-11-06 23:51:17 +01:00
Max Kellermann
8e7d6eb151 DecoderInternal: wake up the player thread in _flush_chunk()
Merge duplicate code.
2013-11-06 23:51:17 +01:00
Max Kellermann
5c18e4f114 event/FullyBufferedSocket: remove obsolete TODO comment
We have a better solution now.
2013-11-06 23:50:36 +01:00
Max Kellermann
fd2eafa7c6 ClientRead: "close" flushes the output buffer
Add a new CommandResult code called "FINISH" which, unlike "CLOSE",
will attempt to flush the output buffer.  This is a one-shot attempt;
it will do one write, and not try again.
2013-11-06 22:01:06 +01:00
Max Kellermann
422b8472fe event/FullyBufferedSocket: try to write without extra roundtrip
Postpone the write using IdleMonitor instead of scheduling a write
event.  This reduces the number of system calls, because we don't need
to register and unregister the write event in epoll.
2013-11-06 21:52:24 +01:00
Max Kellermann
5b213b0504 event/FullyBufferedSocket: make WriteFromBuffer() protected
.. and rename it to Flush().
2013-11-06 21:52:09 +01:00
Max Kellermann
ad27d06979 PlayerThread: enable buffering when starting playback
For some reason, this got lost in commit 975deca8.

Re-enabling this fixes stuttering at the beginning of radio streams.
2013-11-06 20:14:38 +01:00
Max Kellermann
c4b1251d0a configure.ac: require libaudiofile 0.3 due to API breakage
Prior to version 0.3, the "length" callback returned a "long" instead
of AFfileoffset.  Now that this API bug fix is a few years old, let's
drop 0.2 support for good.
2013-11-06 20:04:21 +01:00
Max Kellermann
01891f8815 input/curl: fix bug with redirected streams
Migrate from the old curl_multi_perform() API to the newer
curl_multi_socket_action() API (since CURL 7.16).

This allows working around a bug with HTTP redirections with epoll:
when CURL closes a socket and the new one happens to have the same
file number, MPD did not have a chance to remove the old one from
epoll and subsequently attempted to use EPOLL_CTL_MOD, which was not
allowed by epoll, because it's a new socket now.
2013-11-06 19:14:22 +01:00
Max Kellermann
adb68450ce input/curl: move code into class CurlMulti
Move all global variables there, and keep just one global variable:
the pointer to the CurlMulti instance.  Prepares for the next commit.
2013-11-06 19:07:10 +01:00
Max Kellermann
2520f6fe49 input/curl: remove the global list of requests
Unused.
2013-11-06 19:06:14 +01:00
Max Kellermann
c9278bfcdf input/curl: don't abort all requests on curl_multi_perform() error
Eliminate some complicated code that's not worth the trouble.
2013-11-06 19:06:02 +01:00
Max Kellermann
8b838ff9ea input/curl: use CURLOPT_PRIVATE
Replaces the loop in input_curl_find_request().
2013-11-06 19:05:45 +01:00
Max Kellermann
154bdf0bca event/SocketMonitor: add method Abandon() 2013-11-06 19:05:45 +01:00
Max Kellermann
ed436c6f0c system/ByteOrder: fix big-endian support
D'oh!
2013-11-05 22:08:53 +01:00
Max Kellermann
ae5dd2da4f playlist/pls: fix reversed song order
Remove the forward_list::reverse() call.  It was not necessary,
because pls_parser() already reads the playlist in reverse order.
2013-11-05 18:22:34 +01:00
Jurgen Kramer
f4b61e8c8d decoder/dsf: enable DSD128 2013-11-05 17:38:48 +01:00
Max Kellermann
e49a3d377f NEWS: add missing line 2013-11-05 17:38:41 +01:00
Max Kellermann
b631b552bb test/*: add more missing stdlib.h includes 2013-11-05 17:28:23 +01:00
Natanael Copa
3f21581a81 add various missing headers
Fixes building with gcc-4.8

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2013-11-05 11:08:36 +01:00
Max Kellermann
bb62ecf157 configure.ac: prepare for 0.18.2 2013-11-05 11:08:17 +01:00
Max Kellermann
a268ab35ea release v0.18.1 2013-11-04 23:46:14 +01:00
Max Kellermann
62baec1841 output/alsa: avoid endless loop in Raspberry Pi workaround
See code comment.
2013-11-04 23:40:34 +01:00
Max Kellermann
7bca61f5bb event/ServerSocket: don't abort if IPv6 is not available
First check if an IPv6 socket can be created.
2013-11-04 23:36:02 +01:00
Max Kellermann
ecf12a60e8 Log: add level "DEFAULT"
Map LogLevel::INFO to G_LOG_LEVEL_INFO, and LogLevel::DEFAULT to
G_LOG_LEVEL_MESSAGE.  Now client connect/disconnect message are only
logged on log_level "secure".
2013-11-04 22:27:49 +01:00
Max Kellermann
6de85cb047 Log: document the LogLevel items 2013-11-04 22:17:53 +01:00
Max Kellermann
39257717d8 test/test_mixramp: add threshold to floating point comparisons
Fixes bogus test failures on Debian build machines due to rounding
errors (hopefully).
2013-11-04 22:08:59 +01:00
Max Kellermann
b54762a8f6 event/ServerSocket: fix assertion failure
Regression from previous commit.  D'oh!
2013-11-04 20:16:28 +01:00
Max Kellermann
bcae86196c event/ServerSocket: open sockets in the order they were configured
Use a std::list which can be appended at the end.
2013-11-04 20:10:46 +01:00
Max Kellermann
7adfea8ca2 system/resolver: return path of UNIX domain sockets
getnameinfo() doesn't work well - it always returns "localhost".
2013-11-04 19:13:05 +01:00
Max Kellermann
eab1a77683 ClientRead: always ignore whitespace at the end of the line 2013-11-04 18:11:15 +01:00
Max Kellermann
84f5e0c0de Makefile.am: distribute missing files 2013-11-04 08:26:10 +01:00
Max Kellermann
2ce3900071 filter/AutoConvert: modify child_audio_format, not in_audio_format
This prevented using the "volume_normalization" feature with some
codecs (e.g. mp3), because the normalization code requires 16 bit
samples.  If the codec happens to deliver formats other than S16, the
AutoConvert filter succeeds to initialize the conversion filter, but
the returned input audio format was wrong.
2013-11-04 08:00:00 +01:00
Max Kellermann
bf2c1f3e9e configure.ac: prepare for 0.18.1 2013-11-04 08:00:00 +01:00
Max Kellermann
8ccd8a008d release v0.18 2013-10-31 00:23:41 +01:00
Max Kellermann
9513c1a8d6 AUTHORS: add new authors 2013-10-31 00:23:41 +01:00
Max Kellermann
0a1be2bfc3 AUTHORS: new formatting 2013-10-31 00:18:44 +01:00
Max Kellermann
8c6727949c CommandLine: simplified program name line 2013-10-31 00:12:31 +01:00
Max Kellermann
ff9b717bf6 Makefile.am: add missing header file 2013-10-31 00:08:14 +01:00
Max Kellermann
8c834a4ff6 system/FatalError: use _exit() instead of exit()
Skip the global destructors.  We don't need them here - we bail out as
quickly as we can.
2013-10-30 23:42:16 +01:00
Max Kellermann
8c01004219 system/FatalError: move code to Abort() 2013-10-30 23:41:02 +01:00
Max Kellermann
8555b65c50 *: update copyright year to 2013 2013-10-30 23:37:06 +01:00
Max Kellermann
304fa5ecac ClientList: disconnect all clients in destructor
Fixes assertion failure.
2013-10-30 23:12:45 +01:00
Max Kellermann
88e630170e mixer/software: fix double free bug 2013-10-30 23:12:45 +01:00
Max Kellermann
da8bdd62c8 PlaylistState: ignore "mixrampdelay:nan"
mixramp_delay==nan() causes severe problems with cross-fading.
2013-10-30 22:33:02 +01:00
Max Kellermann
54abeab80b increase default buffer size to 4 MB
2 MB was too small for cross-fading a 24 bit file.  Increasing to 4 MB
is still not too large for weak machines, but is enough for
cross-fading.
2013-10-30 21:46:40 +01:00
Max Kellermann
1dc8a9f0e7 db/proxy: remove obsolete #undefs 2013-10-30 20:51:41 +01:00
Max Kellermann
a62d54425c db/proxy: auto-reconnect 2013-10-30 19:50:22 +01:00
Max Kellermann
c8b2591ac2 configure.ac: move -Werror before all other CFLAGS
Without -Werror, clang will not fail on -ftree-vectorize.
2013-10-30 19:17:07 +01:00
Max Kellermann
ee1d8e1091 configure.ac: default to enable_openal=auto 2013-10-30 19:02:59 +01:00
Max Kellermann
672fc8d79b configure.ac: enable -ffast-math and -ftree-vectorize
Allows advanced compiler optimization.
2013-10-30 18:30:04 +01:00
Max Kellermann
84ff1a680a configure.ac: enable some gcc options even in debug mode
Most importantly: always disable C++ exceptions.  It was surprising to
see MPD terminate due to an unexpected exception.
2013-10-30 18:22:35 +01:00
Max Kellermann
90c899407a ReplayGainInfo: use large negative value instead of infinity
The last piece to allow -ffast-math.
2013-10-30 18:01:45 +01:00
Max Kellermann
55868eecd0 PlayerCommands: show CrossFade/MixRamp only if enabled 2013-10-30 17:49:47 +01:00
Max Kellermann
50dc98367c PcmMix: use negative value instead of NaN for addition
Avoid NaN to allow -ffast-math.
2013-10-30 17:23:49 +01:00
Max Kellermann
c4d3030d24 CrossFade: eliminate NaN from mixramp_interpolate()
Use a boolean flag instead.
2013-10-30 17:20:34 +01:00
Max Kellermann
c6f101884b CrossFade: use negative value for invalid MixRamp overlap
Avoid NaN to allow -ffast-math.
2013-10-30 17:20:12 +01:00
Max Kellermann
c0c0526fc8 test/test_mixramp: improved test for mixramp_interpolate(0) 2013-10-30 17:18:54 +01:00
Max Kellermann
375c88b110 test/test_mixramp: add test with "invalid" return value 2013-10-30 17:14:40 +01:00
Max Kellermann
a65f63747b CrossFade: use negative value for invalid mixramp_delay
Avoid NaN to allow -ffast-math.
2013-10-30 16:50:34 +01:00
Max Kellermann
a21edddf27 CrossFade: remove obsolete API documentation 2013-10-30 16:45:02 +01:00
Max Kellermann
a88c23b6e8 Main: check the g_get_user_special_dir() result
Fixes crash.
2013-10-30 16:14:44 +01:00
Max Kellermann
216e37bf33 Makefile.am: link test/DumpDatabase with Ack.cxx 2013-10-30 16:14:44 +01:00
Max Kellermann
7bb3987acc db/proxy: return server errors using "enum ack" 2013-10-30 16:04:21 +01:00
Max Kellermann
6a147a17af db/proxy: pass search/find to remote MPD 2013-10-30 10:00:57 +01:00
Max Kellermann
2b7529e905 db/proxy: pass SongFilter to the remote MPD in VisitUniqueTags() 2013-10-30 09:40:23 +01:00
Max Kellermann
1ed321f964 db/proxy: add missing nullptr check 2013-10-30 09:37:20 +01:00
Max Kellermann
2aee1b86f3 SongFilter: add special keyword "base"
Restores the features from the previous draft commands "findin" /
"searchin".
2013-10-29 21:13:40 +01:00
Max Kellermann
b5fc21b9f4 Revert "command: new commands "findin", "searchin" with base URI"
This reverts commit a577944ab5.

Will be replaced by new options for the old commands "search" and
"find".
2013-10-29 21:13:40 +01:00
Max Kellermann
44581dbef5 util/UriUtil: add uri_is_child_or_same() 2013-10-29 21:13:40 +01:00
Jean-Francois Dockes
205448c1e8 db/proxy: enable song matching 2013-10-29 20:58:35 +01:00
Jean-Francois Dockes
2d11c6ab29 SongFilter: make SongFilter::Item class definition public 2013-10-29 20:47:52 +01:00
Max Kellermann
6859c22b69 SongFilter: "any" does not match file name
According to the protocol documentation, matching the file name was
wrong.  This removes some awkward special-case code.
2013-10-29 20:40:55 +01:00
Max Kellermann
2d5413fc3b DatabaseSelection: use std::string 2013-10-29 20:36:52 +01:00
Max Kellermann
a6aa0e4cbf SongFilter: use std::string 2013-10-29 19:39:17 +01:00
Max Kellermann
163848ab3b fd_util: avoid unnecessary fcntl() calls 2013-10-29 13:02:53 +01:00
Max Kellermann
03747ba93e PlayerControl: move attributes to struct CrossFadeSettings 2013-10-29 00:14:27 +01:00
Max Kellermann
095c390df7 FilterRegistry: add "pure" attribute 2013-10-29 00:05:04 +01:00
Max Kellermann
20597b3632 *: use nullptr instead of NULL 2013-10-28 23:58:17 +01:00
Max Kellermann
4728735acf decoder/dsf: don't play junk at the end of the "data" chunk 2013-10-28 23:47:25 +01:00
Max Kellermann
9dcbd005f0 decoder/dsf: add range check 2013-10-28 23:41:51 +01:00
Max Kellermann
0ad2eb34c7 decoder/dsdlib: add class DsdUint64
Merge lots of duplicate code.
2013-10-28 23:29:23 +01:00
Max Kellermann
0e8a15e813 decoder/dsdlib: include cleanup 2013-10-28 23:26:37 +01:00
Max Kellermann
5b0d6a59cf decoder/dsdlib: move API documentation to header 2013-10-28 23:26:16 +01:00
Max Kellermann
fd3dc7e5fb decoder/dsdlib: convert struct dsdlib_id to a class 2013-10-28 23:12:48 +01:00
Max Kellermann
c37edfd3e9 configure.ac: disable the OS X output plugin by default
There hasn't been a maintainer for this plugin for years.  It may even
fail to build.
2013-10-28 22:25:58 +01:00
Max Kellermann
4a99b1df4b configure.ac: add variable host_is_darwin
Fixes the OpenAL detection which was broken because enable_osx was
uesd which was set later.
2013-10-28 22:18:56 +01:00
Max Kellermann
12e9b7eafa PcmFormat: move definitions to struct SampleTraits 2013-10-28 21:29:36 +01:00
Max Kellermann
de1261ba28 MusicChunk: return WritableBuffer 2013-10-28 17:10:12 +01:00
Max Kellermann
5ee5a89a7f MusicChunk: use uint8_t instead of char 2013-10-28 17:08:14 +01:00
Max Kellermann
1ad2475f9e DecoderControl: convert mutex and client_cond to a reference
Share the Mutex between the DecoderThread and the PlayerThread.  This
simplifies synchronization between the two threads and fixes a freeze
problem: while the PlayerThread waits for the DeocderThread, it cannot
answer requests from the main thread, and the main thread will block
until the DecoderThread finishes.
2013-10-28 10:22:05 +01:00
Max Kellermann
5b5675cc12 player_control: rename to PlayerControl 2013-10-28 10:12:33 +01:00
Max Kellermann
e699f6781e decoder_control: rename to DecoderControl 2013-10-28 10:09:21 +01:00
Oddegamra
5f13c1cd9c output/httpd: accept icy-metadata with and without space
Some, or most, Win32 audio players will pass "icy-metadata:1" to
streaming servers. MPD expects a space between ":" and "1" at this
point, and thus does not send any stream metadata. This applies to
foobar2k and Winamp, for example.

According to forums.radiotoolbox.com/viewtopic.php?t=74 not having
a space there is expected behavior, so maybe MPD could accept
both forms to determine if metadata should be sent or not.
2013-10-26 16:32:00 +02:00
Max Kellermann
a577944ab5 command: new commands "findin", "searchin" with base URI 2013-10-26 16:13:35 +02:00
Max Kellermann
17ec3b0c2d FileCommands: "readcomments" understands APE and ID3v2 tags
Implements Mantis ticket 3843.
2013-10-26 16:04:29 +02:00
Max Kellermann
fb75137540 FileCommands: fix wrong control character check in IsValidValue()
Check was the wrong way around, and made all valid values invisible.
2013-10-26 16:04:06 +02:00
Max Kellermann
6f87164ad6 ApeTag: support multiple values per name 2013-10-26 16:00:05 +02:00
Max Kellermann
a4d82cfe1e ApeTag: move code to ForEachValue() 2013-10-26 15:57:09 +02:00
Max Kellermann
9f21eee2ec ApeTag: simplify the "recognized" flag 2013-10-26 15:52:49 +02:00
Max Kellermann
a40246d312 TagFile: use Path instead of const char * 2013-10-26 15:38:29 +02:00
Max Kellermann
4a5aad0948 PlayerControl: initialize tagged_song in constructor 2013-10-26 15:37:49 +02:00
Max Kellermann
85ae7e9c9a DecoderControl: move code/attributes to new class MixRampInfo 2013-10-26 14:19:34 +02:00
Max Kellermann
2098b94b47 DecoderThread: move code to DecoderControl::CycleMixRamp() 2013-10-26 14:12:10 +02:00
Max Kellermann
59ad6265a1 DecoderControl: add MixRamp getters 2013-10-26 14:08:09 +02:00
Max Kellermann
067572c6dd CrossFade: reimplement mixramp_interpolate() without strtok()
Don't require a writable string, and don't modify it.
2013-10-26 13:53:32 +02:00
Max Kellermann
7f03f68fcc CrossFade: apply coding style 2013-10-26 13:53:08 +02:00
Max Kellermann
de862f9f1b test/test_mixramp: unit test for mixramp_interpolate() 2013-10-26 13:49:15 +02:00
Max Kellermann
b5e31c89c0 CrossFade: merge "return" statements using "break" 2013-10-26 13:49:15 +02:00
Max Kellermann
e898400fbd CrossFade: use nullptr instead of NULL 2013-10-26 13:49:15 +02:00
Max Kellermann
3ac7de7a22 util/NumberParser: add ParseFloat() 2013-10-26 13:49:15 +02:00
Max Kellermann
ade66e7ece util/NumberParser: indent 2013-10-26 13:49:15 +02:00
Max Kellermann
6673f9e39d INSTALL: mention clang 2013-10-26 13:49:15 +02:00
Max Kellermann
2db2c0f0b7 INSTALL: mention minimum gcc version 2013-10-26 13:48:42 +02:00
Max Kellermann
17dc638c18 command: new command "readcomments" lists arbitrary file tags 2013-10-25 19:35:40 +02:00
Max Kellermann
d6e28c42e5 ReplayGainInfo: refactor to a class 2013-10-25 19:12:46 +02:00
Max Kellermann
6d475c40de ReplayGainInfo: use CamelCase for struct name 2013-10-25 19:12:38 +02:00
Max Kellermann
ed7891bf01 ReplayGainConfig: add "pure" attributes 2013-10-25 19:12:29 +02:00
Max Kellermann
e17da71a70 output/httpd: support HEAD requests 2013-10-25 00:32:48 +02:00
Max Kellermann
610bef9ff5 output/httpd: remove bogus assertion 2013-10-25 00:26:02 +02:00
Max Kellermann
961c7d0f78 OtherCommands: re-add the "volume" command
This command was removed by commit 206392ad (MPD 0.16), even though it
was been proven useful for some very simple clients.  On request, I
add it to the protocol again.
2013-10-25 00:20:36 +02:00
Max Kellermann
c1ba47beee MixerAll, Volume: add "pure" attributes 2013-10-25 00:15:55 +02:00
Max Kellermann
ac8e5be9f4 decoder/opus: support replay gain
Parse the R128_TRACK_GAIN comment string.
2013-10-24 23:56:06 +02:00
Max Kellermann
c76952534e decoder/Opus: implement seeking 2013-10-24 23:26:58 +02:00
Max Kellermann
f0060718de decoder/opus: provide time stamps
Call decoder_timestamp().  This is not necessary currently, but will
be as soon as we implement seeking.
2013-10-24 23:26:54 +02:00
Max Kellermann
982ab9e496 decoder/opus: show song duration during playback
This requires seeking to the end-of-stream, checking its granulepos,
and then seeking back to the previous file position.  We do this only
for local files.
2013-10-24 23:26:46 +02:00
Max Kellermann
b74bcf2274 decoder/opus: call ogg_stream_reset() in OggSeekPageAtOffset() 2013-10-24 23:23:23 +02:00
Max Kellermann
645cb5833d test/run_decoder: print the song duration 2013-10-24 21:35:05 +02:00
Max Kellermann
dc328e0c4a decoder/opus: move code to OggSeekPageAtOffset() 2013-10-24 20:40:23 +02:00
Max Kellermann
92c85bd20d decoder/opus: move SeekFindEOS() to OggFind.cxx 2013-10-24 20:33:12 +02:00
Max Kellermann
f629eb8cb2 decoder/opus: make opus_sample_rate constexpr 2013-10-24 20:14:47 +02:00
Max Kellermann
e4f41ff61d decoder/opus: use std::copy_n() instead of memcpy() 2013-10-24 20:06:50 +02:00
Max Kellermann
dae6ecb680 decoder/opus: support all core tag names 2013-10-24 20:01:14 +02:00
Max Kellermann
a57a7b1a76 decoder/opus: move code to ParseOpusTagName() 2013-10-24 20:01:14 +02:00
Max Kellermann
03073b366b decoder/opus: use delete[] for the OpusReader::ReadString() result 2013-10-24 20:01:14 +02:00
Max Kellermann
1bd8a9e744 DecoderAPI: add "pure" attributes 2013-10-24 20:01:05 +02:00
Max Kellermann
0a5c991ab5 decoder/wavpack: move variable declarations 2013-10-23 23:20:55 +02:00
Max Kellermann
93deb84499 input_stream: rename struct to InputStream 2013-10-23 23:12:02 +02:00
Max Kellermann
c4d4011c63 InputInternal: remove obsolete library 2013-10-23 23:10:27 +02:00
Max Kellermann
3d12f8d246 UriUtil: uri_remove_auth() returns std::string 2013-10-23 21:58:44 +02:00
Max Kellermann
c3e720279c test/test_util: unit test for libutil.a 2013-10-23 21:58:44 +02:00
Max Kellermann
f1027ed198 InputStream: add method Rewind() 2013-10-23 21:58:44 +02:00
Max Kellermann
fe3c5e4e8e DecoderThread: remove unused function deconst_plugin() 2013-10-23 21:57:28 +02:00
Max Kellermann
d110131ad6 Playlist: refresh new tags after database update
Fixes regression from commit e96779d.
2013-10-22 01:05:29 +02:00
Max Kellermann
10bc1a9acc decoder/flac: fix tag name comparison 2013-10-22 01:05:09 +02:00
Max Kellermann
3f899f83ff Playlist*, Queue: use GetDatabase() overload without Error
Don't use IgnoreError() when there's an overload that does not try to
give us one.
2013-10-22 00:59:56 +02:00
Max Kellermann
fc05768374 Queue: add method ModifyAtPosition() 2013-10-22 00:59:56 +02:00
Max Kellermann
03b57df630 Queue: ModifyAtOrder() does not increment version
Leave that to the caller, allowing it to modify multiple items at a
time.
2013-10-22 00:59:56 +02:00
Max Kellermann
4de3b6dc80 Partition: add method DatabaseModified() 2013-10-22 00:59:55 +02:00
Max Kellermann
c7bbfef19a UpdateRemove: include cleanup 2013-10-22 00:59:55 +02:00
Max Kellermann
7f1130b52b DecoderList: fix the decoder_plugin_from_mime_type() return value 2013-10-22 00:59:55 +02:00
Max Kellermann
2d696f46c3 PlaylistEdit: compare Song URIs in DeleteSong()
Fixes purging deleted songs from the queue after update.  Fixes
regression from commit e96779d.
2013-10-22 00:13:39 +02:00
Max Kellermann
2f43e4bc66 Playlist: copy stream tags from the PlayerThread
Finally restores an important feature that has been broken for several
months when the PlayerThread started working with Song copies instead
of pointers to the Queue's Song instances (commit e96779d).
2013-10-22 00:02:21 +02:00
Max Kellermann
f8c23488c9 Song: add method ReplaceTag() 2013-10-21 23:53:30 +02:00
Max Kellermann
1e2cda9239 Partition: add methods TagModified(), SyncWithPlayer()
Move code from class Instance.
2013-10-21 23:40:52 +02:00
Max Kellermann
20cba9e89f Song: pass reference to song_equals() 2013-10-21 23:19:15 +02:00
Max Kellermann
f6d67ac260 DecoderThread: simplify the decoder lookup loop
Merge the two loops into one, and eliminate the GSList.
2013-10-21 22:15:57 +02:00
Max Kellermann
74904b9cf2 DecoderList: reimplement _for_each() with function object 2013-10-21 22:02:19 +02:00
Max Kellermann
82059645f1 decoder: rename the struct to "Decoder" 2013-10-21 21:12:37 +02:00
Max Kellermann
13e9f18403 DecoderPlugin: move functions into the struct 2013-10-21 21:08:12 +02:00
Max Kellermann
875821f2ba SongUpdate: use tag_file_scan()
Eliminate duplicate code.
2013-10-21 21:05:59 +02:00
Max Kellermann
cc3be3aeed TagFile: use IgnoreError() 2013-10-21 20:52:59 +02:00
Max Kellermann
72af3c0489 decoder_plugin: rename struct to DecoderPlugin 2013-10-21 20:31:34 +02:00
Max Kellermann
65e54f6ed1 decoder/modplug: use WritableBuffer instead of GByteArray
Eliminate the temporary buffer, do I/O right into the WritableBuffer.
2013-10-21 20:22:53 +02:00
Max Kellermann
10196496f3 decoder/modplug: move code to LoadModPlugFile() 2013-10-21 20:19:27 +02:00
Max Kellermann
86f08862e4 playlist/EmbeddedCue: use std::string for the "cuesheet" attribute 2013-10-21 10:53:31 +02:00
Max Kellermann
83c726a34f GetBaseUTF8 2013-10-21 10:50:22 +02:00
Max Kellermann
a0415f73d4 archive/bz2: remove unused function bz2_quark() 2013-10-21 10:50:22 +02:00
Max Kellermann
93068f10ec fs/AllocatedPath: don't include glib.h 2013-10-21 10:27:14 +02:00
Max Kellermann
7142c81c05 DirectorySave: use Directory::GetName() 2013-10-21 10:04:59 +02:00
Max Kellermann
c0421a57da input/curl: don't use GLib's typedef "gushort" 2013-10-21 09:54:21 +02:00
Max Kellermann
8f1ec1dfdf util/NumberParser: utilities for parsing numbers from ASCII strings 2013-10-21 09:48:31 +02:00
Max Kellermann
222dc8a239 Util/ASCII: add StringEqualsCaseASCII() overload with length
Replaces GLib's g_ascii_strncasecmp().
2013-10-21 08:42:55 +02:00
Max Kellermann
0e4d2e7277 Util/ASCII: add function StringEqualsCaseASCII()
Replaces GLib's g_ascii_strcasecmp().
2013-10-20 23:09:51 +02:00
Max Kellermann
2bbff77e48 OutputControl: convert anonymous enum to constexpr 2013-10-20 13:53:01 +02:00
Max Kellermann
3315c67f0f Inotify: convert anonymous enum to constexpr 2013-10-20 13:51:55 +02:00
Max Kellermann
b879bcb1eb UpdateWalk: convert anonymous enum to constexpr 2013-10-20 13:50:34 +02:00
Max Kellermann
ae99135c8d Main: convert anonymous enum to constexpr 2013-10-20 13:47:32 +02:00
Max Kellermann
1defb38a6f DatabaseSave: convert anonymous enum to constexpr 2013-10-20 13:46:13 +02:00
Max Kellermann
56bc9e12ee ClientInternal: convert anonymous enum to constexpr 2013-10-20 13:45:47 +02:00
Max Kellermann
116ebe0494 Idle: convert anonymous enum to constexpr 2013-10-20 13:45:21 +02:00
Max Kellermann
5ec843dcc8 *Commands: move to src/command/ 2013-10-20 13:41:04 +02:00
Max Kellermann
a78b2d84ed TagType: rename enum tag_type to TagType 2013-10-20 13:32:59 +02:00
Max Kellermann
cf4d80fc65 command: convert command_return to to a strictly-typed enum 2013-10-20 13:10:54 +02:00
Max Kellermann
8118bc93a8 FatalError: remove unused GError overload 2013-10-20 13:10:09 +02:00
Max Kellermann
c772bc45c6 PlaylistError: convert playlist_result to a strictly-typed enum 2013-10-20 13:06:40 +02:00
Max Kellermann
c1e7be3b8e decoder/sidplay: add header file 2013-10-20 13:05:50 +02:00
Max Kellermann
17ecc56e83 decoder/sidplay: update file name 2013-10-20 13:03:58 +02:00
Max Kellermann
6a42e6f6d4 doc/developer: require C++11 2013-10-20 13:03:32 +02:00
Max Kellermann
75ba961e97 Client: move message functions into the class 2013-10-19 19:44:45 +02:00
Max Kellermann
c2d5ce0ca2 Client: move trivial functions into the Client class 2013-10-19 19:39:40 +02:00
Max Kellermann
32645b80c4 ClientInternal: move class Client to Client.hxx
Publish the Client API, preparing to move more code into the Client
class.
2013-10-19 19:35:37 +02:00
Max Kellermann
ff626ac763 *: use references instead of pointers 2013-10-19 18:48:38 +02:00
Max Kellermann
59f8144c50 *: use nullptr instead of NULL 2013-10-19 18:19:03 +02:00
Max Kellermann
5a7c931293 input/cdio: use class AllocatedPath 2013-10-19 17:48:46 +02:00
Max Kellermann
1373d40fea decoder/mpg123: use const_cast instead of g_strdup() 2013-10-19 17:46:00 +02:00
Max Kellermann
3274bb54ad event/ServerSocket: pass AllocatedPath to AddPath() 2013-10-19 17:40:56 +02:00
Max Kellermann
7db124068f ConfigPath: use std::string 2013-10-19 17:32:49 +02:00
Max Kellermann
39e2ffe212 decoder/mikmod: use const_cast instead of g_strdup() 2013-10-19 17:30:56 +02:00
Max Kellermann
0a213ddf03 input/curl: use std::string for meta_name
Automatic memory management.
2013-10-19 17:24:21 +02:00
Max Kellermann
5dc4cbdf82 util/FormatString: new library to replace g_strdup_printf() 2013-10-19 17:24:21 +02:00
Max Kellermann
1434e5a22e decoder/gme,input/curl,...: use static buffers instead of g_strdup_printf() 2013-10-19 17:15:17 +02:00
Max Kellermann
9acc1e1e97 Permission: use std::find instead of g_strsplit() 2013-10-19 16:47:56 +02:00
Max Kellermann
daa47546c7 Permission: move code to ParsePermission() and a table 2013-10-19 16:47:41 +02:00
Max Kellermann
c5194d0a8f Permission: convert PERMISSION_* from macro to constexpr 2013-10-19 16:47:23 +02:00
Max Kellermann
7ece8ff85c Permission: remove nullptr check
Both callers pass non-nullptr.
2013-10-19 16:40:40 +02:00
Max Kellermann
a4effeb3f9 Permission: convert PERMISSION_PASSWORD_CHAR from macro to constexpr 2013-10-19 16:39:45 +02:00
Max Kellermann
d3f28a1d7f FilterConfig: use std::find instead of g_strsplit_set() 2013-10-19 16:34:11 +02:00
Max Kellermann
03cddd0acf FilterConfig: return bool 2013-10-19 16:29:56 +02:00
Max Kellermann
04a737e04c FilterConfig: move code to filter_chain_append_new() 2013-10-19 16:26:51 +02:00
Max Kellermann
966c54bef5 FilterConfig: eliminate duplicate API documentation 2013-10-19 16:23:40 +02:00
Max Kellermann
efcd9dfc35 ConfigData: use strtoul() in GetUnsignedValue()
Lifts the artificial 31 bit limit in i386 where
sizeof(long)==sizeof(int).
2013-10-19 16:12:52 +02:00
Sebastian Thorarensen
db44a6e948 decoder/modplug: Add "loop_count" parameter
The "loop_count" configuration parameter allows the user to set how
many times a module with backward loops shall loop. "0" (the default)
means a module is not allowed to use backward loops at all. "-1"
enables inifinite looping.
2013-10-19 16:12:17 +02:00
Sebastian Thorarensen
d6553fc6a7 ConfigData: Add support for signed integers
Now config_param::GetBlockValue() can be used to get signed integers
from the configuration.
2013-10-19 16:11:33 +02:00
Ben Boeckel
fc9014f7ec PlayerThread: Only drop 0 length packets without tags
Fixes a regression from 752dfb3d95 which
caused the current chunk to be flushed as soon as new replaygain
information was found. If this occurs on a tag chunk, it has no data
(length 0) and is then skipped before pushing it to all of the outputs.

This change allows 0-length chunks through if they contain a tag and
they are now appearing in mplayer and mpv properly.
2013-10-19 15:45:11 +02:00
Max Kellermann
b39ab76118 Util/CharUtil: new library replacing g_ascii_isX() 2013-10-19 15:36:47 +02:00
Max Kellermann
90777f78c9 playlist/(Ext)M3u: use strchug_fast() 2013-10-19 15:36:47 +02:00
Max Kellermann
7cb803ad5c test/test_pcm: use C++11 random instead of GLib 2013-10-19 15:05:48 +02:00
Max Kellermann
8e063829c4 encoder/{opus,vorbis}: new serial generator replacing g_random_int() 2013-10-19 14:43:24 +02:00
Max Kellermann
139c6be370 encoder/wave: include cleanup 2013-10-19 02:05:44 +02:00
Sebastian Thorarensen
b6ac249c3c decoder/mikmod: Add loop configuration parameter
This patch allows the user to configure the mikmod decoder plugin to loop
modules. It adds a configuration parameter to the mikmod decoder called
"loop" which can be "no" (the old behaviour, default) or "yes" to allow
modules to use backward loops.
2013-10-18 14:23:24 +02:00
Max Kellermann
5e103b5fb7 filter/route: merge the two loops, one-pass parsing 2013-10-18 12:24:49 +02:00
Max Kellermann
de5be62da5 filter/route: allocate "sources" statically
Worst-case allocation using MAX_CHANNELS.
2013-10-18 12:24:47 +02:00
Max Kellermann
b5f608d026 filter/route: use int8_t instead of signed char 2013-10-18 12:24:47 +02:00
Max Kellermann
58fe352fda util/StringUtil: rename strchug_fast_c() to strchug_fast()
Overload the name.
2013-10-18 12:24:47 +02:00
Max Kellermann
b105093dcd ZeroconfAvahi: convert avahiRunning to a "bool" 2013-10-18 10:50:14 +02:00
Max Kellermann
d1c401fe7a ZeroconfAvahi: integrate into the EventLoop
Finally fixes the regression by commit c1f4f1fd.
2013-10-18 09:16:55 +02:00
Max Kellermann
964aa42b04 test/run_avahi: new debug program 2013-10-18 09:01:34 +02:00
Max Kellermann
bf8660b21c test/run_inotify: use SignalMonitor 2013-10-18 08:56:25 +02:00
Max Kellermann
43863a70c8 SignalMonitor: add SignalMonitorGetEventLoop()
Eliminate the global variable "shutdown_loop".
2013-10-18 08:44:40 +02:00
Max Kellermann
bd5a70c712 input/curl: use MultiSocketMonitor constants instead of GLib 2013-10-18 08:30:44 +02:00
Max Kellermann
909ff4b8a9 valgrind.suppressions: add g_get_home_dir suppression 2013-10-18 01:14:31 +02:00
Max Kellermann
bcfc62a3f2 PlaylistEdit, QueueSave: free the Song object after Append()
Fix for a major memory leak.
2013-10-18 01:12:47 +02:00
Max Kellermann
d1924867db valgrind.suppressions: add libGnuTLS suppression 2013-10-18 01:00:20 +02:00
Max Kellermann
abfbd55305 fs/Path: rename to AllocatedPath
The new class Path only holds a string pointer without being
responsible for allocation/deallocation.  The FileSystem.hxx library
accepts Path arguments instead of AllocatedPath, to avoid forcing
callers to allocate another string object.
2013-10-17 23:43:46 +02:00
Max Kellermann
b3611524f4 fs/Path: move definitions to struct PathTraits 2013-10-17 23:23:25 +02:00
Max Kellermann
a63613dba0 fs/Path: include clenaup 2013-10-17 23:20:26 +02:00
Max Kellermann
7fec2b02d4 fs/Charset: GetFSCharset() returns "utf-8" by default
If fs_charset is empty, i.e. we're using the default "utf-8",
GetFSCharset() should return exactly that instead of an empty
std::string.
2013-10-17 22:47:09 +02:00
Max Kellermann
608a98c873 fs/Charset: default filesystem charset is UTF-8
Implement a fast path for UTF-8 which leaves fs_charset empty, and
don't assign a value to fs_charset if there's no configuration.
2013-10-17 22:42:22 +02:00
Max Kellermann
f951e5356b fs/Charset: don't allow nullptr arguments 2013-10-17 22:39:06 +02:00
Max Kellermann
080ee87e07 fs/Path: move configuration code to Config.cxx 2013-10-17 22:29:03 +02:00
Max Kellermann
fa60b9ae94 fs/Path: move path_domain to Domain.hxx 2013-10-17 22:20:53 +02:00
Max Kellermann
0d33ae52c6 fs/Path: make fs_charset static 2013-10-17 22:10:27 +02:00
Max Kellermann
77e4b28092 fs/Path: include cleanup 2013-10-17 22:08:57 +02:00
Max Kellermann
4817437d31 fs/Limits: convert macro to "constexpr" 2013-10-17 22:08:56 +02:00
Max Kellermann
354b5a9365 fs/Path: move MPD_PATH_MAX to Limits.hxx 2013-10-17 22:00:01 +02:00
Max Kellermann
58502b38d3 *: use std::numeric_limits 2013-10-17 21:53:19 +02:00
Max Kellermann
d44880dfa9 UpdateGlue: handle update id management
Add UpdateQueueItem::id to keep track of the id in every item.
Replaces thhe hack in update_queue_push().
2013-10-17 21:45:53 +02:00
Max Kellermann
0c63632cc2 UpdateGlue: pass UpdateQueueItem around
Fixes a few kludges and avoids GLib allocation.
2013-10-17 21:45:42 +02:00
Max Kellermann
b93523c0b1 UpdateGlue: never pass null to update_enqueue() 2013-10-17 21:45:41 +02:00
Max Kellermann
7ef40de98b UpdateQueue: use std::string and std::queue 2013-10-17 21:13:40 +02:00
Max Kellermann
196ec25682 Mapper: use std::string 2013-10-17 19:54:58 +02:00
Max Kellermann
c85af12d45 StickerDatabase: return std::string 2013-10-17 19:39:23 +02:00
Max Kellermann
e452d1f5b4 StickerDatabase: add pure/const attributes 2013-10-17 19:39:22 +02:00
Max Kellermann
ffea268d2e PlayerControl: GetError() returns an Error, not a char* 2013-10-17 19:34:59 +02:00
Max Kellermann
8e676db633 Thread/Thread: replacement library for GThread 2013-10-17 19:29:47 +02:00
Max Kellermann
f6d74012b7 util/Error: add method SetLastError() 2013-10-17 19:29:38 +02:00
Max Kellermann
32dfc11c23 Main: use ThreadId instead of GThread* 2013-10-17 19:28:34 +02:00
Max Kellermann
aad0ea6e23 Makefile.am: move sources to libthread.a 2013-10-17 19:26:23 +02:00
Max Kellermann
05de2e998c InputStream: use int64_t instead of goffset
Decouple some more from GLib.
2013-10-17 10:45:10 +02:00
Max Kellermann
24780d99e6 input_plugin: rename struct to "InputPlugin" 2013-10-17 10:20:57 +02:00
Max Kellermann
7c1cf61728 thread/{Cond,Mutex}: use "class" instead of "typedef"
Allows forward-declaration.
2013-10-17 10:06:31 +02:00
Max Kellermann
eb10d08671 CueParser: use std::string 2013-10-17 01:34:10 +02:00
Max Kellermann
abb0549e4b InotifyUpdate: use class Path 2013-10-17 01:16:46 +02:00
Max Kellermann
5327ea13ac PlaylistSave: eliminate the last g_warning() call 2013-10-17 01:15:54 +02:00
Max Kellermann
be8ceae6e6 Song: GetURI() returns std::string 2013-10-17 01:01:15 +02:00
Max Kellermann
67ae033de7 ArchiveLookup: in-place editing, avoid string copy 2013-10-17 00:54:20 +02:00
Max Kellermann
161f7ced96 ArchiveLookup: declare local variables later 2013-10-17 00:48:58 +02:00
Max Kellermann
72bc11b180 ArchiveLookup: don't reset out arguments
If we return false, their values are undefined.
2013-10-17 00:46:26 +02:00
Max Kellermann
15c2538532 ArchiveLookup: move code to FindSlash() 2013-10-17 00:44:57 +02:00
Max Kellermann
fd9dd9343b ArchiveLookup: move code to FindSuffix() 2013-10-17 00:38:26 +02:00
Max Kellermann
1b8a1d4140 ArchiveLookup: return const strings 2013-10-17 00:36:52 +02:00
Max Kellermann
e132d10aec ArchiveLookup: move API documentation to header 2013-10-17 00:36:35 +02:00
Max Kellermann
3dbda2dda2 test/test_archive: unit test for archive_lookup() 2013-10-17 00:19:22 +02:00
Max Kellermann
a0105b45ae configure.ac: add function MPD_AUTO_LIB and use it 2013-10-17 00:09:08 +02:00
Max Kellermann
551b7768fc configure.ac: define HAVE_MPCDEC
Restore the "mpcdec" decoder plugin that was accidently broken since
commit 8ead8f7e.
2013-10-17 00:07:04 +02:00
Max Kellermann
d6967db761 decoder/wildmidi: remove suport for libwildmidi 0.2.2 or older 2013-10-16 23:57:26 +02:00
Max Kellermann
b0967cae69 configure.ac: don't leak -lsidutils -lmp3lame into
Make the third argument to AC_CHECK_LIB() non-empty to disable its
default handler.
2013-10-16 23:46:11 +02:00
Max Kellermann
401a799a1b test: use the CPPUNIT framework for unit tests 2013-10-16 23:36:36 +02:00
Max Kellermann
ba98518c69 Makefile.am: distribute util/Domain.hxx and system/ByteOrder.hxx 2013-10-16 23:36:03 +02:00
Max Kellermann
5e26e2ab1d system/ByteOrder: new library for byte ordering / endianess
Replacing GLib macros.
2013-10-16 22:09:44 +02:00
Max Kellermann
08eca827b6 util/ByteReverse: use C99 "restrict"
Micro-optimization.
2013-10-16 22:07:59 +02:00
Max Kellermann
6b2b5af344 util/byte_reverse: convert to C++ 2013-10-16 22:07:52 +02:00
Max Kellermann
f32fbd9ed1 pcm_pack: convert to C++ 2013-10-16 22:07:43 +02:00
Max Kellermann
e3511d0ee0 encoder/wave: use delete to dispose the WaveEncoder object 2013-10-16 22:07:32 +02:00
Max Kellermann
fa13a6616f Archive*: move archive_domain to ArchiveDomain.cxx
Merge duplicate symbol.
2013-10-15 23:24:54 +02:00
Max Kellermann
d4c2f91182 ConfigData: remove unused method DupBlockString() 2013-10-15 23:19:44 +02:00
Max Kellermann
084fd8df63 playlist/soundcloud: use std::string 2013-10-15 23:17:53 +02:00
Max Kellermann
328131b7aa output/roar: use const_cast instead of g_strdup() 2013-10-15 23:14:34 +02:00
Max Kellermann
85003429af output/roar: use std::string 2013-10-15 23:11:32 +02:00
Max Kellermann
6db77dcf75 output/roar: move code into the RoarOutput class 2013-10-15 22:58:38 +02:00
Max Kellermann
1cde86823d output/pipe: use std::string 2013-10-15 22:52:04 +02:00
Max Kellermann
dbd88e6aef Client, ...: remove unnecessary glib.h include 2013-10-15 22:51:09 +02:00
Max Kellermann
45418583e9 ApeTag: use std::string for temporary allocation 2013-10-15 22:50:02 +02:00
Max Kellermann
77a1133723 PlaylistRegistry: use std::string for temporary allocation 2013-10-15 22:49:51 +02:00
Max Kellermann
25c208d81d input/*: don't allocate attribute "mime"
This was a memory leak, because "mime" was a std::string which created
another copy and discarded the allocated buffer.
2013-10-15 22:49:23 +02:00
Max Kellermann
67f87db511 UpdateArchive: use std::string for temporary string 2013-10-15 22:49:12 +02:00
Max Kellermann
7de96275dd ConfigData: use std::string for config_param::value 2013-10-15 22:49:01 +02:00
Max Kellermann
e13d0bf656 Permission: use std::string for temporary password allocation
As a side effect, this fixes a memory leak.
2013-10-15 22:48:09 +02:00
Max Kellermann
8ed9f7effa Mapper: remove obsolete variable music_dir_fs_length 2013-10-15 22:48:01 +02:00
Max Kellermann
12ab556477 event/BufferedSocket: pass writable pointer to OnSocketInput()
Remove the const_cast from HttpdClient.cxx, and avoid one allocation
in ClientRead.cxx.
2013-10-15 22:47:46 +02:00
Max Kellermann
509f8dab89 Util/Macros: replacement for GLib's G_N_ELEMENTS() 2013-10-15 22:47:39 +02:00
Max Kellermann
77429b6dd3 output/winmm: use delete instead of g_free() 2013-10-15 22:47:25 +02:00
Max Kellermann
84d20d9e43 util/FifoBuffer: C++ version of the fifo_buffer library 2013-10-15 10:28:52 +02:00
Max Kellermann
0c13703da3 system/clock: convert to C++ 2013-10-15 09:38:12 +02:00
Max Kellermann
b97b7a7493 require GLib 2.28
The header glib_compat.h is now obsolete and can be removed.
2013-10-15 09:35:25 +02:00
Max Kellermann
be2951b45f gcc.h: rename to Compiler.h 2013-10-15 09:21:59 +02:00
Max Kellermann
1dd1a705b5 gcc.h: major update
Copy the according file from another project (i.e. XCSoar).  This will
allow copying more code more easily.
2013-10-15 09:13:22 +02:00
Max Kellermann
e4e80ff0cb *: use WIN32 instead of G_OS_WIN32 2013-10-15 08:33:44 +02:00
Max Kellermann
9508ea982b fs/Path: add method IsAbsolute() 2013-10-14 22:38:29 +02:00
Max Kellermann
47d655ea7f fs/Path: add separator constants/functions 2013-10-14 22:26:23 +02:00
Max Kellermann
62271bf6ce PlaylistFile: always check for absolute paths within music_directory
Try map_fs_to_utf8() first, and fall back to Path::ToUTF8() for
absolute paths.
2013-10-14 22:21:22 +02:00
Max Kellermann
0b27ac2f5c fs/Path: add method RelativeFS()
Move code from map_fs_to_utf8().
2013-10-14 22:09:02 +02:00
Max Kellermann
6fd481df97 Mapper, ...: use memcmp() instead of strncmp() where appropriate
Micro-optimization.
2013-10-14 22:00:21 +02:00
Max Kellermann
b915e43391 fs/Path: add method data() 2013-10-14 21:57:43 +02:00
Max Kellermann
c96b295700 PlaylistFile: fix memory leak
Consistently use std::string in LoadPlaylistFile().
2013-10-14 21:53:08 +02:00
Max Kellermann
9067da2df8 Mapper: map_fs_to_utf8() returns std::string
Avoid the conversion to an allocated char*, let the caller decide.
2013-10-14 21:43:41 +02:00
Max Kellermann
8cf2f52f7a Merge tag 'release-0.17.6' 2013-10-14 21:40:56 +02:00
Max Kellermann
681352ac3b release 0.17.6 2013-10-14 21:15:55 +02:00
Florian Schlichting
d9c662d51f decoder/modplug: fix include directory 2013-10-14 21:12:47 +02:00
Max Kellermann
ad631d563b stored_playlist: use fs_charset_to_utf8() for URLs 2013-10-14 21:11:20 +02:00
Max Kellermann
7cbaf11dda load_file 2013-10-14 21:00:46 +02:00
Max Kellermann
3be63549c0 stored_playlist: add "file://" prefix to absolute paths
Prepare to fix loading arbitrary song files from stored playlists.
2013-10-14 20:52:49 +02:00
Max Kellermann
17c6db6c33 replay_gain_*.h: rename to *.hxx 2013-10-02 12:22:12 +02:00
Max Kellermann
86316b1828 output/httpd: don't include glib.h in header 2013-10-02 12:20:36 +02:00
Max Kellermann
efc3a69dbf Stats: don't include glib.h in header
Use forward declaration instead.
2013-10-02 12:16:52 +02:00
Max Kellermann
ec883e1901 Stats: rename stats.h to Stats.hxx 2013-10-02 12:14:07 +02:00
Max Kellermann
060814daa8 Log: new logging library API
Prepare to migrate away from GLib.  Currently, we're still using GLib
as a backend.
2013-10-02 08:57:55 +02:00
Max Kellermann
c53492a76a TextFile: don't include glib.h in header
Un-inline the methods that use GLib.
2013-10-02 08:56:27 +02:00
Max Kellermann
43675717b8 filesystem/Path: use std::string 2013-10-02 08:56:27 +02:00
Max Kellermann
b21ed2fa36 PlaylistMapper: convert playlist name to filesystem charset 2013-10-02 08:56:27 +02:00
Max Kellermann
0214baad5a Playlist*: use nullptr instead of NULL 2013-10-02 08:56:27 +02:00
Max Kellermann
c2d3ed2acc Listen, ...: add missing includes 2013-10-02 08:56:27 +02:00
Max Kellermann
0339c8d025 ConfigData: handle default_value==nullptr
Return Path::Null() instead of dying from assertion failure.
2013-10-02 08:56:02 +02:00
Max Kellermann
0e0be0243b Daemon, Mapper: move-assign the Path objects 2013-10-01 18:50:18 +02:00
Max Kellermann
a2ce2447a6 Merge branch 'v0.17.x' 2013-10-01 17:20:38 +02:00
Max Kellermann
9a1076256d mixer/alsa: handle ENODEV
Fixes busy loop when USB sound device gets unplugged (Mantis bug
#3824).
2013-10-01 16:35:27 +02:00
Max Kellermann
72ef38d4a7 mixer/alsa: log snd_mixer_handle_events() errors 2013-10-01 16:30:20 +02:00
Max Kellermann
d397ce68dc prepare 0.17.6 2013-10-01 16:29:54 +02:00
Max Kellermann
5e20b7976f DecoderControl: lock the mutex in Seek()
Use LockSynchronousCommand() instead of SynchronousCommandLocked().
Fixes regression from commit ef663810 (dead lock due to cond_wait with
unlocked mutex).
2013-09-30 16:20:35 +02:00
Max Kellermann
36f712b949 tag/{riff,aiff}: convert to C++ 2013-09-28 14:14:13 +02:00
Max Kellermann
a446775d80 playlist/lastfm: remove defunct Last.fm support
This plugin has been defunct ever since Last.fm changed their
protocol.  Since there is no volunteer willing to fix the plugin, I'm
removing it now.
2013-09-28 14:01:51 +02:00
Max Kellermann
ccd7f0825a DecoderControl: use GLib forward declarations 2013-09-27 23:00:23 +02:00
Max Kellermann
d0896ea7c4 PlayerThread: convert struct player to a class 2013-09-27 22:22:11 +02:00
Max Kellermann
a73d1e4b1c PlayerThread: use strictly typed enum 2013-09-27 22:19:26 +02:00
Max Kellermann
d05bb2a0af PlayerControl: use strictly typed enums 2013-09-27 22:07:20 +02:00
Max Kellermann
6765901687 DecoderControl: convert "enum decoder_state" to strictly-typed enum 2013-09-27 12:27:33 +02:00
Max Kellermann
c5d05ac0cf DecoderCommand: convert to strictly-typed enum 2013-09-27 12:11:37 +02:00
Max Kellermann
939003c1f1 OutputAll: add pure/const attributes 2013-09-27 09:38:47 +02:00
Max Kellermann
a10f3a8aec PlayerControl: convert functions to methods 2013-09-27 09:30:19 +02:00
Max Kellermann
ef663810a2 DecoderControl: convert functions to methods 2013-09-27 09:18:03 +02:00
Max Kellermann
ada67a6a4f PlayerThread: move code to player_control::CommandFinished() 2013-09-27 07:58:48 +02:00
Max Kellermann
b6a5d1ad5a PlayerThread: use nullptr instead of NULL 2013-09-27 00:03:22 +02:00
Max Kellermann
d8c5a63bc2 PlayerThread: unlock/lock in player_task() 2013-09-26 23:58:41 +02:00
Max Kellermann
bcb2db62c9 PlayerThread: move code into the player class 2013-09-26 23:57:31 +02:00
Max Kellermann
079ef93121 PlayerThread: use player references 2013-09-26 23:27:47 +02:00
Max Kellermann
b2789c598e PlayerThread: use {decoder,player}_control references 2013-09-26 22:53:40 +02:00
Max Kellermann
92a93c1217 PlayerThread: allocate decoder_control on the stack 2013-09-26 22:48:55 +02:00
Max Kellermann
96b70835f9 PlayerThread: move global MusicBuffer variable into the player object 2013-09-26 22:45:49 +02:00
Max Kellermann
7fa3b7a267 PlayerThread: simplify "buffer empty" assertion 2013-09-26 22:41:07 +02:00
Max Kellermann
f3fc76e3c8 MusicChunk: remove obsolete prototypes 2013-09-26 22:34:43 +02:00
Max Kellermann
3216f4b257 MusicBuffer: expose the C++ API 2013-09-26 22:21:56 +02:00
Max Kellermann
ce1d897575 MusicPipe: expose the C++ API 2013-09-26 21:51:45 +02:00
Max Kellermann
17e108a10a MusicChunk: use constexpr for CHUNK_SIZE 2013-09-26 21:49:26 +02:00
Max Kellermann
5bc4ab899f *Plugin: remove redundant "line %i" from error messages
The MPD core will add this as a prefeix.
2013-09-26 20:59:40 +02:00
Max Kellermann
44faf1080c SongFilter: search for album artist falls back to the artist tag
Implement Mantis ticket 0003646.
2013-09-26 19:25:13 +02:00
Max Kellermann
e354c5c2a8 IdTable, SongFilter: use std::fill_n() instead of std::fill() 2013-09-26 18:25:28 +02:00
Max Kellermann
04bc9005ae TagType: reduce the enum size to 1 byte
Reduce the TagItem overhead.
2013-09-26 18:14:58 +02:00
Max Kellermann
3c92c69bc7 Tag: add "pure" attributes 2013-09-26 18:11:00 +02:00
Max Kellermann
52ee132d92 TagHandler: use a TagBuilder internally
Reduce heap allocator overhead.
2013-09-26 17:35:08 +02:00
Max Kellermann
7ca0aedcfc Main: fix crash if no database was configured
Add nullptr check, and return early from glue_db_init_and_load().
2013-09-26 17:33:46 +02:00
Max Kellermann
a2c4037a24 Main: use nullptr instead of NULL 2013-09-26 17:31:50 +02:00
Max Kellermann
d7b0073ce1 decoder/modplug: fix include directory
Since Debian package 1:0.8.8.4-4, the pkg-config file does not contain
-I/usr/include/libmodplug anymore, and we need to add the
"libmodplug/" prefix to the #include line.
2013-09-26 17:27:35 +02:00
Artem Savkov
585b68d2ae input/curl: fix EventLoop stall after curl_easy_pause
When playing finite http streams, e.g. something from soundcloud,
eventloop stalls after pausing writefunc. TimeoutMonitor is cancelled
by the time resume happens, so when enough data is consumed writefunc
is called only once. Calling InvalidateSockets() from
input_curl_resume() seems to fix the issue.
2013-09-26 17:27:35 +02:00
Max Kellermann
89d2d648cc ConfigPath: return early on "~"
Previously, the pointer was moved to undefined memory.
2013-09-12 11:05:59 +02:00
Max Kellermann
7532f24d58 ConfigPath: skip the slash of "~/"
Increment the "path" earlier.
2013-09-12 11:05:41 +02:00
Max Kellermann
69a5df2f98 ConfigPath: remove the "~/" from the constructed path
This was building broken paths like "/home/foo/~/bar".  Bug found by
Maarten de Vries.
2013-09-12 10:54:45 +02:00
Max Kellermann
1c65908cdb ConfigPath: simplify the duplicate tilde check 2013-09-12 10:49:57 +02:00
Max Kellermann
3aaf013dd1 ConfigPath: convert "home" variable to Path object
Use Path::FromUTF8() for the g_get_home_dir() return value instead of
assuming it's already FS charset.
2013-09-12 10:35:40 +02:00
Max Kellermann
5f2705ab07 ConfigPath: move code to GetHome() 2013-09-12 10:30:00 +02:00
Max Kellermann
9af620982c ConfigPath: include cleanup 2013-09-12 10:17:41 +02:00
Max Kellermann
1ee6a78cb7 Path: add FromUTF8() overload that returns an Error 2013-09-12 10:17:41 +02:00
Max Kellermann
bf4ee48efa ConfigPath: move path_domain to system/Path.cxx 2013-09-12 10:03:37 +02:00
Maarten de Vries
08e6d222a2 Listen: Allow tilde paths for socket. 2013-09-12 08:55:45 +02:00
Max Kellermann
cf98b0e261 test/dump_rva2: remove fake Tag symbols 2013-09-05 19:25:50 +02:00
Max Kellermann
a24589d46e TagBuilder: add method Commit(Tag&)
For callers that already have a Tag instance.
2013-09-05 19:23:06 +02:00
Max Kellermann
84533b6cad TagBuilder: add method IsEmpty() 2013-09-05 19:14:47 +02:00
Max Kellermann
8dca38e979 Tag: remove the obsolete "bulk" mode
Methods BeginAdd() and EndAdd() have been replaced by class
TagBuilder.
2013-09-05 19:08:22 +02:00
Max Kellermann
662bed6a00 db/proxy: use class TagBuilder 2013-09-05 19:07:27 +02:00
Max Kellermann
ae5e0cb02b SongSave: use class TagBuilder 2013-09-05 18:59:19 +02:00
Max Kellermann
0b3e1c4706 TagBuilder: new class for constructing Tag objects
Obsoletes Tag::BeginAdd() and the complicated "bulk add" code.
2013-09-05 18:41:49 +02:00
Max Kellermann
ce08a7a932 TagItem: disable the copy constructor/operator
This is not a C++ class and must not be copied.
2013-09-05 18:41:01 +02:00
Max Kellermann
5d5f21bfc5 Tag: compile-time initialisation of ignore_tag_items
Move to TagSettings.c and use C99 initializers.
2013-09-05 18:34:12 +02:00
Max Kellermann
fcccedc588 Tag: move struct TagItem to TagItem.hxx 2013-09-05 18:28:07 +02:00
Max Kellermann
0d73a49327 Tag: move fix_tag_value() to TagString.cxx 2013-09-05 18:27:40 +02:00
Max Kellermann
6239dd96f2 Tag: remove unused methods 2013-09-05 18:27:31 +02:00
Max Kellermann
57a4700fb9 TagNames: make tag_item_names const 2013-09-05 18:27:23 +02:00
Max Kellermann
2b676dc5fc Tag: move configuration code to TagConfig.cxx
Allow using the Tag.cxx library without the Config library.
2013-09-05 18:27:08 +02:00
Max Kellermann
3f267b1795 Tag, ...: move to libtag.a 2013-09-05 18:26:56 +02:00
Max Kellermann
7a4c9f5f4c mpd_error.h: remove obsolete header
Migrate the remaining callers to FatalError().
2013-09-05 18:26:46 +02:00
Ales Guzik
3330aa6f6a input/curl: enable https 2013-09-05 11:56:49 +02:00
Max Kellermann
8929f88e6d PlaylistPlugin: add interface SongEnumerator
Replaces struct playlist_provider.
2013-09-05 09:40:55 +02:00
Max Kellermann
5348808bf5 PlaylistPlugin, ConfigGlobal: use nullptr instead of NULL 2013-09-05 09:40:32 +02:00
Max Kellermann
fccba1af2a use standard snprintf() instead of GLib g_snprintf() 2013-09-05 09:21:53 +02:00
Max Kellermann
26d92c80ed conf.h: remove obsolete header
Use only ConfigData.hxx in plugin sources to reduce header
dependencies.
2013-09-05 08:47:10 +02:00
Max Kellermann
9605e24655 conf.h: move constants to ConfigDefaults.hxx 2013-09-05 08:42:08 +02:00
Max Kellermann
7d0269d2ce InputLegacy: move functions to the input_stream class 2013-09-05 00:23:14 +02:00
Max Kellermann
52ffdb0a55 test/read_tags: use input_stream_wait_ready() 2013-09-05 00:22:43 +02:00
Max Kellermann
681d6bbdc5 TagTable: un-inline the two functions
Reduce header dependencies.
2013-09-04 23:57:30 +02:00
Max Kellermann
867b82b6de Tag*: move TagTable.hxx to libtag.a 2013-09-04 23:54:37 +02:00
Max Kellermann
5101ef4b02 Tag*: move libtag.a sources to src/tag/ 2013-09-04 23:46:20 +02:00
Max Kellermann
ee9e238179 system/SocketError: un-inline constructor
Reduces header dependencies.
2013-09-04 23:36:30 +02:00
Max Kellermann
29030b54c9 util/Error: new error passing library
Replaces GLib's GError.
2013-09-04 18:14:22 +02:00
Max Kellermann
c9fcc7f148 system/resolver: convert to C++ 2013-09-04 18:02:09 +02:00
Max Kellermann
d1f4a31b5e output/pulse: require libpulse 0.9.16
Remove all #ifdefs.  Old versions of libpulse are not being tested,
and thus I'm removing support.
2013-09-04 16:55:03 +02:00
Max Kellermann
b691d3123b IOThread: pass GError to FatalError()
Fixes build failure on GLib < 2.32.
2013-09-04 16:54:52 +02:00
Max Kellermann
f68e36f8c2 DatabaseSave: eliminate redundant db_quark() implementation 2013-09-03 11:52:57 +02:00
Max Kellermann
4db119c01b IOThread: use FatalError() on g_thread_create() error
New GLib versions don't fail.
2013-09-03 11:28:47 +02:00
Max Kellermann
bbd7115564 input/{mms,despotify}: remove "seek" implementation
Omitting it has the same effect as returning false unconditionally.
2013-09-03 10:54:29 +02:00
Max Kellermann
8d36367fe2 input_stream.h: rename to InputLegacy.hxx 2013-09-03 09:18:30 +02:00
Max Kellermann
3deca8fccd db_error: convert to C++ 2013-08-10 19:43:27 +02:00
Max Kellermann
7af24c4d3a playlist_error: convert to C++ 2013-08-10 19:40:45 +02:00
Max Kellermann
7f0ce4e94e ack.h: move to protocol/ 2013-08-10 19:32:41 +02:00
Max Kellermann
5c48d3fbba alsa/mixer: defer InvalidateSockets() call to I/O thread 2013-08-10 14:05:06 +02:00
Max Kellermann
00420ef9ca EventLoop: initialise the thread id explicitly 2013-08-10 14:01:55 +02:00
Max Kellermann
b9d30595d6 ZeroconfAvahi: disable Avahi with epoll
Temporary hotfix until we have integrated avahi into our new event
loop.
2013-08-10 13:59:01 +02:00
Max Kellermann
c1f4f1fdb6 EventLoop: new implementation using epoll
Implement an event loop without GLib.
2013-08-10 13:54:23 +02:00
Max Kellermann
342333f72a mixer/alsa: invoke InvalidateSockets() in constructor 2013-08-10 13:54:23 +02:00
Max Kellermann
94cdc47786 event/Call: signal the calling thread
Fixes regression from commit 018f4155.
2013-08-10 12:40:44 +02:00
Max Kellermann
cc511e7b60 event/IdleMonitor: new monitor class 2013-08-10 11:52:31 +02:00
Max Kellermann
bb2af791e9 event/MultiSocketMonitor: add struct SingleFD
Prepare for migrating away from GLib.
2013-08-10 11:52:31 +02:00
Max Kellermann
f3f4b332ae event/MultiSocketMonitor: use uint64_t instead of gint64
Unsigned and portable.
2013-08-10 11:52:31 +02:00
Max Kellermann
84ac79bb08 event/MultiSocketMonitor: eliminate virtual method CheckSockets()
Handle timeout internally.
2013-08-10 11:52:31 +02:00
Max Kellermann
be0c8495cd event/MultiSocketMonitor: PrepareSockets() returns timeout
Simplify the API, don't use GLib specific integer type.
2013-08-10 11:52:31 +02:00
Max Kellermann
cbd0709d1c glib_compat.h: use monotonic_clock_us() in g_source_get_time() 2013-08-10 11:52:31 +02:00
Max Kellermann
371d635da8 glib_compat.h: remove unused wrapper g_file_test() 2013-08-10 11:52:31 +02:00
Max Kellermann
85216966fa decoder/wildmidi: use class Path for the "timidity.cfg" location 2013-08-10 11:52:31 +02:00
Max Kellermann
1c823e9d1f ConfigData: overload GetBlockPath() with default value 2013-08-10 11:52:31 +02:00
Max Kellermann
25e338a098 ConfigData: use FatalError() instead of MPD_ERROR() 2013-08-10 11:52:31 +02:00
Max Kellermann
81175b0717 system/EPollFD: fix typo in Add() 2013-08-10 11:52:31 +02:00
Max Kellermann
d23c907a94 thread/Id: new class replacing GThread pointers
Remove a GLib dependencies from class EventLoop and DatabaseLock.
2013-08-10 09:00:04 +02:00
Max Kellermann
018f4155eb event: add function BlockingCall()
Replaces io_thread_call().  This approach is more generic and easier
to use due to std::function.
2013-08-08 23:04:07 +02:00
Max Kellermann
9ab0a1f5f1 EventLoop: add methodd IsInside()
Track which thread runs the EventLoop and provide a check whether
we're currently inside.
2013-08-08 23:04:01 +02:00
Max Kellermann
c043b337b1 EventLoop: un-inline Run() and others
Prepare for adding more code.
2013-08-08 23:03:49 +02:00
Max Kellermann
090bc6fa79 event/*Monitor: add method GetEventLoop() 2013-08-08 23:03:38 +02:00
Max Kellermann
b63db1c1aa event/SocketMonitor: un-inline Schedule()
Merge with CommitEventFlags().
2013-08-08 00:18:59 +02:00
Max Kellermann
0287ac794e event/SocketMonitor: add assertions 2013-08-08 00:18:59 +02:00
Max Kellermann
0005221533 output/httpd: use "unsigned" instead of "guint" 2013-08-08 00:18:59 +02:00
Max Kellermann
23d2c0f1c6 Client{Event,Write}: add missing include 2013-08-08 00:14:19 +02:00
Max Kellermann
377b6f05ea event/BufferedSocket: add missing include 2013-08-08 00:11:40 +02:00
Max Kellermann
3ac2e9d31f os/FileSystem: disable mkfifo() wrapper on WIN32 2013-08-07 20:31:27 +02:00
Max Kellermann
b76a29a69a ConfigPath: return a Path object
Migrate all callers to use Path directly, instead of doing the
conversion in each caller.
2013-08-07 19:59:09 +02:00
Max Kellermann
abe090ec1f *: remove remaining __cplusplus checks 2013-08-07 19:58:52 +02:00
Max Kellermann
dff05c71e6 event/EPollFD: basic support for Linux epoll 2013-08-07 19:44:43 +02:00
Max Kellermann
f6f4742410 event/DeferredMonitor: rename Run() to RunDeferred() 2013-08-07 19:39:26 +02:00
Max Kellermann
977004c350 event/DeferredMonitor: use EventLoop::AddIdle() 2013-08-07 19:38:10 +02:00
Max Kellermann
fdc7d13ad1 configure.ac: pass option name to MPD_OPTIONAL_FUNC() 2013-08-07 19:23:00 +02:00
Max Kellermann
355dd5cb24 event/DeferredMonitor: new class wrapping g_idle_add() 2013-08-07 18:59:42 +02:00
Max Kellermann
123dd5fe2d mixer/alsa: use AllocatedArray for the pollfd buffer 2013-08-07 18:56:57 +02:00
Max Kellermann
953e3190ca encoder/lame: use ReusableBuffer instead of AllocatedArray 2013-08-07 18:53:24 +02:00
Max Kellermann
44a0e21795 PcmBuffer: move code to new class ReusableBuffer
ReusableBuffer is more generic.
2013-08-07 18:51:21 +02:00
Max Kellermann
fafaf567f9 Makefile: fix "distcheck" errors 2013-08-07 18:49:05 +02:00
Max Kellermann
870cc1d928 add missing includes 2013-08-07 18:23:55 +02:00
Max Kellermann
d86ee93801 filter/Route: don't access PcmBuffer attributes directly
Return the pointer given by PcmBuffer::Get() instead of reaching into
the PcmBuffer object.
2013-08-07 18:23:34 +02:00
Alexander Gehrke
87b7328463 CommandLine.cxx: look for config file in XDG_CONFIG_HOME too
Look for "$XDG_CONFIG_HOME/mpd/mpd.conf", similar to where mpd looks
for the file under Windows.
2013-08-07 18:22:27 +02:00
Alexis Ballier
3f846cf6b8 FfmpegDecoderPlugin: Allocate the interleaved buffer as needed instead of using an arbitrary big constant.
Also, save a memcpy when FFmpeg outputs interleaved audio.

Fixes build with FFmpeg 2.0.
2013-08-07 15:07:41 +02:00
Max Kellermann
f2ce8c3b62 event/EventFD: move to libsystem 2013-08-07 11:52:26 +02:00
Max Kellermann
4223657ab8 event/SignalMonitor: use signalfd() if available 2013-08-07 11:03:47 +02:00
Max Kellermann
930128a7ea SignalHandlers: move code to new class SignalMonitor 2013-08-07 10:56:33 +02:00
Max Kellermann
db447440ff event/Event{Pipe,FD}: auto-create in constructor
Errors are fatal now.  This makes the class a lot easier to use.
2013-08-07 10:53:22 +02:00
Max Kellermann
b70d38dc10 Makefile.am: move sources to libsystem.a 2013-08-07 10:31:31 +02:00
Max Kellermann
a27d105dcd FatalError: new library to replace mpd_error.h 2013-08-07 10:08:36 +02:00
Max Kellermann
67e44b0f2c daemon: convert to C++ 2013-08-07 09:53:33 +02:00
Max Kellermann
bf840700e4 test/signals: remove obsolete library 2013-08-07 09:51:43 +02:00
Max Kellermann
47e16dbee3 configure.ac: add option --enable-eventfd
Remove the runtime check for eventfd(), hard-code the feature once
it's been selected at compile time.  The class WakeFD is splitted into
EventFD and EventPipe, using WakeFD as a macro diversion.
2013-08-06 23:32:21 +02:00
Max Kellermann
66f678023f util/Manual: add missing include <utility> 2013-08-06 22:34:20 +02:00
Max Kellermann
132971f8eb playlist/pls: use std::string instead of GString 2013-08-06 09:32:08 +02:00
Max Kellermann
3f04a4d635 encoder/lame: dynamic output buffer 2013-08-06 09:13:28 +02:00
Max Kellermann
17c8e839b6 encoder/lame: use delete instead of g_free() 2013-08-06 09:13:07 +02:00
Max Kellermann
348bdcd7b7 encoder/lame: use lame_encode_buffer_interleaved()
Don't deinterleave manually, don't allocate memory.
2013-08-06 09:10:30 +02:00
Max Kellermann
a32443c63b encoder/lame: use offset variable instead of memmove() 2013-08-06 09:02:48 +02:00
Max Kellermann
7e53934ce3 encoder/lame: rename "buffer" to "output_buffer" 2013-08-06 09:02:48 +02:00
Max Kellermann
7c2b553364 playlist/EmbbeddedCue: convert to class 2013-08-05 22:23:33 +02:00
Max Kellermann
409fc837ab playlist/lastfm: convert to class 2013-08-05 21:44:34 +02:00
Max Kellermann
6d0ada7f45 playlist/lastfm: allocate the lastfm_playlist object at the end
Simplify the error path, because the other allocations may fail.
2013-08-05 21:31:54 +02:00
Max Kellermann
af63372d2b playlist/m3u: allocate ExtM3uPlaylist with new/delete 2013-08-05 21:28:19 +02:00
Max Kellermann
3e91f757a9 playlist/extm3u: allocate ExtM3uPlaylist with new/delete 2013-08-05 21:25:25 +02:00
Max Kellermann
498491ec05 decoder/ffmpeg: convert struct mpd_ffmpeg_stream to a class 2013-08-05 00:15:25 +02:00
Max Kellermann
85b77b81ca *: use gcc.h macros instead of GLib 2013-08-04 23:48:01 +02:00
Andrzej Rybczak
5bf2ec5a74 DatabasePrint: print Last-Modified attribute for directories 2013-08-04 23:29:24 +02:00
Max Kellermann
9e715089a4 Commands: new command "toggleoutput" 2013-08-04 23:21:23 +02:00
Max Kellermann
1a852bc365 configure.ac: increase protocol version to 0.18 2013-08-04 23:21:23 +02:00
Max Kellermann
9326ce53ec Merge tag 'release-0.17.5' 2013-08-04 14:36:22 +02:00
Max Kellermann
d8217c364a release 0.17.5 2013-08-04 14:21:45 +02:00
Justin Riley
3a34fd181d FfmpegDecoderPlugin: add application/flv to mime types list 2013-08-04 14:20:16 +02:00
Max Kellermann
fcb7233b25 ConfigData: remove obsolete functions 2013-08-04 14:07:50 +02:00
Max Kellermann
fe53a376a3 PlaylistPlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
65842cd99e DatabasePlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
bf6ed643e0 InputPlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
a0beb5fa26 MixerPlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
f54bcc1f16 FilterPlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
ca0d09c50f EncoderPlugin: pass config_param reference 2013-08-04 14:07:50 +02:00
Max Kellermann
81c3224076 OutputPlugin: pass config_param reference 2013-08-04 14:07:49 +02:00
Max Kellermann
7a1d466fb2 DecoderPlugin: pass config_param reference 2013-08-04 13:30:47 +02:00
Max Kellermann
83f4c48c8a ConfigData: move code to block_param, config_param methods 2013-08-04 12:03:56 +02:00
Max Kellermann
acd742d225 ConfigData: remove C++ checks 2013-08-03 23:47:31 +02:00
Max Kellermann
d1e7b4e381 audio_format: convert to C++ 2013-08-03 21:37:56 +02:00
Max Kellermann
67f591a9ce gcc.h: add macro gcc_unreachable() 2013-08-03 21:34:17 +02:00
Christoph Mende
7ff988275f decoder/mikmod: use MikMod_free() to free the title on libmikmod-3.2
Player_LoadTitle() returns an aligned pointer in libmikmod-3.2 that
cannot be freed with free(). The correct way to do this now is
MikMod_free() which extracts the original pointer from the buffer and
frees that.

Signed-off-by: Christoph Mende <mende.christoph@gmail.com>
2013-08-01 09:30:20 +02:00
Max Kellermann
363050f44c playlist_edit: fix "move" relative to current when there is no current song
Fixes Mantis #3770.
2013-08-01 09:28:03 +02:00
Michael Mair-Keimberger
dbe04c4207 configure.ac: detect system "ar" 2013-08-01 09:13:41 +02:00
tsufeki
d59a332ef9 commmand: fix URI argument in playlistadd 2013-08-01 08:42:22 +02:00
Max Kellermann
105b431e4c PcmBuffer: reset size in Clear()
Fix for Mantis #3806.

"PcmBuffer::Clear clears the buffer but does not reset the size. If
Get is called on the same PcmBuffer later on with a size that is the
same as (or less than) it was before the call to Clear, the "else"
branch is taken and the memory of buffer (at the address of nullptr)
is poisoned instead of the necessary allocation being performed. A
memset or memcpy on the returned pointer (nullptr) causes a
segmentation fault."
2013-08-01 08:33:53 +02:00
Max Kellermann
ba79f4c1f9 Tag: check bulk mode in Clear() 2013-07-31 09:02:07 +02:00
Max Kellermann
8b2dcf7018 decoder/ffmpeg: require ffmpeg/libav 0.8
Now that even Debian stable has picked up version 0.8, we can safely
make this a requirement, and remove a lot of old cruft.
2013-07-31 01:01:21 +02:00
Max Kellermann
44621f7326 output/winmm: adapt to PcmBuffer API changes 2013-07-31 00:57:52 +02:00
Max Kellermann
8ead8f7ea6 decoder/mpcdec: remove support for the "old" API
This old version has been obsolete for many years - time to remove it.
2013-07-31 00:43:21 +02:00
Max Kellermann
7f9402bd22 Tag: add method Clear()
Allow reusing Tag instances.
2013-07-31 00:35:05 +02:00
Max Kellermann
cbd38327e7 DecoderAPI: pass rvalue reference to decoder_tag()
Avoid duplicating the tag.
2013-07-31 00:34:22 +02:00
Max Kellermann
06f898cc12 tag: convert to C++ 2013-07-30 20:19:53 +02:00
Max Kellermann
6a9ab8bc0e tag: move enum tag_type to TagType.h 2013-07-30 20:10:24 +02:00
Max Kellermann
9a0061c511 encoder_api: convert to C++ 2013-07-30 09:04:05 +02:00
Max Kellermann
7a3aac1843 encoder/lame,twolame: convert to C++ 2013-07-30 08:52:47 +02:00
Max Kellermann
da1f4b3ede encoder/wave: convert to C++ 2013-07-30 08:48:53 +02:00
Max Kellermann
dac740ee17 encoder/null: convert to C++ 2013-07-30 08:43:19 +02:00
Max Kellermann
28030d7edb include cleanup 2013-07-30 08:39:21 +02:00
Max Kellermann
648196319f output_api: convert to C++ 2013-07-30 08:34:10 +02:00
Max Kellermann
c75cb67c44 pcm_buffer: convert to C++ 2013-07-30 08:31:02 +02:00
Max Kellermann
cd1bb2bafa Main: fix crash without state file
If no state file is configured, don't chek for state changes.
2013-07-30 08:31:02 +02:00
Max Kellermann
a9d2dc6144 pcm_resample: convert to C++ 2013-07-30 00:04:16 +02:00
Max Kellermann
46b9388bb0 PcmConvert: don't memset() in the constructor
This destroys data inside PcmDsd and other attributes.  It was once
necessary, but is not anymore.
2013-07-30 00:03:36 +02:00
Max Kellermann
a1a97d663e encoder/flac: convert to C++ 2013-07-29 08:04:34 +02:00
Max Kellermann
cac3c159bc pcm_dsd: convert to C++ 2013-07-29 07:56:40 +02:00
Max Kellermann
43166130b5 audio_check: convert to C++ 2013-07-29 07:50:08 +02:00
Max Kellermann
14f21378e3 tag_table: convert to C++ 2013-07-29 07:45:58 +02:00
Max Kellermann
bd42aeab46 XiphTags: convert to C++ 2013-07-29 07:42:50 +02:00
Max Kellermann
cde6a3a00c tag_handler: convert to C++ 2013-07-29 07:39:58 +02:00
Max Kellermann
96b763067e ape: convert to C++ 2013-07-29 07:39:36 +02:00
Max Kellermann
dd5ba062cc tag_id3: convert to C++ 2013-07-28 20:25:45 +02:00
Max Kellermann
ba161ec572 song: convert header to C++ 2013-07-28 13:25:12 +02:00
Max Kellermann
43f613d9be decoder_api: convert to C++ 2013-07-28 13:18:48 +02:00
Max Kellermann
2277d143fa decoder/fluidsynth: convert to C++ 2013-07-28 13:16:27 +02:00
Max Kellermann
6b6d9e64bd decoder/pcm: convert to C++ 2013-07-28 13:10:05 +02:00
Max Kellermann
f016a99f24 decoder/mpcdec: convert to C++ 2013-07-28 13:04:12 +02:00
Max Kellermann
2eed9d64ce decoder/modplug: convert to C++ 2013-07-28 13:03:04 +02:00
Max Kellermann
1688b6dda9 decoder/mikmod: convert to C++ 2013-07-28 13:03:04 +02:00
Max Kellermann
33aedc887a decoder/wildmidi: convert to C++ 2013-07-28 13:03:04 +02:00
Max Kellermann
258d0ea97e decoder/mpg123: convert to C++ 2013-07-28 13:03:04 +02:00
Max Kellermann
d3641766a5 decoder/sndfile: convert to C++ 2013-07-28 12:48:26 +02:00
Max Kellermann
b25d5c5d33 decoder/audiofile: convert to C++ 2013-07-28 12:48:26 +02:00
Max Kellermann
352d7f477e decoder/{dsf,dsdiff}: convert to C++ 2013-07-28 12:20:50 +02:00
Max Kellermann
1fcf35ad3b tag_rva2: convert to C++ 2013-07-26 12:52:51 +02:00
Max Kellermann
c8054e569a decoder/mad: convert to C++ 2013-07-26 11:59:17 +02:00
Max Kellermann
ef48eca9ca Merge branch 'master' of git://git.musicpd.org/dk/mpd 2013-06-24 16:17:46 +02:00
Matthias Larisch
906d2fbadf fix overwriting bitrate with signal type
I recently opened a bug: http://bugs.musicpd.org/view.php?id=3787

The main problem is that opus encoder config for signal overwrote
bitrate setting.
2013-06-24 16:08:25 +02:00
Matthias Drochner
2b579aeb4f NULL pointer vs bool "false" confusion
there are some places in the mpd-0.17.4 sources where a "false" is
used instead of a NULL pointer.
2013-06-24 16:00:58 +02:00
Denis Krjuchkov
e9e55b0812 text_input_stream: convert to class 2013-05-12 20:02:27 +06:00
Denis Krjuchkov
49a3845135 timer: convert to class 2013-05-12 19:03:42 +06:00
Denis Krjuchkov
21dac6c05d decoder/FLAC*: rename files and symbols to Flac* 2013-05-06 23:36:47 +06:00
Denis Krjuchkov
1d9b84a5af PlaylistFile: use DirectoryReader and file system API 2013-05-06 23:36:42 +06:00
Denis Krjuchkov
a688745bdc ClientFile: use Path and file system API, update usages accordingly
This commit also fixes incorrect passing of UTF-8 strings to client_allow_file
2013-05-06 23:36:36 +06:00
Denis Krjuchkov
459d824c50 ClientFile.cxx: include config.h 2013-05-06 23:36:24 +06:00
Denis Krjuchkov
96019f4a02 UpdateWalk, ExcludeList: use Path, file system API, DirectoryReader, log in UTF8 2013-05-06 23:34:48 +06:00
Denis Krjuchkov
896015bf53 DirectoryReader: rename Failed() to HasFailed() for consistency with TextFile 2013-05-05 13:34:12 +06:00
Denis Krjuchkov
df3e7a9248 .gitignore: always ignore any .exe files 2013-05-05 13:28:18 +06:00
Max Kellermann
b2d3d15e97 Main: move global variables to struct Instance
More preparations for multi-player support.
2013-04-17 23:52:58 +02:00
Max Kellermann
08dfd263ba GlobalEvents: include windows.h for DELETE macro workaround 2013-04-17 23:52:57 +02:00
Max Kellermann
abaabe92d6 decoder_buffer: convert to C++ 2013-04-17 22:45:10 +02:00
Max Kellermann
257b42b87f decoder/faad: convert to C++ 2013-04-17 22:33:59 +02:00
Max Kellermann
31bc94160a song_sort: convert to C++ 2013-04-17 22:25:57 +02:00
Max Kellermann
9e5d2c5bb7 encoder_list: convert to C++ 2013-04-17 22:22:37 +02:00
Max Kellermann
2df2a989af input/soup: plugin removed
This plugin is cumbersome to support, now that MPD is migrating away
from GLib and the GLib event loop.  It has no practical advantages
over the CURL plugin.  Soup requires the bloated GType library.
2013-04-17 21:46:16 +02:00
Max Kellermann
4a800b311f don't use g_thread_init() with GLib 2.32
Deprecated.
2013-04-17 01:54:14 +02:00
Max Kellermann
a4a13a3825 use g_thread_new() if GLib is recent enough
Fixes deprecation warnings.
2013-04-17 01:49:43 +02:00
Max Kellermann
a28df6123f OutputInternal: use Mutex instead of GMutex 2013-04-17 01:41:56 +02:00
Max Kellermann
c5c43c4541 thread/Cond: add method timed_wait() 2013-04-17 01:33:07 +02:00
Max Kellermann
0954f580fa output/oss,null: use new/delete 2013-04-17 01:21:33 +02:00
Max Kellermann
3a2254c91f output: convert to C++ 2013-04-17 01:12:05 +02:00
Max Kellermann
4aeec4bb60 output/solaris: convert to C++ 2013-04-17 01:08:35 +02:00
Max Kellermann
750b2ad6a8 output/openal: convert to C++ 2013-04-17 01:04:27 +02:00
Max Kellermann
86c276f538 output/ao: convert to C++ 2013-04-17 00:56:09 +02:00
Max Kellermann
166569200a output/shout: convert to C++ 2013-04-17 00:47:20 +02:00
Max Kellermann
e903d00968 output/ffado: remove broken plugin
This plugin has been in MPD for three years, and it has never worked.
Enough!
2013-04-17 00:44:02 +02:00
Max Kellermann
7d5d95ad53 configure.ac: fix hidden syntax error 2013-04-17 00:40:27 +02:00
Max Kellermann
cc6c452854 output/mvp: remove obsolete plugin
The hardware is obsolete, and the product does not exist anymore on
the Hauppauge web site.  Let's see if anybody complains about the
removal.
2013-04-17 00:37:30 +02:00
Max Kellermann
f492c78e2e output/jack: convert to C++ 2013-04-17 00:37:30 +02:00
Max Kellermann
6b83d08228 output/fifo: convert to C++ 2013-04-17 00:37:30 +02:00
Max Kellermann
dc415b761e output/pipe: convert to C++ 2013-04-17 00:37:30 +02:00
Max Kellermann
f1034eb657 output/recorder: convert to C++ 2013-04-17 00:37:30 +02:00
Max Kellermann
ac9ebe1439 scripts: delete obsolete scripts 2013-04-17 00:37:30 +02:00
Max Kellermann
7b5f7c041b MixerInternal: use Mutex instead of GMutex 2013-04-16 23:50:41 +02:00
Max Kellermann
8ce9b53093 mixer/software: use gcc_unused instead of G_GNUC_UNUSED 2013-04-16 23:50:41 +02:00
Max Kellermann
0b9e52bd5f configure.ac: fix libmpdclient variable name 2013-04-16 23:44:32 +02:00
Max Kellermann
5dd728d802 doc: move sticker_file to "optional parameters" 2013-04-16 23:19:44 +02:00
Florian Schlichting
ce7c97b6ba doc: mpd.conf.5 wrongly documents parameters as required
mpd.conf.5 lists follow_outside_symlinks and follow_inside_symlinks
under REQUIRED, yet also documents a default value for these options,
which only makes sense if they're not actually required.
2013-04-16 23:17:43 +02:00
Max Kellermann
9a4c049675 prepare 0.17.5 2013-04-16 23:17:38 +02:00
Max Kellermann
cb8449a66d MixerInternal: convert to class 2013-04-16 21:33:25 +02:00
Max Kellermann
621467717d mixer/winmm: convert to a class 2013-04-16 21:31:03 +02:00
Max Kellermann
506c716cf2 mixer/Software: convert to a class 2013-04-16 21:25:27 +02:00
Max Kellermann
9f625b0a0d mixer/Pulse: convert to a class 2013-04-16 21:18:54 +02:00
Max Kellermann
bc1b4131cb mixer/Oss: convert to a class 2013-04-16 21:11:14 +02:00
Max Kellermann
80ba3c5932 mixer/Alsa: convert to a class 2013-04-16 21:11:06 +02:00
Max Kellermann
e63420a8c2 output/Pulse: convert to C++ 2013-04-16 20:51:21 +02:00
Max Kellermann
e02d8ad8d2 output/roar: work around libroar's use of "new" 2013-04-16 20:04:11 +02:00
Max Kellermann
d300e6bf21 util/Manual: work around strict-aliasing warning 2013-04-11 00:01:08 +02:00
Max Kellermann
1729388634 pcm_export: convert to C++ 2013-04-09 01:31:05 +02:00
Max Kellermann
c654c7630a pcm_*: move to src/pcm/ 2013-04-09 01:24:52 +02:00
Max Kellermann
3f3b26fb0e utils: convert to C++ 2013-04-09 01:17:47 +02:00
Max Kellermann
0921180b90 string_util: convert to C++ 2013-04-09 01:08:20 +02:00
Max Kellermann
14df240f5b OpusReader: don't use strndup()
Eliminate the fallback strndup() and strnlen() implementations.
2013-04-09 01:03:44 +02:00
Max Kellermann
2090911363 cue_parser: convert to C++ 2013-04-09 00:38:03 +02:00
Max Kellermann
3cc7be0fa6 playlist/cue: add constructor/destructor 2013-04-09 00:34:48 +02:00
Max Kellermann
6728b8c1a3 decoder_plugin: convert to C++ 2013-04-09 00:20:49 +02:00
Max Kellermann
450c26c471 tokenizer: convert to C++ 2013-04-08 23:51:39 +02:00
Max Kellermann
7ec1121cc8 uri: convert to C++ 2013-04-08 23:45:31 +02:00
Max Kellermann
f84e288ad7 decoder/gme: fix rounding error
Cast to integer after multiplying with 1000.  Allows sub-second
seeking.
2013-04-08 23:45:21 +02:00
Max Kellermann
8e31366431 decoder/gme: convert to C++ 2013-04-08 23:32:53 +02:00
Max Kellermann
1bfa04f80e InputStream: use gcc.h attributes 2013-04-08 23:22:12 +02:00
Max Kellermann
98cbc0ea79 event/TimeoutMonitor: eliminate support for periodic events
No caller needs this.  Fixes use-after-free after returning from
Client::OnTimeout().
2013-04-08 23:14:07 +02:00
Max Kellermann
dca1115196 StateFile: schedule timer only after a change
Save the state file 2 minutes after the last change.  This reduces the
disruptions by an idle MPD, and MPD can be paged out permanently until
it is used.
2013-04-08 23:11:36 +02:00
Max Kellermann
96882175f1 StateFile: move code to RememberVersions(), IsModified() 2013-04-08 23:11:36 +02:00
Max Kellermann
484841fc9e StateFile: make AutoWrite() private 2013-04-08 23:11:35 +02:00
Max Kellermann
8052c76489 Idle: fix typo in API documentation 2013-04-08 23:11:35 +02:00
Max Kellermann
3477acee48 decoder/ffmpeg: suppress warning about unused variable
Only relevant for old ffmpeg versions.
2013-04-08 22:12:49 +02:00
Max Kellermann
2c4b998170 Merge tag 'release-0.17.4' 2013-04-08 22:11:42 +02:00
Max Kellermann
0a9c7ff6cf release 0.17.4 2013-04-08 22:00:43 +02:00
Max Kellermann
cd71038655 command: don't check audio_format if not playing
Fixes valgrind warning.
2013-04-08 22:00:35 +02:00
Max Kellermann
1894aed261 Makefile.am: enable "dist-xz" 2013-04-08 21:35:45 +02:00
Max Kellermann
f3832bcaa8 .gitignore: stricter matches 2013-04-08 21:35:34 +02:00
Max Kellermann
436335e9a3 player_control: don't emit IDLE_PLAYER before audio format is known
Eliminates one IDLE_PLAYER call in playlist_control, and add two new
ones to player_thread.  Fixes Mantis bug 3636.
2013-04-08 21:31:03 +02:00
Max Kellermann
a30eb194d5 command: don't print undefined audio_format
Check audio_format_defined().
2013-04-08 21:31:03 +02:00
Anton Khirnov
8becbb8b08 ffmpeg decoder plugin: do not allocate an AVFrame on stack.
AVFrame must be allocated with avcodec_alloc_frame().
2013-04-05 23:34:10 +02:00
Anton Khirnov
e0c2c77c2a ffmpeg decoder plugin: do not allocate an AVFrame on stack.
AVFrame must be allocated with avcodec_alloc_frame().
2013-04-05 23:30:47 +02:00
Max Kellermann
6f2e1c2415 GlobalEvents: use g_idle_add() instead of WakeFD()
Use the GMainLoop specific function to wake up the main loop.  This is
simpler and comes with very little overhead.
2013-02-27 20:41:17 +01:00
Max Kellermann
fc0ad8674b GlobalEvents: wake up only if the flags were empty
Don't bother checking for the parameter mask.  This doesn't matter.
The only thing that matters is if a wake-up is already pending.
2013-02-27 20:40:46 +01:00
Max Kellermann
19c67ab724 Idle, GlobalEvents: use std::atomic::exchange()
Less overhead than fetch_and() for what we do.
2013-02-27 20:35:44 +01:00
Oddegamra
a046b6e105 IcyMetaDataServer: increment iterator
Fixes segmentation fault.
2013-02-27 20:01:58 +01:00
Max Kellermann
8017301de5 Merge branch 'v0.17.x' 2013-02-27 20:00:14 +01:00
Florian Schlichting
46528783ef fix typos in upstream's mpd.conf.5 2013-02-27 19:50:05 +01:00
Hagen Fritsch
6f4bb6cd2c Add some comments to keep track of timer units. 2013-02-27 19:47:28 +01:00
Hagen Fritsch
2cf31e905b clock: fix usec-to-usec factor 2013-02-27 19:45:31 +01:00
Hagen Fritsch
28a60db5aa clock: add missing include 2013-02-27 19:42:35 +01:00
Max Kellermann
496f70fc0d mixer_plugin: convert to C++ 2013-02-22 20:51:23 +01:00
Max Kellermann
9ede4c5f3c {output,mixer}/winmm: convert to C++ 2013-02-22 20:29:03 +01:00
Max Kellermann
214a526945 Merge branch 'v0.17.x' 2013-02-19 09:24:11 +01:00
Jörg Thalheim
d5b756413a command: allow to omit END in ranges (START:END)
If END is omitted, mpd should use the highest possible value instead of raising an error.
This partially reverts 52e9cab1c1
2013-02-19 09:23:18 +01:00
Max Kellermann
af99176581 output/alsa: workaround for noise after manual song change
Workaround for driver bug observed on the Raspberry Pi, see code
comment for details.
2013-02-04 15:51:32 +01:00
Max Kellermann
57e825dfe7 output/alsa: pre-allocate the silence buffer 2013-02-04 15:30:31 +01:00
Max Kellermann
e06dd129dd output/alsa: move code to alsa_write_silence() 2013-02-04 14:30:16 +01:00
Max Kellermann
00baddcd9e SocketUtil: add separators to g_prefix_error() call 2013-02-04 14:26:03 +01:00
Max Kellermann
7e92820c50 output/alsa: default "device" is an empty string
Fixes nullptr dereference in std::string::operator=().  Also fixes a
memory leak by using config_get_block_string() instead of
config_dup_block_string().
2013-02-04 11:46:49 +01:00
Max Kellermann
5692e20fd5 event/ServerSocket: close only sockets that have been opened
Fixes assertion failure.
2013-02-04 11:44:36 +01:00
Max Kellermann
3b3c9334c8 decoder/Opus: replace non-static data member initializers
Would require gcc 4.7, and MPD attempts to be compatible with gcc 4.6.
2013-02-04 11:08:32 +01:00
Max Kellermann
96dc0a318a player_thread: implement missing "idle" events on output errors
When all outputs fail, MPD automatically pauses playback, but did not
emit the IDLE_PLAYER event.  Thus, clients were not woken up.  (Mantis
3665)
2013-02-04 10:15:34 +01:00
Uli Schlachter
a4223aac38 ServerSocket: Initialize length variable 2013-02-04 09:30:21 +01:00
Denis Krjuchkov
2bb751d9fa StateFile: use file system API, log in UTF-8 2013-02-02 20:52:04 +06:00
Denis Krjuchkov
3b620112ca SimpleDatabasePlugin: use file system API, log in UTF-8 2013-02-02 20:52:03 +06:00
Denis Krjuchkov
99526219b7 UpdateIO.cxx: use file system API, log in UTF-8 2013-02-02 20:52:02 +06:00
Denis Krjuchkov
d818b618af UpdateWalk.cxx: use FileExists 2013-02-02 20:51:36 +06:00
Denis Krjuchkov
c64700e7ae TextFile.hxx: use file system API 2013-02-02 20:23:27 +06:00
Denis Krjuchkov
5bd1917705 SongUpdate.cxx: use StatFile 2013-02-02 20:22:32 +06:00
Denis Krjuchkov
178c6c20cd PlaylistSave.cxx: use FOpen 2013-02-02 20:21:46 +06:00
Denis Krjuchkov
92d71cc7fa PlaylistFile.cxx: use file system API 2013-02-02 20:21:10 +06:00
Denis Krjuchkov
227eca7d28 ExcludeList.cxx: use FOpen 2013-02-02 20:20:24 +06:00
Denis Krjuchkov
9399b0ea52 ConfigFile.cxx: use FOpenMode 2013-02-02 20:19:25 +06:00
Denis Krjuchkov
17dca254a3 Path.hxx: add GetDirectoryName() method 2013-02-02 19:28:02 +06:00
Denis Krjuchkov
f6b50d2387 FileSystem.hxx: add FOpen modes for appending files 2013-02-02 19:20:10 +06:00
Max Kellermann
a9ce0218c1 FilterInternal: convert struct filter to a OO interface 2013-02-02 09:34:07 +01:00
Max Kellermann
7bb5a960fd output/null: convert to C++ 2013-02-02 09:30:29 +01:00
Max Kellermann
e6b04d1b50 filter/*: don't use GLib macros 2013-02-02 08:31:17 +01:00
Max Kellermann
12613356fc filter/Chain: use std::forward_list instead of GSList 2013-02-01 18:14:06 +01:00
Max Kellermann
3894450b10 filter: convert to C++ 2013-02-01 17:47:09 +01:00
Max Kellermann
ec07f6ec83 PcmMix: merge duplicate code with templates 2013-02-01 17:45:17 +01:00
Max Kellermann
a7a10d03c9 test/test_pcm: add unit test for pcm_mix() 2013-02-01 15:52:03 +01:00
Max Kellermann
ef99d6ce3d PcmUtils: remove pcm_range(), use PcmClamp() instead 2013-02-01 14:10:27 +01:00
Max Kellermann
0ac06d77f1 PcmUtils: make PcmClamp() 64-bit-safe, add missing cast 2013-02-01 14:04:40 +01:00
Max Kellermann
469e233428 PcmUtils: remove unused clamp functions 2013-02-01 14:02:20 +01:00
Max Kellermann
86a0f9cf9b PcmFormat: merge duplicate code with a template 2013-02-01 13:47:29 +01:00
Max Kellermann
e6a91d291d PcmChannels: merge duplicate code with a template 2013-02-01 13:47:24 +01:00
Max Kellermann
bf35972714 ConfigTemplates: fix typo in id3v1_encoding 2013-02-01 13:47:12 +01:00
Max Kellermann
e0c645a270 test/test_pcm: add unit tests for the PcmFormat library 2013-02-01 00:32:05 +01:00
Max Kellermann
e42734c3f3 test/test_pcm: merge source buffer generator 2013-01-31 22:58:27 +01:00
Max Kellermann
eab78ab99c PcmDither: use constexpr 2013-01-31 22:55:00 +01:00
Max Kellermann
f2491c88c8 PcmDither: convert struct to a class 2013-01-31 22:54:10 +01:00
Max Kellermann
1b175025fe pcm_*: convert to C++ 2013-01-31 21:11:06 +01:00
Max Kellermann
ccdf7184be gcc.h: add "restrict" macro for C++ 2013-01-31 21:11:06 +01:00
Max Kellermann
7764136211 mixer/software, filter/volume: convert to C++ 2013-01-31 21:11:06 +01:00
Max Kellermann
0307801d51 test/test_pcm: convert to C++ 2013-01-31 21:11:06 +01:00
Max Kellermann
72cf8dd8a0 ZeroconfBonjour: fix OnSocketReady() return type 2013-01-31 21:11:06 +01:00
Max Kellermann
3c2b464dfa filter/convert: remove unused attribute 2013-01-31 00:31:24 +01:00
Max Kellermann
361404fd59 pcm_convert: convert to C++ 2013-01-31 00:26:55 +01:00
Max Kellermann
762c91b7f1 util/Manual: new template class 2013-01-30 23:48:34 +01:00
Max Kellermann
f2a8d4d289 filter/convert: convert to C++ 2013-01-30 23:28:13 +01:00
Max Kellermann
9ee52d85d7 filter/autoconvert: include cleanup 2013-01-30 23:19:11 +01:00
Max Kellermann
5ed9f02c4d TagPool, ...: include cleanup 2013-01-30 22:53:12 +01:00
Max Kellermann
378ebad1c8 ConfigData: use simple linked list instead of GSList 2013-01-30 22:39:24 +01:00
Max Kellermann
e44e0fab9f ConfigData: forbid copying a config_param object 2013-01-30 22:39:24 +01:00
Max Kellermann
c434077728 FilterConfig: add missing glib.h include 2013-01-30 22:39:24 +01:00
Max Kellermann
6e47e79790 ConfigData: move functions into the class 2013-01-30 22:25:17 +01:00
Max Kellermann
d9ea3082fb ConfigData: add constructors/destructors 2013-01-30 22:20:14 +01:00
Max Kellermann
2d63c26936 ConfigData: use std::string in block_param 2013-01-30 22:20:14 +01:00
Max Kellermann
3cdd01aa1b ConfigData: use std::vector for the block_param list 2013-01-30 22:20:13 +01:00
Max Kellermann
d25195447a ConfigData: use new/delete instead of GLib 2013-01-30 22:20:13 +01:00
Max Kellermann
aa8ab2fc89 test/test_vorbis_encoder: convert to C++ 2013-01-30 22:19:24 +01:00
Max Kellermann
d664baff26 audio_{parser,config}: convert to C++ 2013-01-30 21:47:12 +01:00
Max Kellermann
3275d4c6fa conf.h: move the GQuark to ConfigQuark.hxx 2013-01-30 21:43:16 +01:00
Max Kellermann
cd0d003197 filter/chain, encoder: GLib include cleanup 2013-01-30 21:42:50 +01:00
Max Kellermann
cfeeb7af2e test/run_encoder, ...: convert to C++ 2013-01-30 21:39:43 +01:00
Max Kellermann
ac887d3afb ConfigFile: simplify error cleanup 2013-01-30 21:39:43 +01:00
Max Kellermann
e294ccae24 ConfigFile: move code to ConfigGlobal.cxx 2013-01-30 21:39:43 +01:00
Max Kellermann
72070f292b ConfigFile: add struct ConfigData 2013-01-30 21:36:11 +01:00
Max Kellermann
823c618d24 {encoder,output}_api.h: allow compiling as C++ 2013-01-30 21:36:09 +01:00
Max Kellermann
51cb6a0a44 conf: move struct definitions to ConfigData.hxx 2013-01-30 21:36:07 +01:00
Max Kellermann
a1b1ec3d11 Makefile.am: move source files to libconf.a 2013-01-30 21:36:06 +01:00
Max Kellermann
595b6a4f6c ConfigFile: add enum ConfigOption
Look up top-level config options by enum (= integer), not by name
string.
2013-01-30 21:36:04 +01:00
Max Kellermann
daa4647712 ConfigOption: rename to ConfigTemplate 2013-01-30 19:05:33 +01:00
Max Kellermann
c67668d6dd Makefile.am: fix test/read_mixer rule 2013-01-30 19:05:04 +01:00
Max Kellermann
9cfaa9c7b0 ConfigFile: move code to ConfigOptions.cxx 2013-01-30 17:45:19 +01:00
Max Kellermann
c5ea586882 ConfigFile: split config_entry
The new struct ConfigOption is the compile-time description, and the
global array "config_params" contains the actual values.
2013-01-30 17:35:33 +01:00
Max Kellermann
f2a3a37dff filter_config: convert to C++ 2013-01-30 17:22:44 +01:00
Max Kellermann
01dd540d7e decoder_list: convert to C++ 2013-01-30 17:18:48 +01:00
Max Kellermann
8142080633 InotifyUpdate: use std::list instead of GList
Let STL manage the WatchDirectory allocations.
2013-01-30 16:44:55 +01:00
Max Kellermann
9920a3e8fc InotifyUpdate: move code to destructor 2013-01-30 16:44:54 +01:00
Max Kellermann
f7d8e6c40c InotifyUpdate: allocate the root dynamically 2013-01-30 16:41:17 +01:00
Max Kellermann
4ecf09f9e6 InotifyUpdate: use new/delete instead of GLib slices 2013-01-30 16:37:49 +01:00
Max Kellermann
47a8369d79 InotifyUpdate: rename struct watch_directory 2013-01-30 16:36:58 +01:00
Max Kellermann
6805fa2fa0 InotifyUpdate: use std::map instead of GTree 2013-01-30 16:27:55 +01:00
Max Kellermann
4d6b9611ae UpdateContainer: remove duplicate unlock call 2013-01-30 16:27:38 +01:00
Max Kellermann
16afdfd874 ArchivePlugin: move instance methods to class ArchiveFile 2013-01-30 15:30:19 +01:00
Max Kellermann
701fff03d2 archive/bzip2: create file only after stream has been opened
Simplify error handling.
2013-01-30 15:27:23 +01:00
Max Kellermann
8e0575ca9b archive/zzip: fix memory leak 2013-01-30 15:25:29 +01:00
Max Kellermann
5e8f51a963 output/httpd: use the BufferedSocket class for HttpdClient 2013-01-30 15:08:09 +01:00
Max Kellermann
be3d2188d6 event/SocketMonitor: wake up the event loop after flag change 2013-01-30 15:08:09 +01:00
Max Kellermann
18e429a87e event/Loop: add method WakeUp() 2013-01-30 15:08:09 +01:00
Max Kellermann
3576a8fd9f Main: delete the EventLoop after everything else
Fixes crash when another object attempts to access the EventLoop
during destruction.
2013-01-30 15:08:09 +01:00
Max Kellermann
f260cd031c input/Rewind: remove bogus assertion 2013-01-30 15:05:54 +01:00
Max Kellermann
18c4b536f2 event/ServerSocket: add method GetEventLoop() 2013-01-30 14:23:01 +01:00
Max Kellermann
fa51db449f ServerSocket: replace callback with virtual method 2013-01-30 14:16:04 +01:00
Max Kellermann
cb9a05ac77 output/httpd: safer cast, consider offset 2013-01-30 14:14:42 +01:00
Max Kellermann
f1f22019f5 output/httpd: forward-declare class HttpdClient 2013-01-30 13:42:16 +01:00
Max Kellermann
6d79a1cdfc output/httpd: add constructor, destructor, Configure() 2013-01-30 13:41:27 +01:00
Max Kellermann
ad5eb2f8d6 ServerSocket: expose the class
Eliminate the C wrappers.
2013-01-30 13:40:56 +01:00
Max Kellermann
39d56d6b65 ServerSocket: move to libevent.a 2013-01-30 13:39:12 +01:00
Max Kellermann
a291415326 event/BufferedSocket: move output buffer to FullyBufferedSocket
BufferedSocket has just an input buffer, and FullyBufferedSocket adds
the output buffer.
2013-01-30 11:03:44 +01:00
Max Kellermann
4ad7456428 event/SocketMonitor: OnSocketReady() returns bool 2013-01-30 11:03:44 +01:00
Max Kellermann
73f36858bb event/SocketMonitor: add methods Read(), Write() 2013-01-30 10:39:17 +01:00
Max Kellermann
fe3f0332f7 page: convert to C++ 2013-01-30 09:18:52 +01:00
Max Kellermann
718fd97612 icy_server: convert to C++ 2013-01-30 09:17:03 +01:00
Max Kellermann
f8ff45b212 icy_server: pass pointer to _metadata_page()
Don't use va_list.
2013-01-30 09:13:46 +01:00
Max Kellermann
f5c0b0d316 ArchiveFile: convert to a class 2013-01-29 23:26:51 +01:00
Max Kellermann
ba51045d9e refcount: convert to C++ 2013-01-29 23:20:19 +01:00
Max Kellermann
fa34dd7bd3 test/visit_archive: new debug program 2013-01-29 22:54:56 +01:00
Max Kellermann
9f0fb8f6a8 ArchivePlugin: replace scan_reset(), scan_next() with visit()
Add the interface ArchiveVisitor.
2013-01-29 21:21:07 +01:00
Max Kellermann
a42f9fd4e2 ArchivePlugin: scan_next() returns const string 2013-01-29 21:11:04 +01:00
Max Kellermann
e66005563e playlist/despotify: various code simplifications 2013-01-29 20:36:28 +01:00
Max Kellermann
8cad20585d playlist/memory: use std::forward_list instead of GSList 2013-01-29 20:32:54 +01:00
Max Kellermann
a8b75dc4df playlist/{asx,rss,soundcloud,xspf}: merge code to MemoryPlaylistProvider 2013-01-29 18:56:35 +01:00
Max Kellermann
e4455962c6 ClientSubscribe: remove obsolete typedef 2013-01-29 18:37:40 +01:00
Max Kellermann
20f85745e7 require GLib 2.24 2013-01-29 18:33:37 +01:00
Max Kellermann
feb8d5b82f ConfigFile, CommandLine: use the Path class 2013-01-29 18:09:39 +01:00
Max Kellermann
eb8922f346 test/{read_conf,run_filter}: convert to C++ 2013-01-29 17:23:58 +01:00
Max Kellermann
84eb95466b output/osx: convert to C++ 2013-01-29 16:59:21 +01:00
Max Kellermann
3dd8beb380 decoder/faad: use the newer NeAAC* API
Drop support for the old faacDec* API.
2013-01-29 16:17:15 +01:00
Max Kellermann
ae77406b8e faad.m4: clear FAAD_LIBS if faad got auto-disabled
Fixes build errors on systems without libfaad, when --disable-aac was
not specified.
2013-01-29 15:52:43 +01:00
Max Kellermann
2d16069211 faad.m4: don't add -I. to temporary CFLAGS 2013-01-29 15:51:31 +01:00
Max Kellermann
d18314fa05 faad.m4: remove faad --with-* options
Some of these are not implemented properly and never worked.  And the
others are not useful; you can easily set environment variables
instead.
2013-01-29 15:40:44 +01:00
Max Kellermann
26a9ce7b29 output/{alsa,oss}: convert to C++ 2013-01-29 14:32:32 +01:00
Max Kellermann
76417d4446 InputStream: use std::string 2013-01-28 23:41:45 +01:00
Max Kellermann
cffc78ad6a InputStream: store references instead of pointers 2013-01-28 23:35:01 +01:00
Max Kellermann
dcf55c7e32 InputStream: add constructor/destructor
Eliminate input_stream_init() and input_stream_deinit().
2013-01-28 23:29:43 +01:00
Max Kellermann
e565cd4404 input/despotify: add constructor/destructor 2013-01-28 23:13:19 +01:00
Max Kellermann
5934ccbb74 input/despotify: rename class 2013-01-28 23:12:10 +01:00
Max Kellermann
e39969a0d0 input/iso9660: add constructor/destructor 2013-01-28 22:54:07 +01:00
Max Kellermann
d68185aa28 input/iso9660: rename the classes 2013-01-28 22:52:40 +01:00
Max Kellermann
4cab151ed2 input/zzip: add constructor/destructor 2013-01-28 22:48:04 +01:00
Max Kellermann
8ac9b77e5c input/zzip: rename the classes 2013-01-28 22:43:59 +01:00
Max Kellermann
1b9da5d978 input/bzip2: add constructor/destructor 2013-01-28 22:39:09 +01:00
Max Kellermann
ab2b7358cb archive/bzip2: rename the classes 2013-01-28 22:17:40 +01:00
Max Kellermann
8ceea85813 DatabaseLock, input/bzip2: remove obsolete Glib/gcc workaround 2013-01-28 22:17:40 +01:00
Max Kellermann
d0a812d2df input/Soup: move code into the class 2013-01-28 22:00:24 +01:00
Max Kellermann
3dad2e1c0f input/soup: rename the class 2013-01-28 21:59:40 +01:00
Max Kellermann
70e4399334 input/ffmpeg: add constructor/destructor 2013-01-28 21:46:38 +01:00
Max Kellermann
00f8c2d46f input/ffmpeg: rename the class 2013-01-28 21:45:44 +01:00
Max Kellermann
0dd4b52b63 decoder/ffmpeg: require ffmpeg/libav 0.7.6
This is the version present in Ubuntu Oneiric, the oldest distribution
with gcc 4.6.  Debian Squeeze is off target, because it has gcc 4.4,
which is unable to compile MPD anyway.

This commit drops all API compatibility hacks for older versions.
2013-01-28 21:32:14 +01:00
Max Kellermann
88c17926e4 decoder/mp4ff: delete obsolete plugin
The underlying library has been obsolete for many years.
2013-01-28 21:32:14 +01:00
Max Kellermann
541192c941 db/Proxy: explicitly request first element of array
Works around gcc 4.6 bug.
2013-01-28 21:32:14 +01:00
Max Kellermann
2e9f054ec0 audio_config: include cleanup 2013-01-28 20:30:47 +01:00
Max Kellermann
2aa34882b7 output/httpd: move functions into the HttpdOutput class 2013-01-27 23:23:46 +01:00
Max Kellermann
27f8ef2f33 output/httpd: rename struct httpd_output 2013-01-27 23:21:39 +01:00
Max Kellermann
2cbe21c791 ZeroconfAvahi: pass GMainContext to avahi_glib_poll_new() 2013-01-27 22:53:21 +01:00
Max Kellermann
0988056471 ZeroconfBonjour: use SocketMonitor instead of GIOChannel 2013-01-27 22:38:14 +01:00
Max Kellermann
95c3f57b30 zeroconf: convert to C++ 2013-01-27 22:38:14 +01:00
Max Kellermann
068f191c0d event/SocketMonitor: add method Steal() 2013-01-27 22:38:14 +01:00
Max Kellermann
6bf6c9215b Makefile.cxx: fix test/run_input.cxx path 2013-01-27 22:17:47 +01:00
Max Kellermann
a65afa8090 PlayerControl: work around std::nanf() not being available on MacPorts 2013-01-27 21:58:35 +01:00
Max Kellermann
8155784990 string_util: add fallback for strnlen()
Usually, when strndup() is not available, strndup() isn't either,
because both are POSIX 2008.
2013-01-27 21:43:27 +01:00
Max Kellermann
44725e485d configure.ac: disable libwrap if not compatible with C++
The libwrap version on Mac OS X is broken, it will not work with C++
due to broken function prototypes.
2013-01-27 21:43:04 +01:00
Denis Krjuchkov
e98e2a0b07 Path::FromUTF8() returns nulled instance on error, add error handling where required 2013-01-28 00:13:46 +06:00
Denis Krjuchkov
943064bb51 Path: convert remaining funcs to methods, keep fs_charset as std::string 2013-01-28 00:13:46 +06:00
Denis Krjuchkov
7149a8ae4f Path: merge utf8_to_fs_charset() into Path::FromUTF8() 2013-01-28 00:13:45 +06:00
Denis Krjuchkov
3c7cf94643 Path: convert fs_charset_to_utf8() to static method Path::ToUTF8() 2013-01-28 00:13:45 +06:00
Denis Krjuchkov
3bd35d1883 Path: introduce MPD_PATH_MAX_UTF8 2013-01-28 00:13:45 +06:00
Max Kellermann
6f3d70b5e2 DecoderControl, InputStream: use Mutex/Cond instead of GMutex/GCond 2013-01-27 18:39:32 +01:00
Max Kellermann
257a0dee75 playlist/*: convert to C++ 2013-01-27 17:38:09 +01:00
Denis Krjuchkov
e995cd928c Path: define MPD_PATH_MAX to 260 on Windows 2013-01-26 11:18:12 +06:00
Denis Krjuchkov
292d7c3fdf Path: ToUTF() returns std::string 2013-01-26 11:16:12 +06:00
Max Kellermann
0273cd44b0 input_stream: forward-declare the struct
Hide the definition from C code, to prepare the transition to C++.
2013-01-26 01:24:01 +01:00
Max Kellermann
3203a7dd8c tag_file: convert to C++ 2013-01-26 01:23:02 +01:00
Max Kellermann
86b0adc82c playlist/*: convert to C++ 2013-01-26 01:17:43 +01:00
Max Kellermann
ba49f20f68 decoder/ffmpeg: convert to C++ 2013-01-26 01:17:43 +01:00
Denis Krjuchkov
a3ee26da64 Mapper: improve usage of Path class 2013-01-26 01:14:13 +01:00
Max Kellermann
a9b62a2ece PlayerControl: add second Cond object
This fixes a deadlock bug introduced by 18076ac9.  After all, the
second Cond was necessary.

The problem: two threads can wait for a signal at the same time.  The
player thread waits for the output thread to finish playback.  The
main thread waits for the player thread to complete a command.  The
output thread finishes playback, and sends a signal, which
unfortunately does not wake up the player thread, but the main
thread.  The main thread sees that the command is still not finished,
and waits again.  The signal is lost forever, and MPD is deadlocked.
2013-01-25 23:53:43 +01:00
Max Kellermann
49567f1f3e input_{internal,plugin}: convert to C++ 2013-01-25 22:43:01 +01:00
Max Kellermann
94fffb332b archive/*: convert to C++ 2013-01-24 19:18:58 +01:00
Max Kellermann
dc2e64c92b DecoderControl: fix typo in assertion check 2013-01-23 18:02:40 +01:00
Denis Krjuchkov
06fb7c671b Makefile.am: introduce libfs 2013-01-22 01:31:29 +06:00
Denis Krjuchkov
ef93cdf4a8 Path: move to fs subdirectory 2013-01-22 01:24:53 +06:00
Denis Krjuchkov
4ad90e2d52 FileSystem: extract DirectoryReader, improve the rest
- DirectoryReader is extracted to separate header
- FileSystem.cxx/FileSystem.hxx/DirectoryReader.hxx moved to fs/ subdir
- Functions return true on success, instead of 0 (where applicable)
- ReadLink return result instead of out parameter
- UnlinkFile is renamed to RemoveFile
- CheckExists/CheckIsRegular/CheckIsDirectory are renamed
  to PathExists/FileExists/DirectoryExists
2013-01-22 01:05:30 +06:00
Max Kellermann
7c0e4dfb56 input/archive: fix memory leak in error handler 2013-01-21 19:08:35 +01:00
Max Kellermann
9ec069104f input,playlist/despotify: convert to C++ 2013-01-21 19:01:10 +01:00
Max Kellermann
7d21d60dba despotify_utils: fix indent 2013-01-21 19:00:50 +01:00
Max Kellermann
ed8562c300 despotify_utils: include cleanup 2013-01-21 19:00:01 +01:00
Max Kellermann
22ec1c3498 despotify_utils: add missing copyright header 2013-01-21 18:59:37 +01:00
Max Kellermann
9cc90b1fbe input/cdio_paranoia: convert to C++ 2013-01-21 17:58:30 +01:00
Max Kellermann
0c9f22507f input/ffmpeg: convert to C++ 2013-01-21 17:50:43 +01:00
Max Kellermann
9c870e4276 input/rewind: convert to C++ 2013-01-21 17:36:19 +01:00
Max Kellermann
5cffe693b0 input/file,mms: convert to C++ 2013-01-21 10:52:40 +01:00
Max Kellermann
e01615fd1e input_internal.h: add extern "C" 2013-01-21 10:52:19 +01:00
Max Kellermann
c1daa857a5 test/run_tcp_connect: delete obsolete source file 2013-01-21 10:47:38 +01:00
Max Kellermann
3928c4e9ae UpdateRemove: Mutex/Cond instead of GMutex/GCond 2013-01-21 10:42:47 +01:00
Max Kellermann
32799fef5c DecoderControl: move functions into the class 2013-01-21 10:13:29 +01:00
Max Kellermann
e1b03b4a71 PlayerControl: move functions into the class 2013-01-20 17:48:23 +01:00
Denis Krjuchkov
e6ed592b8a FileSystem: new library for Path-friendly file system routines 2013-01-20 19:08:36 +06:00
Denis Krjuchkov
6f4560184c dummy.cxx: remove unused file
This file was used previously to force C++ linkage.
It's no longer required because most of the code is C++ anyway.
2013-01-19 12:45:50 +06:00
Max Kellermann
e5039c478a Path: new class "Path" wraps filesystem path strings 2013-01-18 15:34:01 +01:00
Max Kellermann
8901514506 Playlist, Song: clarify parameter encoding 2013-01-18 15:34:01 +01:00
Max Kellermann
21fe376d1d path: convert to C++ 2013-01-17 00:43:27 +01:00
Max Kellermann
e22ef6c481 output/roar: convert to C++ 2013-01-16 23:29:56 +01:00
Max Kellermann
2bb01093c0 Idle: don't wake up event loop on duplicate event 2013-01-16 23:27:17 +01:00
Max Kellermann
36c814d26e Idle: use std::atomic instead of GMutex 2013-01-16 23:23:47 +01:00
Max Kellermann
d769b74d61 Main: fix comment typo 2013-01-16 23:23:47 +01:00
Max Kellermann
601495fa0f ClientList: convert to a class 2013-01-16 23:00:13 +01:00
Max Kellermann
1998633739 ClientGlobal: move client_close_all() to ClientList.cxx 2013-01-16 22:56:52 +01:00
Max Kellermann
0194217f9d Revert "ClientList: allow deleting clients in client_list_foreach() callback"
This reverts commit f56c6a18c1.  This
fix is not necessary anymore because clients are now being deleted by
the timer callback.
2013-01-16 22:49:51 +01:00
Max Kellermann
b0bbb8b693 Client: use TimeoutMonitor to track connection timeout
Don't use a global loop over the whole client list.
2013-01-16 21:51:08 +01:00
Max Kellermann
cab84af72e Client: move "idle" functions into the class 2013-01-16 21:46:13 +01:00
Max Kellermann
74500eacca Merge branch 'v0.17.x' 2013-01-16 20:05:26 +01:00
Brice Jaglin
1105e61f29 decoder/ffmpeg: support float planar audio 2013-01-16 19:54:54 +01:00
Max Kellermann
b7cf279d6d zeroconf-avahi: eliminate "goto" 2013-01-16 00:23:00 +01:00
Max Kellermann
c614e550d9 valgrind.suppressions: more GLib suppressions 2013-01-15 23:44:21 +01:00
Max Kellermann
452a30d7af input/Curl: break loop when remaining length becomes 0
Fixes assertion failure (regression).
2013-01-15 23:39:32 +01:00
Max Kellermann
49e79620fd PlayerControl: initialise attribute "border_pause" 2013-01-15 23:21:14 +01:00
Max Kellermann
ae5a721df9 Playlist: initialise attribute "playing" 2013-01-15 23:09:18 +01:00
Max Kellermann
0dd5f2915a ServerSocket: use the SocketMonitor class 2013-01-15 22:56:06 +01:00
Max Kellermann
a0ebd444ad event/SocketMonitor: add method Open()
Allow creating a closed SocketMonitor instance.
2013-01-15 22:56:06 +01:00
Max Kellermann
0c6072c4e4 ServerSocket: move more code to methods 2013-01-15 22:53:14 +01:00
Max Kellermann
8917264110 ServerSocket, SocketUtil: use the SocketError library
Use WinSock errors on Windows.
2013-01-15 22:42:15 +01:00
Max Kellermann
e90d606f0a socket_util: convert to C++ 2013-01-15 22:41:56 +01:00
Max Kellermann
5bb2d64ddb SocketError: merge duplicate FormatMessage() calls
Make a class that contains the formatting code and the buffer.
2013-01-15 22:41:56 +01:00
Max Kellermann
bc66dc45e6 server_socket: convert to C++ 2013-01-15 21:42:55 +01:00
Max Kellermann
7087935656 output/httpd: convert to C++ 2013-01-15 20:20:51 +01:00
Max Kellermann
5822daa63d output_internal, ...: add extern "C" 2013-01-15 20:20:51 +01:00
Max Kellermann
4808c7ef39 encoder/{Vorbis,Opus}: use new/delete 2013-01-15 20:20:51 +01:00
Max Kellermann
7071126770 InotifySource: use the SocketMonitor class 2013-01-15 18:18:34 +01:00
Max Kellermann
2101daef5a mixer/Alsa: use MultiSocketMonitor 2013-01-15 18:18:00 +01:00
Max Kellermann
083065f433 input/Curl: move code to class MultiSocketMonitor 2013-01-15 18:16:55 +01:00
Max Kellermann
4cfc4a5a94 input/Curl: simpler GPollFD initialisation
Using initializer list.
2013-01-15 18:16:38 +01:00
Max Kellermann
1c7ee737e6 input/Curl: don't remove/add modified GPollFD
Not necessary, GLib will pick up the updated GPollFD automatically.
2013-01-15 18:16:15 +01:00
Max Kellermann
39439b80f5 Client: rebase on the new BufferedSocket class 2013-01-15 12:15:33 +01:00
Max Kellermann
396480cf94 event/SocketMonitor: wrapper class for GSource + GPollFD 2013-01-15 11:00:48 +01:00
Max Kellermann
3e03527930 Client: move output buffer code to new class PeakBuffer 2013-01-15 10:59:28 +01:00
Max Kellermann
4fa724461e util/fifo_buffer: add method _init() 2013-01-15 10:59:28 +01:00
Max Kellermann
1e2018ce83 Client: move connection functions into the class 2013-01-15 10:59:28 +01:00
Max Kellermann
3fcf17cb79 SignalHandlers: emit GlobalEvents::SHUTDOWN
.. instead of calling g_main_loop_quit(), which may dead-lock.
2013-01-15 10:59:28 +01:00
Max Kellermann
f9fc3a42cc fifo_buffer: move to util/ 2013-01-15 01:02:13 +01:00
Max Kellermann
76bc28ab1e fifo_buffer: add extern "C" 2013-01-15 01:01:25 +01:00
Max Kellermann
f47f86ef02 socket_error: new library for errno / WSAGetLastError() 2013-01-15 00:53:12 +01:00
Max Kellermann
31268ffa24 io_error: add function new_error_errno() 2013-01-15 00:53:12 +01:00
Max Kellermann
0634be9724 Client*: include check.h / config.h 2013-01-14 23:50:01 +01:00
Dark Raven
f56c6a18c1 ClientList: allow deleting clients in client_list_foreach() callback 2013-01-14 11:24:54 +01:00
Max Kellermann
aa4c506fcd Revert "ClientList.cxx: copy client list before iterating"
This reverts commit f53dadcc6d, to
prepare for a better solution.
2013-01-14 11:24:29 +01:00
Max Kellermann
d3a479b7fa event/TimeoutMonitor: wrapper for g_timeout_source_new() 2013-01-14 11:12:28 +01:00
Max Kellermann
92fb0e829a StateFile: convert to a class 2013-01-14 11:00:22 +01:00
Max Kellermann
43a9928537 gcc.h: add C++11 "final" fallback macro 2013-01-14 10:56:42 +01:00
Max Kellermann
c8b408beae InotifyQueue: convert to a class 2013-01-14 10:13:28 +01:00
Max Kellermann
8e3982dd42 InotifySource: convert to a class 2013-01-14 10:08:26 +01:00
Max Kellermann
e83f805b8f Main, IOThread: move GMainLoop setup code to class EventLoop 2013-01-14 09:15:49 +01:00
Max Kellermann
be98afe34d IOThread: use gcc.h 2013-01-14 09:15:49 +01:00
Denis Krjuchkov
f53dadcc6d ClientList.cxx: copy client list before iterating
It seems that it is not safe to remove the item from std::list
while it's being iterated somewhere else.

This is a very simple quick fix to make things work
until some better solution is implemented.
2013-01-13 15:36:25 +06:00
Denis Krjuchkov
90ab65f8c7 WakeFD.cxx: use two sockets instead of pipe on Win32
Pipes aren't really pollable on Windows.
GLib emulates polling on pipes using separate reader/writer threads.
This adds significant overhead and keeps a strong dependency on GLib.

socketpair() function is absent on Windows as well.
We implement it here in a loose way.
2013-01-13 15:30:53 +06:00
Denis Krjuchkov
abb0fcb203 Win32Main.cxx: more clean shutdown
This change fixes two issues:

1) console_handler is called from a separate thread.
   Thread-safe primitive is required for correct operation.

2) If console_handler returns TRUE our process is immediately terminated.
   We use Sleep() to give main thread an opportunity to shutdown correctly.
2013-01-13 15:20:32 +06:00
Denis Krjuchkov
eef4f33a29 configure.ac: use correct variable for checking libmpdclient presence 2013-01-11 16:47:56 +06:00
Max Kellermann
0226440a2d thread/{Mutex,Cond}: new backend for WIN32
Use CRITICAL_SECTION and CONDITION_VARIABLE.  This requires Windows
Vista or newer.  It fixes problems with GLib threading objects that
were implicitly created by static constructors before g_thread_init().
2013-01-11 11:11:07 +01:00
Max Kellermann
9d770d6084 GlobalEvents: #undef DELETE on Windows
Work around a build failure due to windows.h macro.
2013-01-11 11:10:46 +01:00
Max Kellermann
7f0297dc44 configure.ac: require Windows Vista or newer
We're going to use Vista features soon.  Sorry for those poor people
still on XP (or Windows, anyway).
2013-01-11 11:09:27 +01:00
Max Kellermann
49f3855407 configure.ac: enable WIN32_LEAN_AND_MEAN on Windows 2013-01-11 11:06:16 +01:00
Denis Krjuchkov
905d493fd7 .gitignore: add src/win/mpd_win32_rc.rc
This file is generated during configuration and should be ignored.
2013-01-11 15:30:59 +06:00
Denis Krjuchkov
5def2a09bd mpdconf.example: example improvements
- Add mandatory "name" setting for winmm/openal examples.

- Fix the language in openal sample (a -> an)
2013-01-11 15:28:21 +06:00
Denis Krjuchkov
a98aa66620 string_util.c: provide fallback strndup() implementation
This patch also adds extern "C" { } wrapper around string_util.h
to allow its usage in C++ code
2013-01-11 13:51:39 +06:00
Max Kellermann
631a268996 input/curl: use std::list instead of GQueue 2013-01-10 23:00:23 +01:00
Max Kellermann
85074f5ac6 icy_metadata: convert to C++ 2013-01-10 22:33:16 +01:00
Max Kellermann
12a8ed39d4 input/Curl: add constructor to input_curl class 2013-01-10 22:25:57 +01:00
Max Kellermann
b9ac5e9e76 input/Curl: remove unused source/source_id attributes 2013-01-10 22:25:33 +01:00
Max Kellermann
2758a734a2 input/Curl: remove redundant attribute "url"
Use the "url" attribute from the base class instead.
2013-01-10 22:21:30 +01:00
Max Kellermann
01f3131c81 input/Curl: use std::forward_list instead of GSList 2013-01-10 20:52:58 +01:00
Max Kellermann
2ca9236864 input/Curl: remove unused attribute "fds" 2013-01-10 20:52:44 +01:00
Max Kellermann
3bb711837e input/Curl: require libcurl 7.18 2013-01-10 20:46:47 +01:00
Max Kellermann
ed8798e82f output/shout: refactor check_block_param() to a function
Don't use macro magic, don't dereference the block_param.
2013-01-10 18:46:33 +01:00
Max Kellermann
38474961fd Log, ...: include cleanup 2013-01-10 18:34:40 +01:00
Max Kellermann
3dd38e7b7f decoder/wavpack: convert to C++ 2013-01-10 18:18:14 +01:00
Max Kellermann
3711a97657 decoder/wavpack: include cleanup 2013-01-10 18:18:02 +01:00
Max Kellermann
911411e630 conf: convert to C++ 2013-01-10 18:18:02 +01:00
Max Kellermann
c02cc199bc path: move code to IsSupportedCharset() 2013-01-10 18:06:21 +01:00
Max Kellermann
dd6c21e092 path: make the "win_charset" buffer static
It is illegal to use it after going out of scope.
2013-01-10 17:54:11 +01:00
Denis Krjuchkov
7801ca86b9 mpdconf.example: provide an example of openal output 2013-01-10 15:50:00 +06:00
Denis Krjuchkov
10fc288c91 mpdconf.example: provide an example of winmm output 2013-01-10 15:46:30 +06:00
Max Kellermann
b8cda53bd3 notify: convert to C++ 2013-01-10 10:44:04 +01:00
Denis Krjuchkov
43806d524d mpdconf.example: improve documentation for replay gain
- Added replaygain_missing_preamp and replaygain_limit settings

- Added information about "auto" replay gain mode
2013-01-10 15:34:25 +06:00
Max Kellermann
e0a97a030f io_thread: convert to C++ 2013-01-10 10:33:20 +01:00
Max Kellermann
33ba288622 input/{curl,soup}: convert to C++ 2013-01-10 10:23:20 +01:00
Max Kellermann
d5516dee00 input_stream: convert to C++ (internally) 2013-01-10 10:15:09 +01:00
Max Kellermann
06e0741a52 PlayerControl: switch to the Mutex/Cond classes 2013-01-10 10:12:54 +01:00
Max Kellermann
0b93445380 thread/Cond: new wrapper for pthread_cond_t or GCond 2013-01-10 10:03:19 +01:00
Max Kellermann
483ba5ea1c thread/GLibMutex: new Mutex implementation
Switch WIN32 to this implementation to be able to use condition
variables, which is impossible with CriticalSection.
2013-01-10 10:03:18 +01:00
Max Kellermann
18076ac9b7 PlayerThread: use pc.cond instead of main_cond
The main_cond variable was completely unnecessary.  The pc.cond object
can be used for both main->pc and pc->main.
2013-01-10 10:01:24 +01:00
Max Kellermann
ad15ca7104 DecoderControl: take ownership of client_cond
Don't let the "client" pass its own GCond.  This was not used
consistently.
2013-01-10 10:01:18 +01:00
Max Kellermann
53117ac204 DecoderThread: signal the client after decoder finishes
Fixes potential dead lock bug.
2013-01-10 10:00:53 +01:00
Max Kellermann
51a8c109ab thread/PosixMutex: fix indent 2013-01-10 10:00:52 +01:00
Denis Krjuchkov
ea25e0ee55 configure.ac: change newline position to fit into 80 chars 2013-01-10 14:47:15 +06:00
Denis Krjuchkov
e6fdae431f configure.ac: print results of libmpdclient detection 2013-01-10 14:42:10 +06:00
Denis Krjuchkov
34afc272fd configure.ac: print results of AdPlug detection 2013-01-10 14:33:10 +06:00
Denis Krjuchkov
a5673fcb28 configure.ac: consistently use Opus name 2013-01-10 14:32:18 +06:00
Max Kellermann
5c3c506638 GlobalEvents: lock-less operation using std::atomic
Use a bit field instead of a mutex-protected bool array.
2013-01-10 00:57:18 +01:00
Max Kellermann
ecd5eb02c5 event/WakeFD: use eventfd() if available 2013-01-10 00:10:01 +01:00
Max Kellermann
3be57dc4a3 fd_util: support eventfd() 2013-01-10 00:10:01 +01:00
Max Kellermann
a93caf3cfe GlobalEvents: move code to class WakeFD 2013-01-09 23:47:38 +01:00
Max Kellermann
26ebfc04b0 EventPipe: rename to GlobalEvents 2013-01-09 23:31:43 +01:00
Max Kellermann
8782f6d232 EventPipe: use Mutex instead of GMutex 2013-01-09 23:30:07 +01:00
Max Kellermann
5faf443038 event_pipe.h: convert to C++ 2013-01-09 22:37:47 +01:00
Max Kellermann
8eacd13ce7 sig_handlers, log: convert to C++ 2013-01-09 22:33:06 +01:00
Max Kellermann
d3e1b72d38 mixer/{alsa,pulse}: convert to C++ 2013-01-09 22:25:24 +01:00
Max Kellermann
b5e1bd5705 Playlist.hxx: move prototype to PlaylistGlobal.hxx 2013-01-09 22:23:37 +01:00
Max Kellermann
4bef0a1e62 Playlist: move playlist_increment_version_all() into the class 2013-01-09 22:21:16 +01:00
Max Kellermann
3e5f09be0b event_pipe: convert to C++ 2013-01-09 13:02:13 +01:00
Max Kellermann
e86e77ad67 idle: convert to C++ 2013-01-09 13:01:38 +01:00
Max Kellermann
3c4bb9ff4e test/FakeReplayGainConfig: move fake symbols from a few debug programs 2013-01-09 12:26:07 +01:00
Max Kellermann
a890dadfd2 test/run_decoder,read_tags: remove obsolete dummy functions 2013-01-09 12:25:39 +01:00
Max Kellermann
6b4374583a ReplayGainCoinfig: initialize replay_gain_limit with default value 2013-01-09 12:25:14 +01:00
Denis Krjuchkov
78f4171a7a configure.ac: improve detection of libgme
At least in my configuration libgme lacks .pc file
thus could not be detected with pkg-config.
2013-01-09 14:35:25 +06:00
Max Kellermann
f8a99a391e ReplayGainCoinfig: make DEFAULT_REPLAYGAIN_LIMIT static 2013-01-09 08:56:16 +01:00
Max Kellermann
2564f763d7 ClientList: don't use GLib
Use std::list instead of GList.
2013-01-09 08:12:44 +01:00
Max Kellermann
377a2b9e07 ClientList: add header ClientList.hxx 2013-01-09 08:08:36 +01:00
Max Kellermann
045993001c zeroconf-bonjour: include Listen.hxx instead of listen.h
Should fix the OS X build.
2013-01-09 08:07:26 +01:00
Max Kellermann
affc446690 Queue: use std::stable_sort() instead of g_qsort_with_data() 2013-01-08 16:51:21 +01:00
Max Kellermann
255ee646c2 song: don't use GLib 2013-01-08 16:47:12 +01:00
Max Kellermann
0308ec564e util/list: don't use GLib 2013-01-08 16:41:36 +01:00
Max Kellermann
6cafec8ae6 Queue: allocate memory with new/delete 2013-01-08 16:35:09 +01:00
Max Kellermann
8ef87be482 Queue: use signed integer instead of G_MAXUINT
The check for unsigned underflow is fragile and unreliable.
2013-01-08 16:33:33 +01:00
Max Kellermann
6c57047362 Queue: move code to new class IdTable 2013-01-08 16:11:25 +01:00
Max Kellermann
e29bc6912b Queue: rename internal types 2013-01-08 16:05:10 +01:00
Max Kellermann
ce57b8b6df Queue: move HASH_MULT and Item into the Queue class 2013-01-08 16:04:10 +01:00
Max Kellermann
d81a9029db Queue: move GenerateId() and others into the class 2013-01-08 15:38:10 +01:00
Max Kellermann
620ae7790b test: rename debug programs back to old names 2013-01-08 15:33:58 +01:00
Denis Krjuchkov
23b2b7144b Makefile.am: distribute mpc.ico 2013-01-08 17:46:04 +06:00
Max Kellermann
bf4311cd9b decoder/OggUtil,Opus: move code to new class OggSyncState 2013-01-08 11:04:14 +01:00
Max Kellermann
8f7adf79a3 decoder/Opus: read total time 2013-01-08 01:38:02 +01:00
Max Kellermann
97b164d03b decoder/OggUtil: add OggExpectPageSeek() 2013-01-08 01:30:44 +01:00
Max Kellermann
61e7e531c2 decoder/Opus: move page reader into the decoder class 2013-01-08 01:22:11 +01:00
Max Kellermann
ceb652915f decoder/Opus: move code to HandlePackets() 2013-01-08 01:20:03 +01:00
Max Kellermann
cdaf504ab8 decoder/Opus: make internal methods inline 2013-01-08 01:19:18 +01:00
Max Kellermann
9fb5aad157 decoder/OggUtil: add OggExpectFirstPage() and OggExpectPageIn() 2013-01-08 01:08:01 +01:00
Max Kellermann
a6301d45f4 decoder/Opus: use OggExpectPage() in main loop 2013-01-08 01:05:59 +01:00
Max Kellermann
b83d069266 decoder/OggUtil: add struct forward declarations 2013-01-08 01:02:06 +01:00
Max Kellermann
960b9a9664 input_stream: add method _cheap_seeking()
Move code from the Vorbis decoder plugin.
2013-01-07 23:25:08 +01:00
Max Kellermann
acb45caa42 decoder/ogg_codec: convert to C++ 2013-01-07 22:14:52 +01:00
Max Kellermann
39060b528a decoder/vorbis: convert to C++ 2013-01-07 22:04:58 +01:00
Max Kellermann
4a36323f1b Queue: don't include glib.h 2013-01-07 22:01:56 +01:00
Max Kellermann
c6281b2680 Queue: use C++ random instead of GLib's GRand 2013-01-07 22:00:57 +01:00
Max Kellermann
5b8b7d1412 util/LazyRandomEngine: lazy wrapper for std::mt19937 2013-01-07 21:27:51 +01:00
Max Kellermann
53e5139b99 Queue: move queue_shuffle_order_first() into the class 2013-01-07 21:26:22 +01:00
Max Kellermann
2b8ce83c9b Queue: move queue_shuffle_order_range() into the class 2013-01-07 21:17:01 +01:00
Max Kellermann
52638c68f5 Playlist: convert functions to methods 2013-01-07 11:35:35 +01:00
Max Kellermann
400ff1c812 DatabaseQueue: pass DatabaseSelection to Add...() 2013-01-07 11:33:00 +01:00
Max Kellermann
d360f17a59 Client: add Partition reference attribute
playlist and player_control are deprecated.
2013-01-07 10:59:56 +01:00
Max Kellermann
a6ee6be960 TagPool: use the Mutex class instead of GStaticMutex 2013-01-07 10:49:21 +01:00
Max Kellermann
47911f9544 tag: convert to C++ 2013-01-07 10:36:27 +01:00
Max Kellermann
48025c2279 DatabaseLock: use the Mutex class instead of GLib's GMutex 2013-01-07 10:34:55 +01:00
Max Kellermann
a68302e50b thread/Mutex: don't use std::mutex
Use a custom pthread_mutex_t wrapper because std::mutex adds overhead.
2013-01-07 10:33:37 +01:00
Max Kellermann
333a08ebf9 replay_gain_info, ...: use cmath instead of math.h in C++ mode
Fixes build problems with mingw32.
2013-01-07 10:19:02 +01:00
Max Kellermann
989c9a7317 filter/replay_gain: convert to C++ 2013-01-07 10:17:16 +01:00
Max Kellermann
975370c084 decoder_api.h, ...: add "extern C" 2013-01-07 10:07:40 +01:00
Max Kellermann
c3c776bc6a mixer_all: convert to C++ 2013-01-07 09:05:06 +01:00
Max Kellermann
9f4b906e6c volume: convert to C++ 2013-01-07 09:05:01 +01:00
Max Kellermann
804900df36 audio_config, volume, mixer_all: include cleanup 2013-01-07 08:54:01 +01:00
Max Kellermann
3781f6cf39 Merge tag 'release-0.17.3' 2013-01-07 08:46:55 +01:00
Avuton Olrich
227da2377a Modify version string to post-release version 0.17.4~git 2013-01-06 16:47:09 -08:00
Avuton Olrich
ffb3a9f526 mpd version 0.17.3 2013-01-06 16:47:09 -08:00
Max Kellermann
6936c0e2ab Queue: use std::swap 2013-01-06 23:48:34 +01:00
Max Kellermann
108242042e queue: convert all functions to methods 2013-01-06 21:33:58 +01:00
Max Kellermann
70652abf97 Queue: add constructor and destructor 2013-01-06 18:59:39 +01:00
Max Kellermann
e202b407ec Playlist: add constructor and destructor 2013-01-06 18:59:33 +01:00
Max Kellermann
2cc89e60cc DatabaseQueue: force passing playlist reference to std::bind()
Avoid implicit copy.
2013-01-06 18:59:01 +01:00
Max Kellermann
d536944beb Partition: new class, container for Playlist and PlayerControl
This is the beginning of multi-player support.  There will be support
for multiple Partition objects in one MPD process.
2013-01-05 02:43:00 +01:00
Max Kellermann
1a8ef3cdab filter/ReplayGain: add method _set_mode()
Push the new mode to the filter instead of accessing global variables
through replay_gain_get_real_mode().
2013-01-05 02:40:33 +01:00
Max Kellermann
7be33eba48 DecoderAPI: don't use replay_gain_get_real_mode()
replay_gain_get_real_mode() accesses dangerous globals.  Let's just
use the global variable replay_gain_mode, and assume "AUTO" means
"TRACK".  At this point, this is the best we can do, because neither
the decoder nor the player should know about the current replay gain
mode.  This is applied as a filter in the output thread.
2013-01-05 02:40:32 +01:00
Max Kellermann
46ed91b53d DecoderAPI: _replay_gain() returns void
Let the function decoder_replay_gain() update
decoder_control::replay_gain_db instead of letting each decoder plugin
take care for that.
2013-01-05 02:40:29 +01:00
Max Kellermann
73f6fc428a test: revert debug program renames 2013-01-05 02:39:32 +01:00
Max Kellermann
44d260f911 replay_gain_*: convert to C++ 2013-01-04 23:50:58 +01:00
Max Kellermann
07249fc395 replay_gain_config: remove unused variable replay_gain_mode_names 2013-01-04 23:49:41 +01:00
Max Kellermann
bc1e8e01f3 DatabaseQueue: pass playlist object
Don't use the global variable "g_playlist".
2013-01-04 23:19:46 +01:00
Max Kellermann
fe8e77e556 Client: add "playlist" attribute
Reduce access to the global variable "g_playlist".
2013-01-04 23:07:11 +01:00
Max Kellermann
b0833084a6 PlayerControl: initialize all attributes 2013-01-04 23:04:42 +01:00
Max Kellermann
3cacaa5dad Client: initialize num_subscriptions 2013-01-04 23:02:35 +01:00
Max Kellermann
e89bd30db5 Playlist: pass max_length to playlist_init()
Move the configuration lookup to Main.cxx.
2013-01-04 22:55:11 +01:00
Max Kellermann
2a9d933a81 PlayerControl: add constructor and destructor 2013-01-04 22:45:14 +01:00
Max Kellermann
81f3d893d9 player_control.h: convert header to C++ 2013-01-04 22:31:53 +01:00
Max Kellermann
05c91082e3 playlist: convert to C++ 2013-01-04 22:12:33 +01:00
Max Kellermann
7267558ba1 DecoderThread: move code to destructor 2013-01-04 22:02:52 +01:00
Max Kellermann
ac6803e7b7 DecoderInternal: initialize replay_gain_serial 2013-01-04 22:01:13 +01:00
Max Kellermann
ffabf8b013 DecoderInternal: move initializers to constructor 2013-01-04 21:59:03 +01:00
Max Kellermann
e9b71a0d28 MusicChunk: move functions to methods 2013-01-04 21:38:46 +01:00
Max Kellermann
efbfe66f21 Mutex: new wrapper for std::mutex, replaces GMutex 2013-01-04 21:24:29 +01:00
Max Kellermann
6886063703 MusicPipe: allocate with new/delete 2013-01-04 21:22:07 +01:00
Max Kellermann
c04e1ad401 mpd_error.h: add missing glib.h include 2013-01-04 21:20:10 +01:00
Max Kellermann
223b90d0d4 MusicBuffer: return memory to kernel when stopping playback
Use the new HugeAllocator as backend for SliceBuffer and call
HugeDiscard() when the last chunk was returned.
2013-01-04 20:48:28 +01:00
Max Kellermann
692b2cfb79 HugeAllocator: new memory allocator 2013-01-04 20:38:06 +01:00
Max Kellermann
447a86c922 SliceBuffer: lazy initialization
Avoid page faults on MPD startup.  This saves a lot of memory for an
idle MPD.
2013-01-04 20:29:47 +01:00
Max Kellermann
e3a2bd3a1e MusicBuffer: move code to template class SliceBuffer 2013-01-04 17:12:21 +01:00
Max Kellermann
f0be6a4b9e MusicBuffer: allocate with new/delete 2013-01-04 17:03:50 +01:00
Max Kellermann
bdab5d5f6e MusicBuffer: disable memory poisoning
This is harmful for memory usage, because it forces the kernel to
allocate physical memory, even before playback has started.  No bug
has been found in a few years with this, so it's safe to assume that
this code is not necessary.
2013-01-04 15:42:15 +01:00
Max Kellermann
15a4246ead Client, Inotify: use std::list instead of std::deque
Random access is not necessary here.
2013-01-04 14:44:06 +01:00
Max Kellermann
9a71845700 crossfade: convert to C++ 2013-01-04 10:31:59 +01:00
Max Kellermann
22f0a1547c buffer, pipe: convert to C++ 2013-01-04 10:16:16 +01:00
Max Kellermann
de0ab43bc1 output_*: convert to C++ 2013-01-04 09:46:41 +01:00
Max Kellermann
e12cc01aa4 decoder_*: convert to C++ 2013-01-04 09:41:45 +01:00
Max Kellermann
71c697288b pcm_convert: make C++ safe 2013-01-04 08:49:15 +01:00
Max Kellermann
a7d1daee93 CommandListBuilder: use std::list instead of GSList 2013-01-04 01:17:25 +01:00
Max Kellermann
77a99cc61d CommandListBuilder: rename attributes 2013-01-04 01:16:22 +01:00
Max Kellermann
fb337418a5 Client: move code to class CommandListBuilder 2013-01-04 00:50:13 +01:00
Max Kellermann
9d312ab208 PlaylistFile: reuse classes PlaylistInfo and PlaylistVector
.. instead of rolling own classes.
2013-01-04 00:02:09 +01:00
Max Kellermann
06be0a1997 PlaylistInfo: remove the obsolete list_head attribute 2013-01-04 00:01:01 +01:00
Max Kellermann
9e4509b846 ClientNew: initialise the "idle" attributes
Make valgrind happy.
2013-01-03 23:59:45 +01:00
Max Kellermann
fc1f0eeda7 Client: add constructor and destructor
Move code from client_new() and client_close().
2013-01-03 23:59:45 +01:00
Max Kellermann
3d5c094804 PlaylistFile: fix memory leak 2013-01-03 23:59:45 +01:00
Max Kellermann
6abc94ec07 valgrind.suppressions: add more suppressions 2013-01-03 23:59:02 +01:00
Max Kellermann
6837e5a6a0 Merge branch 'v0.17.x' 2013-01-03 22:53:53 +01:00
Max Kellermann
9761abf3b5 cue_parser: fix CUE files with only one track
Track whether _finish() has been called, and deliver all partial
results then.  Fixes Mantis ticket 0003621.
2013-01-03 21:58:20 +01:00
Max Kellermann
599a562170 cue_parser: add code comments 2013-01-03 21:38:38 +01:00
Max Kellermann
d29a251547 .gitignore: add more debug programs 2013-01-03 21:21:32 +01:00
Max Kellermann
31da4bc566 cue_parser: fix memory leak 2013-01-03 21:02:59 +01:00
Denis Krjuchkov
0f1a180e15 mpd_auto.m4: Pass libraries to AC_CHECK_LIB in MPD_AUTO_PKG_LIB
Rationale: vanilla libid3tag does not have any pkg-config stuff
and fails to detect because symbols from libz are not found.
2013-01-03 19:59:41 +01:00
Denis Krjuchkov
01a45a53aa cmdline: bunch of fixes related to config file selection
- fix potential memory leak of system_path

  'Potential' because currently g_get_system_config_dirs()
  returns single entry on Windows, but that might change.

- remove incorrect g_free() call

  It's not required at all because
  g_get_system_config_dirs() returns GLib owned memory.

- remove extra semicolon
2013-01-03 19:45:51 +01:00
Max Kellermann
59400d38a9 Client: use std::deque for messages 2013-01-03 18:07:48 +01:00
Max Kellermann
5155b0f608 ClientMessage: turn into a class 2013-01-03 17:58:22 +01:00
Max Kellermann
d919f8d50a ClientInternal: use std::set for subscriptions 2013-01-03 17:49:47 +01:00
Max Kellermann
d67aa7c19d ClientNew: allocate/dispose client objects with new/delete
Prepare for adding non-trivial attributes.
2013-01-03 17:47:39 +01:00
Max Kellermann
7a982169c9 Client: rename the struct client to class Client 2013-01-03 17:36:28 +01:00
Max Kellermann
f2510d60fa ls.h: rename to ls.hxx 2013-01-03 17:34:51 +01:00
Max Kellermann
1e0ea57dc4 cmdline: convert to C++ 2013-01-03 17:31:38 +01:00
Max Kellermann
70b87f2eb6 client: convert to C++ 2013-01-03 11:16:18 +01:00
Max Kellermann
94b2ee627c decoder_print: convert to C++ 2013-01-03 11:14:36 +01:00
Max Kellermann
e30a2dd2d7 listen: convert to C++ 2013-01-03 11:05:44 +01:00
Max Kellermann
7e07daf8cb ls: convert to C++ 2013-01-03 11:01:02 +01:00
Max Kellermann
981906ecd1 output_print: convert to C++ 2013-01-03 10:58:39 +01:00
Max Kellermann
90fe4c5124 TextFile: convert to a class 2013-01-03 10:16:05 +01:00
Max Kellermann
2452447c81 text_file: convert to C++ 2013-01-03 10:12:41 +01:00
Max Kellermann
93f0bb8307 ExcludeList: convert to a class 2013-01-03 10:02:43 +01:00
Max Kellermann
47fc08bffe exclude: convert to C++ 2013-01-03 10:02:33 +01:00
Max Kellermann
c0f2024a2e exclude: make variables more local 2013-01-03 10:02:26 +01:00
Max Kellermann
28f3e190c8 InotifyQueue: use std::deque instead of GSList 2013-01-03 10:02:26 +01:00
Max Kellermann
c4090b670d Permission: use std::map instead of GHashTable 2013-01-03 03:11:39 +01:00
Max Kellermann
ddf112378b permission: convert to C++ 2013-01-03 03:09:50 +01:00
Max Kellermann
b25cce464a client_new: convert to C++ 2013-01-03 03:07:16 +01:00
Max Kellermann
a2297558ff MessageCommands: use std::set instead of GHashTable 2013-01-03 02:40:21 +01:00
Max Kellermann
84cdf0cacc StickerDatabase: use std::map instead of GHashTable 2013-01-03 02:39:08 +01:00
Max Kellermann
9e99e5bef9 strset: delete obsolete library 2013-01-03 02:31:47 +01:00
Max Kellermann
9023ba4a81 PlaylistVector: use std::list 2013-01-03 02:25:06 +01:00
Max Kellermann
83488848e1 Directory: initialise in default constructor 2013-01-03 02:12:34 +01:00
Max Kellermann
f5a92d6cc3 Directory: add constructor and destructor 2013-01-03 01:36:28 +01:00
Max Kellermann
3e8047e583 Directory: rename struct directory to Directory 2013-01-03 01:10:47 +01:00
Max Kellermann
440ac51cf0 database.h: rename to DatabaseSimple.hxx 2013-01-03 01:06:11 +01:00
Max Kellermann
d3293b889d database.h: move prototypes to DatabaseGlue.hxx 2013-01-03 01:04:18 +01:00
Max Kellermann
b4b0b34e5a database.h: eliminate db_*_song()
Use the C++ API.
2013-01-03 00:37:18 +01:00
Max Kellermann
fa3d1156a6 playlist_edit: convert to C++ 2013-01-03 00:35:05 +01:00
Max Kellermann
0eb05b827f Directory: turn functions to methods 2013-01-02 23:06:10 +01:00
Max Kellermann
0c245bc271 Directory: make the header C++ only 2013-01-02 22:52:08 +01:00
Max Kellermann
d65ad1bf15 mapper: convert to C++ 2013-01-02 22:43:56 +01:00
Max Kellermann
43cbbe111b song_update: convert to C++ 2013-01-02 22:42:12 +01:00
Max Kellermann
9ceb8a717a sticker: convert to C++ 2013-01-02 22:25:17 +01:00
Max Kellermann
8331de424a PlaylistInfo: rename class, use std::string 2013-01-02 22:16:05 +01:00
Max Kellermann
98dbdf72b3 PlaylistVector: move struct playlist_metadata to PlaylistInfo.hxx 2013-01-02 22:01:04 +01:00
Max Kellermann
51a2d09eb7 db_lock: convert to C++ 2013-01-02 20:56:21 +01:00
Max Kellermann
22f0ef6d6b don't include stdbool.h in C++ sources
The "bool" type is built-in.
2013-01-02 20:56:04 +01:00
Max Kellermann
975deca85b {decoder,player}_thread: convert to C++ 2013-01-02 20:36:28 +01:00
Max Kellermann
3bbb502387 *_print: convert to C++ 2013-01-02 20:29:24 +01:00
Max Kellermann
0023dffd0b playlist_vector: convert to C++ 2013-01-02 20:25:20 +01:00
Max Kellermann
b715e522cf db_save, state_file: convert to C++ 2013-01-02 20:22:59 +01:00
Max Kellermann
4b0b8315a9 string_util: use const_cast in C++ mode 2013-01-02 20:22:59 +01:00
Max Kellermann
a654f146d1 update: convert to C++ 2013-01-02 19:22:15 +01:00
Max Kellermann
67b46a151d playlist_{any,song,queue}: convert to C++ 2013-01-02 19:19:58 +01:00
Max Kellermann
83c7e1e129 configure.ac: disable C++ RTTI
RTTI adds overhead to the binary, and we don't need that.
2013-01-02 19:19:58 +01:00
Max Kellermann
a6371e2e66 configure.ac: disable C++ exceptions
We don't use exceptions currently.  Since allowing exceptions means a
lot of overhead, this commit disables the feature.
2013-01-02 19:12:27 +01:00
Max Kellermann
7768baa4d1 configure.ac: hide internal symbols
Allows eliminating more dead code.  Adds two more C++ options that may
reduce the binary size.
2013-01-02 19:04:23 +01:00
John
a9a5907a0f mpd.service: depend on network.target
Since some configurations use the "bind_to_address" option in their
/etc/mpd.conf, the systemd service file must wait for the
network.target or else mpd will start before it and thus fail due to
no iface.
2012-11-21 17:26:23 +01:00
Jurgen Kramer
dc32d1f3f3 Add tag support for DSD (DSDIFF & DSF) decoders 2012-10-27 11:42:34 +02:00
Max Kellermann
cbdaa1369f Merge branch 'v0.17.x'
Conflicts:
	src/PlaylistSave.cxx
2012-10-05 17:12:44 +02:00
Max Kellermann
8fb20fcdf8 playlist_song: fix potential charset bug in apply_song_metadata()
The song's URI must be UTF-8, not filesystem character set.
2012-10-05 17:01:04 +02:00
Max Kellermann
72bf226608 playlist_save: use temp2 instead of temp
Fixes minor Windows compatibility problem.
2012-10-05 16:55:30 +02:00
Max Kellermann
d4b5699403 decoder/ffmpeg: support planar audio
Implements Mantis feature request 3582.
2012-10-05 16:40:25 +02:00
Max Kellermann
1dc27be015 decoder/ffmpeg: fix playback of planar PCM data
Interleaving was completely wrong.  This code was never used, so it
didn't have an effect.
2012-10-05 16:38:55 +02:00
Max Kellermann
230a3eb400 decoder/ffmpeg: move code to copy_interleave_frame2() 2012-10-05 16:37:07 +02:00
Max Kellermann
e39382dedd decoder/ffmpeg: ignore negative time stamps
Works around assertion failure in decoder_timestamp().
2012-10-05 16:37:07 +02:00
Max Kellermann
fd016f4507 decoder/ffmpeg: show unsupported sample format name
Use av_get_sample_fmt_string() to obtain a human-readable string.
2012-10-05 15:24:53 +02:00
Max Kellermann
9d728b365d decoder/ffmpeg: pass AVSampleFormat to ffmpeg_sample_format()
API simplification.
2012-10-05 15:14:57 +02:00
Max Kellermann
ddc0283339 decoder/ffmpeg: remove duplicate sample format error message 2012-10-05 14:52:30 +02:00
Max Kellermann
b8fdb452be decoder/flac: support FLAC files inside archives
Implement the "scan_stream" method that can read tags from any
input_stream object.  This requires a FLAC__IOCallbacks implementation
based on the input_stream API.
2012-10-04 10:37:09 +02:00
Max Kellermann
6b416ce6be decoder/flac: move flac_scan_file2() to main plugin file 2012-10-04 10:32:52 +02:00
Max Kellermann
ef0392e854 input/file: use errno_quark() 2012-10-04 10:32:04 +02:00
Max Kellermann
efbf184fe8 PlaylistFile, client_file, tag_id3: don't use g_file_error_quark()
g_file_error_quark() is meant to be used with the GFileError enum
which does not correspond with errno, but must be converted with
g_file_error_from_errno().

At the same time, this removes g_strerror() use for
g_file_error_quark().
2012-10-04 10:31:53 +02:00
Max Kellermann
dd577fb857 test/read_tags: wait until input_stream becomes ready
Improved support for scanning http:// resources.
2012-10-04 09:28:13 +02:00
Max Kellermann
ebd90dbb1a decoder/flac: move callbacks to class FLACInput 2012-10-02 19:59:49 +02:00
Max Kellermann
c9e700f079 decoder/flac: add ctor/dtor to struct flac_data 2012-10-02 19:47:31 +02:00
Max Kellermann
3c2d73d161 decoder/flac: add method FLACMetadataChain::Scan()
Merge common code.
2012-10-02 18:24:15 +02:00
Max Kellermann
343de8b8ab decoder/flac: don't use FLAC__Metadata_SimpleIterator
Use the new FLACMetadataIterator C++ class, which is more powerful.
2012-10-02 17:38:21 +02:00
Max Kellermann
c645b906f3 decoder/flac: add C++ libFLAC wrappers
Not using libFLAC++ because this library adds a lot of overhead due to
virtual method calls.  This new class library is zero-overhead.
2012-10-02 17:37:07 +02:00
Max Kellermann
9c1d1ef268 decoder/flac: eliminate the obsolete "track number" code
This has been deprecated by the "embcue" playlist plugin.
2012-10-02 17:36:54 +02:00
Max Kellermann
ade0483641 Merge branch 'v0.17.x' 2012-10-02 17:34:03 +02:00
Gregory Smith
03a401e477 OSX: Set mDataByteSize correctly on AudioBuffers during render. 2012-10-02 17:27:52 +02:00
Max Kellermann
9994521b8c test/dump_playlist: add missing newline to error message 2012-10-02 17:27:47 +02:00
Max Kellermann
e5fd1924db decoder/flac: remove unused function flac_tag_load() 2012-10-02 11:39:10 +02:00
Max Kellermann
cbdd042adc decoder/flac: use C++ compiler 2012-10-02 10:59:56 +02:00
Max Kellermann
a9419da09c Makefile.am: eliminate FLAC_COMMON 2012-10-02 10:58:53 +02:00
Max Kellermann
ccd7104cdc {decoder,encoder}/flac: drop support for libFLAC 1.1 2012-10-02 10:04:44 +02:00
Max Kellermann
1cf4b5ce47 encoder/opus: implement lookahead
The "opusinfo" program complained about preskip value that was too
small.  This commit uses OPUS_GET_LOOKAHEAD to obtain the number of
frames that shall be silence at the beginning.
2012-10-02 09:42:03 +02:00
Max Kellermann
1badb3b5d5 encoder/opus: initialize the "granulepos" packet attribute 2012-10-02 09:16:44 +02:00
Max Kellermann
038d216f18 encoder/{vorbis,opus}: merge code to new class OggStream 2012-10-02 09:06:03 +02:00
Max Kellermann
9e3f843291 encoder/vorbis: accept floating point input samples
Improves quality by not squeezing 32 bit samples down to 16 bit, and
then back to 32 bit floating point.  Reduces CPU usage by skipping a
conversion step.
2012-10-02 08:39:39 +02:00
Max Kellermann
e166ddf46f pcm_channels: support floating point samples 2012-10-02 08:39:12 +02:00
Max Kellermann
31e1be7570 encoder/opus: call ogg_stream_flush() only in the last iteration
If there are multiple pages, the last partial page must be flushed.
2012-10-02 08:13:48 +02:00
Max Kellermann
d793b7c03f encoder/opus: new encoder plugin for the Opus codec 2012-10-02 00:45:24 +02:00
Max Kellermann
9a715267ad output/shout: move code to my_shout_configure()
Eliminate the evil goto.
2012-10-02 00:39:21 +02:00
Max Kellermann
eafa432cc6 encoder/vorbis: use C++ compiler 2012-10-02 00:37:19 +02:00
Max Kellermann
d95e538020 Merge branch 'v0.17.x' 2012-10-02 00:36:05 +02:00
Max Kellermann
adbe8c409a output/{recorder,shout}: call encoder_read() in a loop
This is necessary for Ogg packets that span more than one page.
2012-10-02 00:26:40 +02:00
Max Kellermann
58e600f408 output/recorder: move code to _write_to_file() 2012-10-02 00:26:40 +02:00
Max Kellermann
d34e55c370 output/recorder: fix write() error check
We can only check for negative values if the variable is signed.
2012-10-02 00:20:42 +02:00
Max Kellermann
fbcbcdc001 output/recorder: make variables more local 2012-10-02 00:20:32 +02:00
Max Kellermann
4227a325a5 output/httpd: make variables more local 2012-10-02 00:20:13 +02:00
Max Kellermann
d115507502 encoder/vorbis: make variables more local 2012-10-02 00:20:01 +02:00
Max Kellermann
43d8252050 output/recorder, test/*: invoke encoder_read() after _open()
Make sure the file header gets written at the beginning, before
_write() gets called.
2012-10-02 00:18:18 +02:00
Max Kellermann
674b4ab647 output/shout: eliminate struct shout_buffer
Move the raw buffer to struct shout_data.
2012-10-02 00:18:04 +02:00
Max Kellermann
fe8fc1081a output/shout: remove shout_buffer.len
Make it a local variable instead.
2012-10-02 00:17:53 +02:00
Max Kellermann
c7748fedab output/shout: fix memory leak in error handler 2012-10-02 00:17:27 +02:00
Max Kellermann
c392efb481 output/shout: make variables more local 2012-10-02 00:17:17 +02:00
Max Kellermann
1ddd9dd52a test/run_encoder: fix encoder_open() call 2012-10-02 00:17:08 +02:00
Max Kellermann
aa171dcc18 configure.ac: fix AC_CONFIG_SRCDIR call
main.c has been renamed to Main.cxx.
2012-10-01 13:37:02 +02:00
Max Kellermann
b4d8cb7bc1 Merge tag 'release-0.17.2' 2012-10-01 11:06:54 +02:00
Avuton Olrich
f672e4016f Modify version string to post-release version 0.17.3~git 2012-09-30 03:27:38 -07:00
Avuton Olrich
76e3dec723 mpd version 0.17.2 2012-09-30 03:27:38 -07:00
Max Kellermann
d0c3fa0150 main: use C++ compiler 2012-09-28 00:40:00 +02:00
Max Kellermann
609f6ce66d PlaylistFile: use std::list instead of GPtrArray 2012-09-28 00:10:02 +02:00
Max Kellermann
7298b6c846 stored_playlist, playlist_save: use C++ compiler 2012-09-28 00:08:15 +02:00
Max Kellermann
acec9c4fd7 stored_playlist: make variables more local 2012-09-28 00:05:21 +02:00
Max Kellermann
9cdbde4f5e output: new option "tags" may be used to disable sending tags
Implements Mantis ticket 0003340.
2012-09-25 23:31:07 +02:00
Max Kellermann
f9147a0706 NEWS: mention the AdPlug decoder 2012-09-25 23:31:07 +02:00
Max Kellermann
33364edfb3 decoder/adplug: new decoder plugin 2012-09-25 22:03:44 +02:00
Simon Hosie
5e9ccdec63 decoder/vorbis: skip 16 bit quantisation, provide float samples
Internally the vorbis (non-Tremor) decoder is working in floating
point, and it's not really necessary to cut the output back to 16-bit
if the soundcard or OS supports higher resolution.

The decoder can be trivially modified to bypass its internal
quantisation and produce floating-point output, and a separate
quantisation can be used as appropriate to the platform.
2012-09-25 21:27:50 +02:00
Max Kellermann
071aca60be decoder/vorbis: rename local variables 2012-09-25 21:26:27 +02:00
Max Kellermann
133e4d5c51 decoder/vorbis: improved support for initial seek
Call decoder_get_command() before doing anything else.
2012-09-25 21:26:27 +02:00
Max Kellermann
fd56461d5f decoder/vorbis: make variables more local 2012-09-25 21:11:38 +02:00
Max Kellermann
d5f59f8c86 INSTALL: correct the libopus URL 2012-09-25 21:09:05 +02:00
Max Kellermann
a5d8b27671 command.h: move function prototypes to AllCommands.h 2012-09-25 12:20:36 +02:00
Max Kellermann
f3f25d5d40 command.h: remove obsolete command_success() prototype
This lives in protocol/result.h now.
2012-09-25 12:20:33 +02:00
Max Kellermann
f118812c34 playlist: include cleanup 2012-09-25 12:20:30 +02:00
Max Kellermann
98dbc95913 rename CommandError.h to CommandError.hxx 2012-09-25 12:20:15 +02:00
Max Kellermann
145c1d214c *Commands: remove extern"C" from C++ headers 2012-09-25 12:19:18 +02:00
Max Kellermann
b62a8e3e3e command: add COMMAND_RETURN_IDLE
Eliminate the hack in handle_idle().
2012-09-25 12:04:20 +02:00
Max Kellermann
e47240931a command: add documentation for "enum command_return" 2012-09-25 12:02:08 +02:00
Max Kellermann
a84874426d command: remove enum integer values
Just use the values assigned by the compiler.
2012-09-25 12:01:53 +02:00
Max Kellermann
f38dfd9231 command: rename to AllCommands.cxx 2012-09-25 11:56:37 +02:00
Max Kellermann
510c4a3ef1 command: move remaining handlers to OtherCommands.cxx 2012-09-25 11:44:49 +02:00
Max Kellermann
e7e52c24f5 gcc.h: require gcc 4.6
We use range-based for and nullptr, which was not implemented prior to
gcc 4.6.
2012-09-25 11:39:46 +02:00
Max Kellermann
e2a574e2a0 Merge branch 'v0.17.x'
Conflicts:
	src/locate.c
2012-09-25 11:39:01 +02:00
Max Kellermann
ba6ef53ef9 decoder_control: remove MixRamp debug messages
These are confusing, and since MixRamp development has ceased, not
useful to anybody.
2012-09-25 11:08:16 +02:00
Max Kellermann
c93a28c641 configure.ac: don't auto-detect the Vorbis encoder when Tremor is enabled
libvorbisidec and libvorbis export the same symbols, which is a
dangerous thing.  Since libvorbisenc depends on libvorbis, this can
get nasty, so let's disable the Vorbis encoder unless the user
explicitly wants it.
2012-09-25 10:41:39 +02:00
Max Kellermann
7088a679a2 decoder/wavpack: support all APEv2 tags
WavPack tags are always APEv2, by definition.  Reuse the tag_table
from tag_ape.c, instead of rolling our own.
2012-09-25 09:37:16 +02:00
Max Kellermann
04c02a1eb8 locate: cast enum tag_type to int before comparing with integer
Avoids clang pickiness.  This code is not correct, but we'll fix that
another day.
2012-09-22 09:48:27 +02:00
Max Kellermann
1536b5a9d6 src/decoder/opus: new decoder plugin for the Opus codec
Using libopus and libogg.
2012-09-05 23:01:17 +02:00
Max Kellermann
bab756a5d0 decoder/{flac,vorbis}: move tag table to XiphTags.c
Merge duplicate data.
2012-09-05 22:56:57 +02:00
Max Kellermann
8c763fe458 Makefile.am: rename HAVE_OGG_COMMON to HAVE_XIPH 2012-09-05 22:56:17 +02:00
Max Kellermann
886255e38a db/SimpleDatabasePlugin: fix memory leak in Visit()
When visiting a song, GetSong() was called, but this object was never
returned by calling ReturnSong().  This patch locks the database only
once in Visit() and passes the original song object to the visitor,
avoiding the copy.
2012-09-05 20:56:20 +02:00
Max Kellermann
0240e75426 db_lock: add C++ helper class ScopeDatabaseLock 2012-09-05 20:52:02 +02:00
Max Kellermann
7102ed8026 decoder/ogg_codec: return UNKNOWN on error 2012-09-04 13:46:12 +02:00
Max Kellermann
ebf481e1a1 decoder/ogg_common: rename to ogg_codec.c 2012-09-04 13:05:12 +02:00
Max Kellermann
5a52e91350 decoder/ogg_common: pass decoder to _type_detect()
Allow the function to be cancelled.
2012-09-04 12:49:02 +02:00
Max Kellermann
18e458154a decoder/ogg_common: apply coding style 2012-09-04 11:52:18 +02:00
Max Kellermann
015e1ab183 decoder/_ogg_common: rename to ogg_common.c 2012-09-04 11:28:36 +02:00
Max Kellermann
2a4c799471 Merge branch 'v0.17.x' 2012-09-04 11:28:13 +02:00
Max Kellermann
41487426f5 decoder/_ogg_common: fix buffer size check
Fixes potential access to uninitialised memory.
2012-09-04 11:22:15 +02:00
Max Kellermann
0d24250aa7 decoder/_ogg_common: simplify the large "if" expression 2012-09-04 11:22:05 +02:00
Wieland Hoffmann
2050e2f886 mpd.conf(5): Use the correct default value for max_playlist_length 2012-09-03 22:49:51 +02:00
Max Kellermann
013e8479af AudioCompress: abort on out-of-memory
This library crashes on out-of-memory (NULL pointer dereference).
There's not much useful MPD can do in such a situation, so let's
explicitly abort instead, just like GLib does.
2012-09-03 22:45:33 +02:00
Max Kellermann
27535a7f78 update_walk: fix unsafe readlink() usage 2012-09-03 22:41:04 +02:00
Max Kellermann
333d226ed0 SongFilter: convert to a C++ class 2012-08-29 20:19:02 +02:00
Max Kellermann
04a9dec952 playlist_print: rename to PlaylistPrint.cxx 2012-08-29 20:17:13 +02:00
Max Kellermann
6ee76b7154 DatabaseSelection: add method Match() 2012-08-29 20:03:37 +02:00
Max Kellermann
36b1c08ad7 locate: rename to SongFilter.cxx 2012-08-29 19:12:26 +02:00
Max Kellermann
7b35d5e9d4 queue_print: rename to QueuePrint.cxx 2012-08-29 19:07:30 +02:00
Max Kellermann
6d4ca071a5 dbUtils.h: eliminate this header 2012-08-29 18:55:49 +02:00
Max Kellermann
684a3d30a6 command: move code to *Commands.cxx 2012-08-29 17:42:06 +02:00
Max Kellermann
25740d27bf Stats: stats_print() returns void 2012-08-29 17:41:26 +02:00
Max Kellermann
fb0a52a34a decoder/mad, output_thread: add gcc_unlikely() 2012-08-29 17:41:22 +02:00
Max Kellermann
c852970cf6 Makefile.am: distribute DatabaseCommands.hxx 2012-08-29 17:41:22 +02:00
Max Kellermann
def21cc87e Merge branch 'v0.17.x'
Conflicts:
	src/queue_save.c
2012-08-25 10:28:33 +02:00
Max Kellermann
488c1eb87b test/test_queue_priority: fix SIGABRT 2012-08-25 10:24:34 +02:00
Max Kellermann
acaa725478 playlist/cue: map "PERFORMER" to "artist" or "album artist"
Implements Mantis ticket 0003549.
2012-08-25 09:56:14 +02:00
Max Kellermann
f351550534 player_thread: disable cross-fading in "single" mode
This commit reimplements the core of the "single" mode.  Instead of
doing the detection in the playlist code from the outside, it is moved
to the player thread, which gets a new option called "border_pause".
It will now pause playback exactly at the beginning of the new song,
making the feature more reliable.

Now that the player thread knows what will happen, it can suppress
cross-fading.

Fixes mantis tickets 0003055 and 0003166.
2012-08-25 09:38:41 +02:00
Max Kellermann
e8df7e8da5 Database*: fix nullptr dereference when no database is configured 2012-08-22 21:40:20 +02:00
Max Kellermann
af4252bc80 fd_util: make C++ safe 2012-08-22 15:51:56 +02:00
Max Kellermann
695ffedef9 Makefile.am: swap libdb_plugins.a and -lmpdclient order
With some linkers, it is important to specify the static library
first, and then libmpdclient.  Fixes linker failures.
2012-08-22 13:54:31 +02:00
Max Kellermann
66ecf39efe command: make "single" a bool 2012-08-21 19:38:08 +02:00
Max Kellermann
5ad21d7e98 queue_save: save song priorities 2012-08-21 19:17:14 +02:00
Max Kellermann
1c3e03837c configure.ac: set VERSION_MINOR to 18
Updates the WIN32 version number for the upcoming 0.18 release.
2012-08-21 18:42:48 +02:00
Max Kellermann
7968fa3779 ProxyDatabase: implement GetSong() 2012-08-16 00:29:25 +02:00
Max Kellermann
31009bb1f6 ProxyDatabase: clear libmpdclient errors in CheckError()
Auto-recover from soft errors.
2012-08-16 00:29:25 +02:00
Max Kellermann
3b8532f3fb DatabasePlugin: add method ReturnSong()
Allow the plugin to allocate the GetSong() return value.
2012-08-16 00:04:14 +02:00
Max Kellermann
f45616e5f6 Merge branch 'v0.17.x' 2012-08-16 00:04:03 +02:00
Max Kellermann
ef5125f8f4 playlist_print: fix memory leak 2012-08-16 00:01:01 +02:00
Max Kellermann
bf2e07074b playlist_song: pass const song to _check_load_song() 2012-08-16 00:00:50 +02:00
Max Kellermann
20695ef369 playlist_song: fix user-after-free bug 2012-08-16 00:00:21 +02:00
Max Kellermann
e391f4b17b ProxyDatabase: pass "detached" objects to visitors
Fixes wrong object URIs with duplicate base names.
2012-08-15 23:10:59 +02:00
Max Kellermann
2bd344549b queue: duplicate all song objects
Make sure the queue "owns" all song objects, so nobody else can free
them.
2012-08-15 23:10:00 +02:00
Max Kellermann
e96779de48 player_control: duplicate the song object
Make sure the player "owns" the next_song object, so nobody else can
free it.
2012-08-15 23:09:22 +02:00
Max Kellermann
eb54337c40 decoder_control: duplicate the song object
Make sure the decoder "owns" the song object, so nobody else can free
it.
2012-08-15 23:08:39 +02:00
Max Kellermann
916a020173 Song: add function song_dup_detached()
Initial support for "detached" songs that come from the database, but
are private copies.
2012-08-15 23:07:24 +02:00
Max Kellermann
c2e4fe983d Song: add function song_equals()
decoder_is_current_song() now recognizes different instances of the
same physical song.
2012-08-15 23:06:59 +02:00
Max Kellermann
81e898375b Song: move trivial inline functions up 2012-08-15 23:06:48 +02:00
Max Kellermann
3c0dea811d DatabasePlugin: add method GetStats()
Optimize the ProxyDatabase by invoking "stats" on the peer, instead of
visiting all songs.
2012-08-15 23:05:08 +02:00
Max Kellermann
a6ac0f8965 DatabasePlugin: add method VisitUniqueTags()
Optimize the ProxyDatabase by invoking "list" on the peer, instead of
visiting all songs.
2012-08-15 23:02:27 +02:00
Max Kellermann
4e1eb03287 ProxyDatabase: obey visitor return values 2012-08-15 23:02:00 +02:00
Max Kellermann
fcf0f8291d ProxyDatabasePlugin: add OO wrapper for mpd_entity
Let the C++ compiler take care for freeing the objects safely.
2012-08-15 23:01:08 +02:00
Max Kellermann
0ed71fa027 ProxyDatabasePlugin: move tag table to the global name space 2012-08-15 23:00:44 +02:00
Max Kellermann
affe21f7c1 db_visitor: delete obsolete header 2012-08-15 22:57:20 +02:00
Max Kellermann
9facf7897d DatabasePrint: remove bogus "nonnull" attributes 2012-08-15 22:56:24 +02:00
Max Kellermann
8422402c39 Merge branch 'v0.17.x'
Conflicts:
	src/player_thread.c
2012-08-15 22:56:11 +02:00
Max Kellermann
9374e0f445 player_thread: add local variable "start_ms"
Just in case "song" becomes invalid at some point.
2012-08-15 22:51:48 +02:00
Max Kellermann
19ed233118 playlist: fix unprotected player_control access 2012-08-15 22:47:08 +02:00
Max Kellermann
faa4fff4dd filter/volume: include cleanup 2012-08-15 22:45:03 +02:00
Max Kellermann
2276e7677b mapper: fix potential crash in file permission check 2012-08-15 22:44:13 +02:00
Max Kellermann
b5fde6dfa5 decoder_control: add function _is_current_song()
Replaces _current_song().
2012-08-15 17:58:15 +02:00
Max Kellermann
784d666a8e decoder_control: add assertion to dc_get_error() 2012-08-15 17:58:09 +02:00
Max Kellermann
c035910df9 decoder_thread: create GError for mapper failure
Fixes crash.
2012-08-15 17:57:55 +02:00
Max Kellermann
efccb6ac82 Merge branch 'v0.17.x' 2012-08-15 01:04:34 +02:00
Max Kellermann
93f9c2ab6b doc/user: add wildmidi documentation 2012-08-15 01:03:16 +02:00
Max Kellermann
4a993cd79e decoder/fluidsynth: add "sample_rate" setting 2012-08-15 00:57:32 +02:00
Max Kellermann
02325d2ede decoder/fluidsynth: add "soundfont" setting
Replaces the old global "soundfont" which never worked.
2012-08-15 00:51:45 +02:00
Max Kellermann
9c83464b95 configure.ac: auto-detect libfluidsynth
Now that the libfluidsynth API was sanitized, we can enable the plugin
automatically if libfluidsynth is installed.
2012-08-15 00:48:52 +02:00
Max Kellermann
b1bbd70f0f decoder/fluidsynth: stop playback at end of file
Use libfluidsynth's new function fluid_player_get_status().
2012-08-15 00:47:10 +02:00
Max Kellermann
c31d11bfe0 decoder/fluidsynth: don't duplicate path
The libfluidsynth now accepts const strings.
2012-08-15 00:39:22 +02:00
Max Kellermann
c8ec85d649 decoder/fluidsynth: check if file is really a MIDI
Use fluid_is_midifile() to verify the file format.
2012-08-15 00:36:04 +02:00
Max Kellermann
e291f3d257 decoder/fluidsynth: remove throttle (requires libfluidsynth 1.1)
The libfluidsynth API is now sane, and does not require real-time
decoding.
2012-08-15 00:29:38 +02:00
Max Kellermann
7d27d2ea5e Merge branch 'v0.17.x' 2012-08-14 23:58:54 +02:00
Max Kellermann
dc22846d58 log: store duplicated path string
Don't free the string right after calling log_init_file().  Add a new
function log_deinit() that frees the string on shutdown.

This fixes cycling the log file after SIGHUP (Mantis ticket 0003524).
2012-08-14 23:16:46 +02:00
Max Kellermann
c9aaabb5d4 output/jack: implement method delay()
Eliminate the g_usleep() call.
2012-08-14 22:47:25 +02:00
Max Kellermann
335d5d5d72 output/pulse: implement method delay()
Reduce command latency while paused.
2012-08-14 22:30:46 +02:00
Max Kellermann
51d793bec1 output/pulse: simplify _wait_stream()
One large loop and only one pa_stream_get_state() call.
2012-08-14 22:22:55 +02:00
Max Kellermann
249dcd967e output/httpd: move delay from _pause() to _delay() 2012-08-14 21:54:47 +02:00
Max Kellermann
302972e9fc output/httpd: fix throttling bug after resuming playback
Reset the timer when paused and no client is connected.

This fixes Mantis ticket 0003527.
2012-08-14 21:39:33 +02:00
Max Kellermann
31b380b266 output/httpd: move code to _has_clients() 2012-08-14 20:22:32 +02:00
Max Kellermann
a869dfea85 timer: use monotonic clock if available 2012-08-14 19:07:31 +02:00
Max Kellermann
12838c6294 input/ffmpeg: remove fallback AV_VERSION_INT definition
This is part of libavutil.
2012-08-14 19:07:27 +02:00
Wieland Hoffmann
49c7102547 mpd.conf(5): Document the existence of musicbrainz_ tags
Additionally, update mpdconf.example to refer to mpd.conf(5) for the
complete list of tags instead of trying to repeat it.
2012-08-14 09:43:18 +02:00
Max Kellermann
5cc3338267 Merge branch 'v0.17.x'
Conflicts:
	src/mapper.h
2012-08-14 02:39:03 +02:00
Max Kellermann
1ae8972859 mapper: fix non-UTF8 music directory name
Duplicate the music_dir variable: one encoded in UTF-8, and another
one using the configured filesystem character set.  This fixes an
ancient MPD bug.
2012-08-14 02:28:04 +02:00
Max Kellermann
adcd2c8eac playlist_song: use map_to_relative_path() 2012-08-14 02:25:19 +02:00
Max Kellermann
45ff355835 playlist_song: improve const-correctness 2012-08-14 02:24:16 +02:00
Max Kellermann
f8bf3afeae playlist_song: move code to playlist_check_load_song() 2012-08-14 02:17:25 +02:00
Max Kellermann
f703da1516 valgrind.suppressions: suppressions for GStaticMutex and more 2012-08-14 01:58:17 +02:00
Max Kellermann
a582deee2c input_stream, main: remove obsolete GLib version checks
MPD requires GLib 2.16.
2012-08-14 01:57:53 +02:00
Max Kellermann
3047bdf653 Merge branch 'v0.17.x'
Conflicts:
	NEWS
	configure.ac
	src/client_file.h
2012-08-13 07:59:19 +02:00
Anton Khirnov
12be9e818f client_file: remove pure attribute from client_allow_file().
That function is not pure, it writes to error.

When marked as pure, the compiler is allowed to assume it does not do
anything to error, so it can remain NULL, which would result in an
invalid read in print_error().
2012-08-13 07:55:40 +02:00
Max Kellermann
a0478f98af Directory: move code to directory_allocate() 2012-08-09 21:04:07 +02:00
Max Kellermann
5e2c62db2f valgrind.suppressions: suppressions for GStaticMutex and more 2012-08-09 20:59:48 +02:00
Max Kellermann
d488d796f4 player_control: add GError attribute
Rewrite of the pc_get_error_message() function, now using a GError
object instead of the complicated "errored_song" attribute.
2012-08-08 22:54:49 +02:00
Max Kellermann
f794b1e1aa output_all: add basic GError support 2012-08-08 22:48:59 +02:00
Max Kellermann
8c425c758c decoder_control: add GError attribute 2012-08-08 22:38:16 +02:00
Max Kellermann
0b9e912297 player_control: rename attribute "error" to "error_type" 2012-08-08 22:29:09 +02:00
Max Kellermann
d35d2b269f player_control: rename player_error enum values 2012-08-08 22:28:59 +02:00
Max Kellermann
fa84ed412d player_control: remove unused enum player_error values 2012-08-08 22:28:49 +02:00
Max Kellermann
16951099d1 player_control: inline trivial functions 2012-08-08 22:27:00 +02:00
Max Kellermann
050ba302cb song: use C++ compiler 2012-08-08 21:08:37 +02:00
Max Kellermann
c1f90a99f4 tag_pool: use GStaticMutex
Eliminates explicit global initialisation.
2012-08-08 21:01:25 +02:00
Max Kellermann
510097cc37 song: include cleanup 2012-08-08 20:14:24 +02:00
Max Kellermann
6a83721c55 directory: use gcc.h macros, not GLib 2012-08-08 20:07:47 +02:00
Max Kellermann
ca9795c30a conf: add a "database" block
The new block overrides the "db_file" setting, and allows configuring
any database plugin.
2012-08-08 09:28:13 +02:00
Max Kellermann
dc2fa246a9 DatabaseGlue: look up the database plugin
No more hard-coded "simple" plugin.
2012-08-08 09:28:13 +02:00
Max Kellermann
b46bb611b3 DatabaseGlue: pass block to db_init()
Let the caller take care for legacy conversion.
2012-08-08 09:28:13 +02:00
Max Kellermann
aa55d759f5 DatabaseGlue: add function db_is_simple()
Preparing for non-"simple" database plugins.
2012-08-08 09:28:13 +02:00
Max Kellermann
2043579f71 main: don't call db_init() without database
Useless call.
2012-08-08 09:28:13 +02:00
Max Kellermann
346e31efa0 ProxyDatabasePlugin: obey the "recursive" flag 2012-08-08 09:28:13 +02:00
Max Kellermann
b504d63117 ProxyDatabasePlugin: use an artificial "root" directory
Fixes assertion failures in the Directory library.
2012-08-08 09:27:42 +02:00
Max Kellermann
b4b1728b6f DatabasePrint: don't print Last-Modified if unknown 2012-08-08 09:27:42 +02:00
Max Kellermann
21792386d8 time_print: new library, function time_print()
Implements error checking for the gmtime_r() call, which was missing
in two code locations.
2012-08-08 09:27:12 +02:00
Max Kellermann
63a2ac21e1 ProxyDatabasePlugin: new database plugin using libmpdclient
Implementation incomplete, but sort-of-works.  DumpDatabase works, but
MPD is still hard-coded on the "simple" plugin.
2012-08-08 01:20:45 +02:00
Max Kellermann
c42b206292 DatabaseCommands: allow empty criteria for "list"
Fixes regression.
2012-08-08 01:16:47 +02:00
Max Kellermann
733d6a6b16 DatabaseSelection: add "match" attribute
Let the database plugin do the match.
2012-08-08 00:55:02 +02:00
Max Kellermann
8d2725234e DatabaseCommands: merge duplicate search/find code 2012-08-08 00:49:07 +02:00
Max Kellermann
0823711106 locate: add a per-item "fold_case" flag
Merge locate_song_search() and locate_song_match().
2012-08-08 00:47:45 +02:00
Max Kellermann
860e9eb8c9 locate: make "tag" unsigned 2012-08-08 00:45:46 +02:00
Max Kellermann
3d2092ee23 locate: make the structs opaque 2012-08-07 23:52:11 +02:00
Max Kellermann
8855efebc0 locate: don't allow empty list 2012-08-07 23:45:00 +02:00
Max Kellermann
7725577a53 locate: pass unsigned integer to _parse() 2012-08-07 23:44:43 +02:00
Max Kellermann
668e3f664f locate: add "pure" attributes 2012-08-07 23:43:36 +02:00
Max Kellermann
9e51733c71 DatabaseCommands: remove stray locate_item_list_parse() call 2012-08-07 23:41:35 +02:00
Max Kellermann
6b39a5621d locate: add "casefold" flag to parser
Fold the case during construction, without having to create another
copy.
2012-08-07 23:27:23 +02:00
Max Kellermann
0d46e11826 locate: remove unused function locate_item_free() 2012-08-07 23:27:08 +02:00
Max Kellermann
ff58207034 db_selection: rename to DatabaseSelection 2012-08-07 23:12:26 +02:00
Max Kellermann
b3d76b7e5c db_print.h: rename to DatabasePrint.hxx 2012-08-07 23:10:34 +02:00
Max Kellermann
4d6c816abb dbUtils.h: move to DatabaseQueue.hxx, DatabasePlaylist.hxx 2012-08-07 22:57:18 +02:00
Max Kellermann
f35ceaee0a command: move code to DatabaseCommands.cxx
Prepare to use the DatabasePlugin C++ API directly.
2012-08-07 22:36:18 +02:00
Max Kellermann
a64a2a65a9 command: move print_error() to CommandError.cxx
Prepare for splitting command.c.
2012-08-07 22:26:14 +02:00
Max Kellermann
1a75abffa5 Database{Plugin,Visitor}: pass references 2012-08-07 21:32:08 +02:00
Max Kellermann
c6a0f5d3f9 test/DumpDatabase: new debug program 2012-08-07 20:21:10 +02:00
Max Kellermann
bb75e3ea55 DatabaseRegistry: list of plugins 2012-08-07 20:07:17 +02:00
Max Kellermann
814eebf976 configure.ac: copy missing file m4/ax_check_link_flag.m4
Needed by ax_append_link_flags.m4.
2012-08-03 14:40:04 +02:00
Max Kellermann
e08d4f28aa Makefile.am: add libdb_plugins.a 2012-08-02 19:25:18 +02:00
Max Kellermann
6f3c65dc64 DatabaseGlue: remove db_walk(), db_visit()
Unused.
2012-08-02 19:15:01 +02:00
Max Kellermann
0a3ada4fea stats: convert to C++ 2012-08-02 19:14:53 +02:00
Max Kellermann
8bdf7917c4 db_print: convert to C++ 2012-08-02 19:14:40 +02:00
Max Kellermann
67d16a086e dbUtils: split to Database{Queue,Playlist}.cxx 2012-08-02 19:14:09 +02:00
Max Kellermann
b8018f12ba DatabaseGlue: add function GetDatabase()
Allow using the object outside of DatabaseGlue.cxx.
2012-08-02 19:13:58 +02:00
Max Kellermann
607780b7f9 DatabasePlugin: add simpler Visit() wrapepr 2012-08-02 19:12:42 +02:00
Max Kellermann
af1c497759 DatabasePlugin: make Visit() const 2012-08-02 19:12:27 +02:00
Max Kellermann
8e331cfc65 gcc.h: re-add gcc_const and gcc_pure
Remove GLib dependency from some headers.
2012-08-02 19:12:18 +02:00
Max Kellermann
edf811fa02 DatabaseVisitor, ...: use GError forward declaration 2012-08-02 19:12:06 +02:00
Max Kellermann
b25b7693ba configure.ac: enable --gc-sections
Produce a smaller binary by removing all unused functions.
2012-08-02 19:09:29 +02:00
Max Kellermann
9dc9459f3a db_plugin: convert to C++ 2012-08-01 09:59:12 +02:00
Max Kellermann
37b92967c5 gcc.h: require g++ 4.5 or newer
Soon we'll use C++11 lambdas which were implemented in gcc 4.5.
2012-08-01 09:59:12 +02:00
Max Kellermann
768504e956 configure.ac: enable C++ warnings 2012-08-01 09:59:12 +02:00
Max Kellermann
2571accfc3 configure.ac: require C++11 compiler
We'll add some C++11 code soon.
2012-08-01 09:59:12 +02:00
Max Kellermann
0d2abdb5d9 gcc.h: add fallback for C++11 "override" 2012-08-01 09:59:12 +02:00
Max Kellermann
79200a8611 decoder/sidplay: fix C++ compiler warnings 2012-08-01 09:59:12 +02:00
Max Kellermann
123ae985d5 util/list: make safe for C++ 2012-08-01 09:59:12 +02:00
Max Kellermann
659d1c7cf7 Modify version string to post-release version 0.18~git 2012-08-01 09:58:42 +02:00
Avuton Olrich
281cd7c057 Modify version string to post-release version 0.17.2~git 2012-07-31 19:05:52 -07:00
1015 changed files with 69550 additions and 57880 deletions

18
.gitignore vendored
View File

@@ -1,12 +1,11 @@
*.Plo
*.Po
*.a
*.bz2
*.d
*.gz
*.la
*.lo
*.o
*.exe
.deps
.dirstamp
Makefile
@@ -32,8 +31,8 @@ libtool
ltmain.sh
missing
mkinstalldirs
/test-driver
mpd
mpd.exe
mpd.service
stamp-h1
tags
@@ -41,6 +40,7 @@ tags
.#*
.stgit*
src/dsd2pcm/dsd2pcm
src/win/mpd_win32_rc.rc
doc/doxygen.conf
doc/protocol.html
doc/protocol
@@ -67,3 +67,15 @@ test/run_ntp_server
test/run_resolver
test/run_tcp_connect
test/test_pcm
test/dump_rva2
test/dump_text_file
test/test_util
test/test_byte_reverse
test/test_mixramp
test/test_vorbis_encoder
test/DumpDatabase
/*.tar.gz
/*.tar.bz2
/*.tar.xz
/mpd-*/

94
AUTHORS
View File

@@ -1,67 +1,31 @@
Current Developers
------------------
Music Player Daemon - http://www.musicpd.org
Copyright (C) 2003-2013 The Music Player Daemon Project
Avuton Olrich <avuton@gmail.com>
release manager
The following people have contributed code to MPD:
Max Kellermann <max@duempel.org>
lead developer
Laszlo Ashin <kodest@gmail.com>
WavPack support
Viliam Mateicka <viliam.mateicka@gmail.com>
FFmpeg support, mixer and archive API
Eric Wollesen <encoded@xmtp.net>
encoder API, shout output
Thomas Jansen <mithi@mithi.net>
multithreading tweaks, miscellaneous
Romain Bignon <romain@peerfuse.org>
playlist manipulation
David Guibert <david.guibert@gmail.com>
PulseAudio mixer
Jochen Keil <jochen.keil@gmail.com>
CUE sheet support
Jeffrey Middleton <jefromi@gmail.com>
playlist manipulation
Sean McNamara <smcnam@gmail.com>
WIN32 compatibility
Former Developers
-----------------
Warren Dukes <warren.dukes@gmail.com>
former lead developer and project founder
Niklas Hofer
'next' and 'previous' patch
Jim Ramsay <i.am@jimramsay.com>
Zerconf/avahi support
Guus Sliepen <guus@sliepen.eu.org>
libsamplerate code
J. Alexander Treuman <jat@spatialrift.net>
general, MP3, ID3, PulseAudio, format conversion, stored playlists
AudioCompress, much much more...
Eric Wong
former lead developer
José Anarch <anarchsss@gmail.com>
JACK plugin
Patrik Weiskircher <pat@icore.at>
Stored playlist commands
Nick Welch <mack@incise.org>
Sighandlers
Warren Dukes <warren.dukes@gmail.com>
Avuton Olrich <avuton@gmail.com>
Max Kellermann <max@duempel.org>
Laszlo Ashin <kodest@gmail.com>
Viliam Mateicka <viliam.mateicka@gmail.com>
Eric Wollesen <encoded@xmtp.net>
Thomas Jansen <mithi@mithi.net>
Romain Bignon <romain@peerfuse.org>
David Guibert <david.guibert@gmail.com>
Jochen Keil <jochen.keil@gmail.com>
Jeffrey Middleton <jefromi@gmail.com>
Sean McNamara <smcnam@gmail.com>
Niklas Hofer
Jim Ramsay <i.am@jimramsay.com>
Guus Sliepen <guus@sliepen.eu.org>
J. Alexander Treuman <jat@spatialrift.net>
Eric Wong
José Anarch <anarchsss@gmail.com>
Patrik Weiskircher <pat@icore.at>
Nick Welch <mack@incise.org>
Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Anton Khirnov <anton@khirnov.net>
Simon Kagstrom <simon.kagstrom@gmail.com>
Denis Krjuchkov <denis@crazydev.net>
Jurgen Kramer <gtmkramer@xs4all.nl>
Jean-Francois Dockes <jf@dockes.org>

53
INSTALL
View File

@@ -3,17 +3,20 @@
Introduction
------------
This document is a very small amount of documentation about what is needed to
install MPD. If more information is desired see the community wiki at
http://mpd.wikia.com.
install MPD. If more information is desired, read the user manual:
http://www.musicpd.org/doc/user/
Dependencies
------------
gcc - http://gcc.gnu.org/
Any other C99 compliant compiler should also work.
gcc 4.6 or later - http://gcc.gnu.org/
clang 3.2 or later - http://clang.llvm.org/
Any other C++11 compliant compiler should also work.
GLib 2.16 - http://www.gtk.org/
GLib 2.28 - http://www.gtk.org/
General-purpose utility library.
@@ -37,15 +40,9 @@ Linux. You will need libasound.
FIFO
This is a mostly undocumented, developer plugin to transmit raw data.
MVP - http://en.wikipedia.org/wiki/Hauppauge_MediaMVP
A network media player.
OSS - http://www.opensound.com
Open Sound System.
OSX - http://www.apple.com
Necessary if you are on Mac OSX.
PulseAudio - http://www.pulseaudio.org/
An advanced sound daemon. You will need libpulse.
@@ -59,9 +56,6 @@ You also need an encoder: either libvorbisenc (ogg), or liblame (mp3).
OpenAL - http://kcat.strangesoft.net/openal.html
Open Audio Library
libffado - http://www.ffado.org/
For FireWire audio devices.
Optional Input Dependencies
---------------------------
@@ -81,14 +75,17 @@ Alternative for MP3 support.
Ogg Vorbis - http://www.xiph.org/ogg/vorbis/
For Ogg Vorbis support. You will need libogg and libvorbis.
libopus - http://www.opus-codec.org/
Opus codec support
FLAC - http://flac.sourceforge.net/
For FLAC support. You will need version 1.1.0 or higher of libflac.
For FLAC support. You will need version 1.2 or higher of libFLAC.
Audio File - http://www.68k.org/~michael/audiofile/
For WAVE, AIFF, and AU support. You will need libaudiofile.
FAAD2 - http://www.audiocoding.com/
For MP4/AAC support. You will need libmp4ff.
For MP4/AAC support.
libmpcdec - http://www.musepack.net/
For Musepack support.
@@ -103,9 +100,9 @@ libsidplay2 - http://sidplay2.sourceforge.net/
For C64 SID support.
libfluidsynth - http://fluidsynth.resonance.org/
For MIDI support (DO NOT USE - use libwildmidi instead)
For MIDI support.
libwildmidi - http://wildmidi.sourceforge.net/
libwildmidi 0.2.3 - http://wildmidi.sourceforge.net/
For MIDI support.
libsndfile - http://www.mega-nerd.com/libsndfile/
@@ -114,6 +111,9 @@ WAVE, AIFF, and many others.
libwavpack - http://www.wavpack.com/
For WavPack playback.
libadplug - http://adplug.sourceforge.net/
For AdLib playback.
despotify - https://github.com/SimonKagstrom/despotify
For Spotify playback.
@@ -163,13 +163,9 @@ Get the latest release from of MPD from <http://www.musicpd.org/>.
Compile
-------
1) unzip and untar the archive
1) unpack the archive
$ tar zxvf mpd-x.x.x.tar.gz
or
$ tar jxvf mpd-x.x.x.tar.bz2
$ tar xf mpd-x.x.x.tar.xz
2) change to directory created
@@ -196,9 +192,9 @@ Run
$ mpd <config file>
First default is ~/.mpdconf then ~/.mpd/mpd.conf then /etc/mpd.conf. If
neither of these exist a mpd configuration file must be specified at
runtime.
First default is $XDG_CONFIG_HOME/mpd/mpd.conf then ~/.mpdconf then
~/.mpd/mpd.conf then /etc/mpd.conf. If neither of these exist a mpd
configuration file must be specified at runtime.
A sample config file is included with the source of MPD, mpdconf.example.
@@ -210,6 +206,5 @@ Using MPD
---------
You can download many different interfaces for MPD at
<http://mpd.wikia.com/wiki/Clients>
MPD can be interfaced directly using telnet (see COMMANDS, if you are brave).
http://www.musicpd.org/clients/

File diff suppressed because it is too large Load Diff

224
NEWS
View File

@@ -1,3 +1,227 @@
ver 0.18.11 (2014/05/12)
* decoder
- opus: fix missing song length on high-latency files
* fix race condition when using GLib event loop (non-Linux)
ver 0.18.10 (2014/04/10)
* decoder
- ffmpeg: fix seeking bug
- ffmpeg: handle unknown stream start time
- gme: fix memory leak
- sndfile: work around libsndfile bug on partial read
* don't interrupt playback when current song gets deleted
ver 0.18.9 (2014/03/02)
* protocol
- "findadd" requires the "add" permission
* output
- alsa: improved workaround for noise after manual song change
* decoder
- vorbis: fix linker failure when libvorbis/libogg are static
* encoder
- vorbis: fix another linker failure
* output
- pipe: fix hanging child process due to blocked signals
* fix build failure due to missing signal.h include
ver 0.18.8 (2014/02/07)
* decoder
- ffmpeg: support libav v10_alpha1
* encoder
- vorbis: fix linker failure
* output
- roar: documentation
* more robust Icy-Metadata parser
* fix Solaris build failure
ver 0.18.7 (2014/01/13)
* playlist
- pls: fix crash after parser error
- soundcloud: fix build failure with libyajl 2.0.1
* decoder
- faad: fix memory leak
- mpcdec: reject libmpcdec SV7 in configure script
* daemon: don't initialize supplementary groups when already running
as the configured user
ver 0.18.6 (2013/12/24)
* input
- cdio_paranoia: support libcdio-paranoia 0.90
* tags
- riff: recognize upper-case "ID3" chunk name
* decoder
- ffmpeg: use relative timestamps
* output
- openal: fix build failure on Mac OS X
- osx: fix build failure
* mixer
- alsa: fix build failure with uClibc
* fix replay gain during cross-fade
* accept files without metadata
ver 0.18.5 (2013/11/23)
* configuration
- fix crash when db_file is configured without music_directory
- fix crash on "stats" without db_file/music_directory
* database
- proxy: auto-reload statistics
- proxy: provide "db_update" in "stats" response
* input
- curl: work around stream resume bug (fixed in libcurl 7.32.0)
* decoder
- fluidsynth: auto-detect by default
* clip 24 bit data from libsamplerate
* fix ia64, mipsel and other little-endian architectures
* fix build failures due to missing includes
* fix build failure with static libmpdclient
ver 0.18.4 (2013/11/13)
* decoder
- dsdiff: fix byte order bug
* fix build failures due to missing includes
* libc++ compatibility
ver 0.18.3 (2013/11/08)
* fix stuck MPD after song change (0.18.2 regression)
ver 0.18.2 (2013/11/07)
* protocol:
- "close" flushes the output buffer
* input:
- cdio_paranoia: add setting "default_byte_order"
- curl: fix bug with redirected streams
* playlist:
- pls: fix reversed song order
* decoder:
- audiofile: require libaudiofile 0.3 due to API breakage
- dsf: enable DSD128
* enable buffering when starting playback (regression fix)
* fix build failures due to missing includes
* fix big-endian support
ver 0.18.1 (2013/11/04)
* protocol:
- always ignore whitespace at the end of the line
* networking:
- log UNIX domain path names instead of "localhost"
- open listener sockets in the order they were configured
- don't abort if IPv6 is not available
* output:
- alsa: avoid endless loop in Raspberry Pi workaround
* filter:
- autoconvert: fix "volume_normalization" with mp3 files
* add missing files to source tarball
ver 0.18 (2013/10/31)
* configuration:
- allow tilde paths for socket
- default filesystem charset is UTF-8 instead of ISO-8859-1
- increase default buffer size to 4 MB
* protocol:
- new command "readcomments" lists arbitrary file tags
- new command "toggleoutput"
- "find"/"search" with "any" does not match file name
- "search" and "find" with base URI (keyword "base")
- search for album artist falls back to the artist tag
- re-add the "volume" command
* input:
- curl: enable https
- soup: plugin removed
* playlist:
- lastfm: remove defunct Last.fm support
* decoder:
- adplug: new decoder plugin using libadplug
- dsf: don't play junk at the end of the "data" chunk
- ffmpeg: drop support for pre-0.8 ffmpeg
- flac: require libFLAC 1.2 or newer
- flac: support FLAC files inside archives
- opus: new decoder plugin for the Opus codec
- vorbis: skip 16 bit quantisation, provide float samples
- mikmod: add "loop" configuration parameter
- modplug: add "loop_count" configuration parameter
- mp4ff: obsolete plugin removed
* encoder:
- opus: new encoder plugin for the Opus codec
- vorbis: accept floating point input samples
* output:
- new option "tags" may be used to disable sending tags to output
- alsa: workaround for noise after manual song change
- ffado: remove broken plugin
- httpd: support HEAD requests
- mvp: remove obsolete plugin
- osx: disabled by default because it's unmaintained and unsupported
* improved decoder/output error reporting
* eliminate timer wakeup on idle MPD
* fix unresponsive MPD while waiting for stream
* port of the source code to C++11
ver 0.17.6 (2013/10/14)
* mixer:
- alsa: fix busy loop when USB sound device gets unplugged
* decoder:
- modplug: fix build with Debian package 1:0.8.8.4-4
* stored playlists:
- fix loading playlists with references to local files
- obey filesystem_charset for URLs
ver 0.17.5 (2013/08/04)
* protocol:
- fix "playlistadd" with URI
- fix "move" relative to current when there is no current song
* decoder:
- ffmpeg: support "application/flv"
- mikmod: adapt to libmikmod 3.2
* configure.ac:
- detect system "ar"
ver 0.17.4 (2013/04/08)
* protocol:
- allow to omit END in ranges (START:END)
- don't emit IDLE_PLAYER before audio format is known
* decoder:
- ffmpeg: support float planar audio (ffmpeg 1.1)
- ffmpeg: fix AVFrame allocation
* player:
- implement missing "idle" events on output errors
* clock: fix build failure
ver 0.17.3 (2013/01/06)
* output:
- osx: fix pops during playback
- recorder: fix I/O error check
- shout: fix memory leak in error handler
- recorder, shout: support Ogg packets that span more than one page
* decoder:
- ffmpeg: ignore negative time stamps
- ffmpeg: support planar audio
* playlist:
- cue: fix memory leak
- cue: fix CUE files with only one track
ver 0.17.2 (2012/09/30)
* protocol:
- fix crash in local file check
* decoder:
- fluidsynth: remove throttle (requires libfluidsynth 1.1)
- fluidsynth: stop playback at end of file
- fluidsynth: check MIDI file format while scanning
- fluidsynth: add sample rate setting
- wavpack: support all APEv2 tags
* output:
- httpd: use monotonic clock, avoid hiccups after system clock adjustment
- httpd: fix throttling bug after resuming playback
* playlist:
- cue: map "PERFORMER" to "artist" or "album artist"
* mapper: fix non-UTF8 music directory name
* mapper: fix potential crash in file permission check
* playlist: fix use-after-free bug
* playlist: fix memory leak
* state_file: save song priorities
* player: disable cross-fading in "single" mode
* update: fix unsafe readlink() usage
* configure.ac:
- don't auto-detect the vorbis encoder when Tremor is enabled
ver 0.17.1 (2012/07/31)
* protocol:
- require appropriate permissions for searchadd{,pl}

View File

@@ -1,19 +1,19 @@
AC_PREREQ(2.60)
AC_INIT(mpd, 0.17.1, musicpd-dev-team@lists.sourceforge.net)
AC_INIT(mpd, 0.18.11, mpd-devel@musicpd.org)
VERSION_MAJOR=0
VERSION_MINOR=17
VERSION_MINOR=18
VERSION_REVISION=0
VERSION_EXTRA=0
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign 1.11 dist-bzip2 subdir-objects])
AC_CONFIG_SRCDIR([src/Main.cxx])
AM_INIT_AUTOMAKE([foreign 1.11 dist-xz subdir-objects])
AM_SILENT_RULES
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
AC_DEFINE(PROTOCOL_VERSION, "0.17.0", [The MPD protocol version])
AC_DEFINE(PROTOCOL_VERSION, "0.18.0", [The MPD protocol version])
dnl ---------------------------------------------------------------------------
@@ -23,21 +23,10 @@ AC_PROG_CC_C99
AC_PROG_CXX
AC_PROG_RANLIB
HAVE_CXX=yes
if test x$CXX = xg++; then
# CXX=g++ probably means that autoconf hasn't found any C++
# compiler; to be sure, we check again
AC_PATH_PROG(CXX, $CXX, no)
if test x$CXX = xno; then
# no, we don't have C++ - the following hack is
# required because automake insists on using $(CXX)
# for linking the MPD binary
AC_MSG_NOTICE([Disabling C++ support])
CXX="$CC"
HAVE_CXX=no
fi
fi
AM_CONDITIONAL(HAVE_CXX, test x$HAVE_CXX = xyes)
AN_MAKEVAR([AR], [AC_PROG_AR])
AN_PROGRAM([ar], [AC_PROG_AR])
AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
AC_PROG_AR
AC_PROG_INSTALL
AC_PROG_MAKE_SET
@@ -76,16 +65,23 @@ dnl OS Specific Defaults
dnl ---------------------------------------------------------------------------
AC_CANONICAL_HOST
host_is_darwin=no
case "$host_os" in
mingw32* | windows*)
AC_CONFIG_FILES([
src/win/mpd_win32_rc.rc
])
AC_CHECK_TOOL(WINDRES, windres)
AM_CPPFLAGS="$AM_CPPFLAGS -DWINVER=0x0501"
AM_CPPFLAGS="$AM_CPPFLAGS -DWIN32_LEAN_AND_MEAN"
AM_CPPFLAGS="$AM_CPPFLAGS -DWINVER=0x0600 -D_WIN32_WINNT=0x0600"
LIBS="$LIBS -lws2_32"
HAVE_WINDOWS=1
;;
darwin*)
host_is_darwin=yes
;;
esac
AM_CONDITIONAL([HAVE_WINDOWS], [test x$HAVE_WINDOWS = x1])
@@ -125,6 +121,19 @@ if test -z "$prefix" || test "x$prefix" = xNONE; then
done
fi
dnl ---------------------------------------------------------------------------
dnl Language Checks
dnl ---------------------------------------------------------------------------
AC_CXX_COMPILE_STDCXX_0X
if test "$ax_cv_cxx_compile_cxx0x_native" != yes; then
if test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
AM_CXXFLAGS="$AM_CXXFLAGS -std=gnu++0x"
elif test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then
AM_CXXFLAGS="$AM_CXXFLAGS -std=c++0x"
fi
fi
dnl ---------------------------------------------------------------------------
dnl Header/Library Checks
dnl ---------------------------------------------------------------------------
@@ -137,6 +146,9 @@ AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_CHECK_FUNCS(pipe2 accept4)
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
MPD_OPTIONAL_FUNC(signalfd, signalfd, USE_SIGNALFD)
MPD_OPTIONAL_FUNC(epoll, epoll_create1, USE_EPOLL)
AC_SEARCH_LIBS([exp], [m],,
[AC_MSG_ERROR([exp() not found])])
@@ -147,6 +159,17 @@ AC_CHECK_HEADERS(valgrind/memcheck.h)
dnl ---------------------------------------------------------------------------
dnl Allow tools to be specifically built
dnl ---------------------------------------------------------------------------
AC_ARG_ENABLE(libmpdclient,
AS_HELP_STRING([--enable-libmpdclient],
[enable support for the MPD client]),,
enable_libmpdclient=auto)
AC_ARG_ENABLE(adplug,
AS_HELP_STRING([--enable-adplug],
[enable the AdPlug decoder plugin (default: auto)]),,
enable_adplug=auto)
AC_ARG_ENABLE(alsa,
AS_HELP_STRING([--enable-alsa], [enable ALSA support]),,
[enable_alsa=auto])
@@ -168,8 +191,8 @@ AC_ARG_ENABLE(audiofile,
AC_ARG_ENABLE(bzip2,
AS_HELP_STRING([--enable-bzip2],
[enable bzip2 archive support (default: disabled)]),,
enable_bzip2=no)
[enable bzip2 archive support (default: auto)]),,
enable_bzip2=auto)
AC_ARG_ENABLE(cdio-paranoia,
AS_HELP_STRING([--enable-cdio-paranoia],
@@ -181,11 +204,6 @@ AC_ARG_ENABLE(curl,
[enable support for libcurl HTTP streaming (default: auto)]),,
[enable_curl=auto])
AC_ARG_ENABLE(soup,
AS_HELP_STRING([--enable-soup],
[enable support for libsoup HTTP streaming (default: auto)]),,
[enable_soup=auto])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[enable debugging (default: disabled)]),,
@@ -196,10 +214,6 @@ AC_ARG_ENABLE(documentation,
[build documentation (default: disable)]),,
[enable_documentation=no])
AC_ARG_ENABLE(ffado,
AS_HELP_STRING([--enable-ffado], [enable libffado (FireWire) support]),,
[enable_ffado=no])
AC_ARG_ENABLE(ffmpeg,
AS_HELP_STRING([--enable-ffmpeg],
[enable FFMPEG support]),,
@@ -217,8 +231,8 @@ AC_ARG_ENABLE(flac,
AC_ARG_ENABLE(fluidsynth,
AS_HELP_STRING([--enable-fluidsynth],
[enable MIDI support via fluidsynth (default: disable)]),,
enable_fluidsynth=no)
[enable MIDI support via fluidsynth (default: auto)]),,
enable_fluidsynth=auto)
AC_ARG_ENABLE(gme,
AS_HELP_STRING([--enable-gme],
@@ -257,11 +271,6 @@ AC_ARG_ENABLE(jack,
AC_SYS_LARGEFILE
AC_ARG_ENABLE(lastfm,
AS_HELP_STRING([--enable-lastfm],
[enable support for last.fm radio (default: disable)]),,
[enable_lastfm=no])
AC_ARG_ENABLE(despotify,
AS_HELP_STRING([--enable-despotify],
[enable support for despotify (default: disable)]),,
@@ -307,30 +316,35 @@ AC_ARG_ENABLE(modplug,
enable_modplug=auto)
AC_ARG_ENABLE(mpc,
AS_HELP_STRING([--disable-mpc],
[disable musepack (MPC) support (default: enable)]),,
enable_mpc=yes)
AS_HELP_STRING([--enable-mpc],
[disable musepack (MPC) support (default: auto)]),,
enable_mpc=auto)
AC_ARG_ENABLE(mpg123,
AS_HELP_STRING([--enable-mpg123],
[enable libmpg123 decoder plugin]),,
enable_mpg123=auto)
AC_ARG_ENABLE(mvp,
AS_HELP_STRING([--enable-mvp],
[enable support for Hauppauge Media MVP (default: disable)]),,
enable_mvp=no)
AC_ARG_ENABLE(openal,
AS_HELP_STRING([--enable-openal],
[enable OpenAL support (default: disable)]),,
enable_openal=no)
[enable OpenAL support (default: auto)]),,
enable_openal=auto)
AC_ARG_ENABLE(opus,
AS_HELP_STRING([--enable-opus],
[enable Opus codec support (default: auto)]),,
enable_opus=auto)
AC_ARG_ENABLE(oss,
AS_HELP_STRING([--disable-oss],
[disable OSS support (default: enable)]),,
enable_oss=yes)
AC_ARG_ENABLE(osx,
AS_HELP_STRING([--enable-osx],
[enable the OS X output plugin - unsupported! (default: disable)]),,
enable_osx=no)
AC_ARG_ENABLE(pipe-output,
AS_HELP_STRING([--enable-pipe-output],
[enable support for writing audio to a pipe (default: disable)]),,
@@ -429,8 +443,8 @@ AC_ARG_ENABLE(werror,
AC_ARG_ENABLE(wildmidi,
AS_HELP_STRING([--enable-wildmidi],
[enable MIDI support via wildmidi (default: disable)]),,
enable_wildmidi=no)
[enable MIDI support via wildmidi (default: auto)]),,
enable_wildmidi=auto)
AC_ARG_WITH(zeroconf,
AS_HELP_STRING([--with-zeroconf=@<:@auto|avahi|bonjour|no@:>@],
@@ -456,8 +470,8 @@ AC_ARG_WITH(tremor-includes,
dnl ---------------------------------------------------------------------------
dnl Mandatory Libraries
dnl ---------------------------------------------------------------------------
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.16 gthread-2.0],,
[AC_MSG_ERROR([GLib 2.16 is required])])
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.28 gthread-2.0],,
[AC_MSG_ERROR([GLib 2.28 is required])])
if test x$GCC = xyes; then
# suppress warnings in the GLib headers
@@ -537,6 +551,15 @@ dnl ---------------------------------------------------------------------------
dnl Miscellaneous Libraries
dnl ---------------------------------------------------------------------------
dnl -------------------------------- libmpdclient --------------------------------
MPD_AUTO_PKG(libmpdclient, LIBMPDCLIENT, [libmpdclient >= 2.2],
[MPD client library], [libmpdclient not found])
if test x$enable_libmpdclient = xyes; then
AC_DEFINE(HAVE_LIBMPDCLIENT, 1, [Define to use libmpdclient])
fi
AM_CONDITIONAL(HAVE_LIBMPDCLIENT, test x$enable_libmpdclient = xyes)
dnl --------------------------------- inotify ---------------------------------
AC_CHECK_FUNCS(inotify_init inotify_init1)
@@ -552,6 +575,27 @@ AM_CONDITIONAL(ENABLE_INOTIFY, test x$enable_inotify = xyes)
dnl --------------------------------- libwrap ---------------------------------
if test x$enable_libwrap != xno; then
AC_CHECK_LIBWRAP(found_libwrap=yes, found_libwrap=no)
if test x$found_libwrap = xyes; then
dnl See if libwrap is compatible with C++; it is
dnl broken on many systems
AC_MSG_CHECKING(whether libwrap is compatible with C++)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <tcpd.h>
bool CheckLibWrap(int fd, const char &progname) {
struct request_info req;
request_init(&req, RQ_FILE, fd, RQ_DAEMON, progname, 0);
fromhost(&req);
return hosts_access(&req);
}
])],
AC_MSG_RESULT([yes]),
[found_libwrap=no; AC_MSG_RESULT([no]);
AC_MSG_WARN([Your version of libwrap is broken with C++])])
AC_LANG_POP
fi
MPD_AUTO_RESULT(libwrap, libwrap, [libwrap not found])
fi
@@ -595,8 +639,8 @@ avahi)
;;
esac
MPD_AUTO_PKG(avahi, AVAHI, [avahi-client avahi-glib],
[avahi client library], [avahi client+glib not found])
MPD_AUTO_PKG(avahi, AVAHI, [avahi-client],
[avahi client library], [avahi-client not found])
if test x$enable_avahi = xyes; then
AC_DEFINE([HAVE_AVAHI], 1, [Define to enable Avahi Zeroconf support])
with_zeroconf=avahi
@@ -669,31 +713,13 @@ dnl Input Plugins
dnl ---------------------------------------------------------------------------
dnl ----------------------------------- CURL ----------------------------------
MPD_AUTO_PKG(curl, CURL, [libcurl],
MPD_AUTO_PKG(curl, CURL, [libcurl >= 7.18],
[libcurl HTTP streaming], [libcurl not found])
if test x$enable_curl = xyes; then
AC_DEFINE(ENABLE_CURL, 1, [Define when libcurl is used for HTTP streaming])
fi
AM_CONDITIONAL(ENABLE_CURL, test x$enable_curl = xyes)
dnl ----------------------------------- SOUP ----------------------------------
MPD_AUTO_PKG(soup, SOUP, [libsoup-2.4],
[libsoup HTTP streaming], [libsoup not found])
if test x$enable_soup = xyes; then
AC_DEFINE(ENABLE_SOUP, 1, [Define when libsoup is used for HTTP streaming])
fi
AM_CONDITIONAL(ENABLE_SOUP, test x$enable_soup = xyes)
dnl --------------------------------- Last.FM ---------------------------------
if test x$enable_lastfm = xyes; then
if test x$enable_curl != xyes; then
AC_MSG_ERROR([Cannot enable last.fm radio without curl])
fi
AC_DEFINE(ENABLE_LASTFM, 1, [Define when last.fm radio is enabled])
fi
AM_CONDITIONAL(ENABLE_LASTFM, test x$enable_lastfm = xyes)
dnl --------------------------------- Despotify ---------------------------------
MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify],
[Despotify support], [despotify not found])
@@ -706,7 +732,7 @@ dnl --------------------------------- Soundcloud ------------------------------
if test x$enable_soundcloud != xno; then
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
[found_soundcloud=yes],
AC_CHECK_LIB([yajl], [yajl_alloc],
AC_CHECK_LIB([yajl], [yajl_parse_complete],
[found_soundcloud=yes YAJL_CFLAGS=-DHAVE_YAJL1 YAJL_LIBS=-lyajl],
[found_soundcloud=no]))
fi
@@ -723,6 +749,7 @@ MPD_AUTO_PKG(cdio_paranoia, CDIO_PARANOIA, [libcdio_paranoia],
if test x$enable_cdio_paranoia = xyes; then
AC_DEFINE([ENABLE_CDIO_PARANOIA], 1,
[Define to enable libcdio_paranoia support])
AC_CHECK_HEADERS(cdio/paranoia/paranoia.h)
fi
AM_CONDITIONAL(ENABLE_CDIO_PARANOIA, test x$enable_cdio_paranoia = xyes)
@@ -756,12 +783,9 @@ fi
AM_CONDITIONAL(ENABLE_ISO9660_TEST, test x$MKISOFS != xno)
dnl ---------------------------------- libbz2 ---------------------------------
if test x$enable_bzip2 = xyes; then
AC_CHECK_LIB(bz2, BZ2_bzDecompressInit,
[BZ2_LIBS="-lbz2"],
[AC_MSG_ERROR([libbz2 not found])])
fi
AC_SUBST(BZ2_LIBS)
MPD_AUTO_LIB(bzip2, BZ2, bz2, BZ2_bzDecompressInit, [-lbz2], [],
[bzip2], [libbz2 not found])
AM_CONDITIONAL(HAVE_BZ2, test x$enable_bzip2 = xyes)
if test x$enable_bzip2 = xyes; then
@@ -806,8 +830,16 @@ dnl ---------------------------------------------------------------------------
dnl Decoder Plugins
dnl ---------------------------------------------------------------------------
dnl -------------------------------- libadplug --------------------------------
MPD_AUTO_PKG(adplug, ADPLUG, [adplug],
[AdPlug decoder plugin], [libadplug not found])
if test x$enable_adplug = xyes; then
AC_DEFINE(HAVE_ADPLUG, 1, [Define to use libadplug])
fi
AM_CONDITIONAL(HAVE_ADPLUG, test x$enable_adplug = xyes)
dnl -------------------------------- audiofile --------------------------------
MPD_AUTO_PKG(audiofile, AUDIOFILE, [audiofile >= 0.1.7],
MPD_AUTO_PKG(audiofile, AUDIOFILE, [audiofile >= 0.3],
[audiofile decoder plugin], [libaudiofile not found])
AM_CONDITIONAL(HAVE_AUDIOFILE, test x$enable_audiofile = xyes)
if test x$enable_audiofile = xyes; then
@@ -818,10 +850,9 @@ dnl ----------------------------------- FAAD ----------------------------------
AM_PATH_FAAD()
AM_CONDITIONAL(HAVE_FAAD, test x$enable_aac = xyes)
AM_CONDITIONAL(HAVE_MP4, test x$enable_mp4 = xyes)
dnl ---------------------------------- ffmpeg ---------------------------------
MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 52.31 libavcodec >= 52.20 libavutil >= 49.15],
MPD_AUTO_PKG(ffmpeg, FFMPEG, [libavformat >= 53.17 libavcodec >= 53.25 libavutil >= 51.17],
[ffmpeg decoder library], [libavformat+libavcodec+libavutil not found])
if test x$enable_ffmpeg = xyes; then
@@ -832,7 +863,7 @@ AM_CONDITIONAL(HAVE_FFMPEG, test x$enable_ffmpeg = xyes)
dnl ----------------------------------- FLAC ----------------------------------
MPD_AUTO_PKG(flac, FLAC, [flac >= 1.1],
MPD_AUTO_PKG(flac, FLAC, [flac >= 1.2],
[FLAC decoder], [libFLAC not found])
if test x$enable_flac = xyes; then
@@ -844,16 +875,18 @@ AM_CONDITIONAL(HAVE_FLAC, test x$enable_flac = xyes)
enable_flac_encoder=$enable_flac
dnl -------------------------------- FluidSynth -------------------------------
MPD_AUTO_PKG(fluidsynth, FLUIDSYNTH, [fluidsynth >= 1.1],
[fluidsynth decoder], [fluidsynth not found])
if test x$enable_fluidsynth = xyes; then
PKG_CHECK_MODULES(FLUIDSYNTH, [fluidsynth],
AC_DEFINE(ENABLE_FLUIDSYNTH, 1, [Define for fluidsynth support]),
enable_fluidsynth=no)
AC_DEFINE(ENABLE_FLUIDSYNTH, 1, [Define for fluidsynth support])
fi
AM_CONDITIONAL(ENABLE_FLUIDSYNTH, test x$enable_fluidsynth = xyes)
dnl ---------------------------------- libgme ---------------------------------
MPD_AUTO_PKG(gme, GME, [libgme],
MPD_AUTO_PKG_LIB(gme, GME, [libgme], gme, gme_open_file, [-lgme -lstdc++], [],
[gme decoder plugin], [libgme not found])
AM_CONDITIONAL(HAVE_GME, test x$enable_gme = xyes)
if test x$enable_gme = xyes; then
@@ -899,9 +932,6 @@ fi
AM_CONDITIONAL(ENABLE_MIKMOD_DECODER, test x$enable_mikmod = xyes)
dnl -------------------------------- libmodplug -------------------------------
found_modplug=$HAVE_CXX
MPD_AUTO_PRE(modplug, [modplug decoder plugin], [No C++ compiler found])
MPD_AUTO_PKG(modplug, MODPLUG, [libmodplug],
[modplug decoder plugin], [libmodplug not found])
@@ -910,6 +940,14 @@ if test x$enable_modplug = xyes; then
fi
AM_CONDITIONAL(HAVE_MODPLUG, test x$enable_modplug = xyes)
dnl -------------------------------- libopus ----------------------------------
MPD_AUTO_PKG(opus, OPUS, [opus ogg],
[opus decoder plugin], [libopus not found])
if test x$enable_opus = xyes; then
AC_DEFINE(HAVE_OPUS, 1, [Define to use libopus])
fi
AM_CONDITIONAL(HAVE_OPUS, test x$enable_opus = xyes)
dnl -------------------------------- libsndfile -------------------------------
dnl See above test, which may disable this.
MPD_AUTO_PKG(sndfile, SNDFILE, [sndfile],
@@ -921,33 +959,12 @@ fi
AM_CONDITIONAL(ENABLE_SNDFILE, test x$enable_sndfile = xyes)
dnl --------------------------------- musepack --------------------------------
MPD_AUTO_LIB(mpc, MPCDEC, mpcdec, mpc_demux_init, [-lmpcdec], [],
[mpcdec], [libmpcdec not found])
if test x$enable_mpc = xyes; then
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
AC_CHECK_LIB(mpcdec,main,
MPCDEC_LIBS="$MPCDEC_LIBS -lmpcdec",
enable_mpc=no)
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
if test x$enable_mpc = xyes; then
AC_CHECK_HEADER([mpc/mpcdec.h],
[AC_DEFINE(HAVE_MPCDEC,1,
[Define to use libmpcdec for MPC decoding])],
[AC_CHECK_HEADER(mpcdec/mpcdec.h,
[AC_DEFINE(MPC_IS_OLD_API, 1,
[Define if an old pre-SV8 libmpcdec is used])]
)]
)
else
AC_MSG_WARN([mpcdec lib needed for MPC support -- disabling MPC support])
fi
AC_DEFINE(HAVE_MPCDEC, 1, [Define to use libmpcdec for MPC decoding])
fi
AC_SUBST(MPCDEC_LIBS)
AC_SUBST(MPCDEC_CFLAGS)
AM_CONDITIONAL(HAVE_MPCDEC, test x$enable_mpc = xyes)
dnl -------------------------------- Ogg Tremor -------------------------------
@@ -999,9 +1016,14 @@ if test x$enable_tremor = xyes; then
AC_MSG_WARN(["OggTremor detected, could not enable Vorbis."])
fi
enable_vorbis=no
if test x$enable_vorbis_encoder = xauto; then
AC_MSG_WARN([OggTremor detected, disabling the Vorbis encoder plugin.])
enable_vorbis_encoder=no
fi
fi
MPD_AUTO_PKG(vorbis, VORBIS, [vorbis vorbisfile ogg],
MPD_AUTO_PKG(vorbis, VORBIS, [vorbisfile vorbis ogg],
[Ogg Vorbis decoder], [libvorbis not found])
if test x$enable_vorbis = xyes; then
AC_DEFINE(ENABLE_VORBIS_DECODER, 1, [Define for Ogg Vorbis support])
@@ -1010,9 +1032,6 @@ fi
AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enable_tremor = xyes)
dnl --------------------------------- sidplay ---------------------------------
found_sidplay=$HAVE_CXX
MPD_AUTO_PRE(sidplay, [sidplay decoder plugin], [No C++ compiler found])
if test x$enable_sidplay != xno; then
# we're not using pkg-config here
# because libsidplay2's .pc file requires libtool
@@ -1027,7 +1046,7 @@ if test x$enable_sidplay != xno; then
[found_sidplay=yes], [found_sidplay=no])
if test x$found_sidplay = xyes; then
AC_CHECK_LIB([sidutils],[main],[],[found_sidplay=no],[])
AC_CHECK_LIB([sidutils],[main],[:],[found_sidplay=no],[])
fi
MPD_AUTO_RESULT(sidplay, [sidplay decoder plugin],
@@ -1052,25 +1071,9 @@ if test x$enable_wavpack = xyes; then
fi
dnl --------------------------------- WildMidi --------------------------------
MPD_AUTO_LIB(wildmidi, WILDMIDI, WildMidi, WildMidi_Init, [-lWildMidi], [],
[wildmidi], [libwildmidi not found])
if test x$enable_wildmidi = xyes; then
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
AC_CHECK_LIB(WildMidi, WildMidi_Init,,
AC_MSG_ERROR([libwildmidi not found]))
AC_CHECK_LIB(WildMidi, WildMidi_SampledSeek,
[AC_DEFINE(HAVE_WILDMIDI_SAMPLED_SEEK, 1,
[Defined if WildMidi_SampledSeek() is available (libwildmidi <= 0.2.2)])])
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
AC_SUBST(WILDMIDI_LIBS,-lWildMidi)
AC_SUBST(WILDMIDI_CFLAGS,)
AC_DEFINE(ENABLE_WILDMIDI, 1, [Define for wildmidi support])
fi
@@ -1087,9 +1090,9 @@ if
test x$enable_mad = xno &&
test x$enable_mikmod = xno; then
test x$enable_modplug = xno &&
test x$enable_mp4 = xno &&
test x$enable_mpc = xno &&
test x$enable_mpg123 = xno &&
test x$enable_opus = xno &&
test x$enable_sidplay = xno &&
test x$enable_tremor = xno &&
test x$enable_vorbis = xno &&
@@ -1099,11 +1102,8 @@ if
AC_MSG_ERROR([No input plugins supported!])
fi
AM_CONDITIONAL(HAVE_OGG_COMMON,
test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_flac = xyes)
AM_CONDITIONAL(HAVE_FLAC_COMMON,
test x$enable_flac = xyes)
AM_CONDITIONAL(HAVE_XIPH,
test x$enable_vorbis = xyes || test x$enable_tremor = xyes || test x$enable_flac = xyes || test x$enable_opus = xyes)
dnl ---------------------------------------------------------------------------
dnl Encoders for Streaming Audio Output Plugins
@@ -1139,7 +1139,7 @@ fi
AM_CONDITIONAL(ENABLE_FLAC_ENCODER, test x$enable_flac_encoder = xyes)
dnl ---------------------------- Ogg Vorbis Encoder ---------------------------
MPD_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc],
MPD_AUTO_PKG(vorbis_encoder, VORBISENC, [vorbisenc vorbis ogg],
[Ogg Vorbis encoder], [libvorbisenc not found])
if test x$enable_vorbis_encoder = xyes; then
@@ -1149,23 +1149,9 @@ fi
AM_CONDITIONAL(ENABLE_VORBIS_ENCODER, test x$enable_vorbis_encoder = xyes)
dnl ------------------------------- LAME Encoder ------------------------------
if test x$enable_lame_encoder != xno; then
AC_CHECK_HEADERS(lame/lame.h,,
[AC_CHECK_HEADERS(lame.h,, using_lame=no)])
AC_CHECK_LIB(mp3lame, lame_init,, using_lame=no)
if test x$using_lame != xno; then
AC_DEFINE(HAVE_LAME, 1, [Define to 1 if you have lame 3.98 or greater.])
LAME_LIBS="-lmp3lame -lm"
enable_lame_encoder=yes
fi
if test "$enable_lame_encoder" = "yes" -a "$using_lame" = "no"; then
AC_MSG_ERROR([LAME libraries and development support files not found.])
fi
fi
AC_SUBST(LAME_LIBS)
MPD_AUTO_LIB(lame_encoder, LAME, mp3lame, lame_init, [-lmp3lame], [],
[libmp3lame], [libmp3lame not found])
if test x$enable_lame_encoder = xyes; then
AC_DEFINE(ENABLE_LAME_ENCODER, 1,
[Define to enable the lame encoder plugin])
@@ -1191,6 +1177,7 @@ fi
dnl --------------------------- encoder plugins test --------------------------
if test x$enable_vorbis_encoder != xno ||
test x$enable_opus != xno ||
test x$enable_lame_encoder != xno ||
test x$enable_twolame_encoder != xno ||
test x$enable_flac_encoder != xno ||
@@ -1211,6 +1198,7 @@ if test x$enable_encoder = xyes; then
[Define to enable the encoder plugins])
fi
AM_CONDITIONAL(ENABLE_ENCODER, test x$enable_encoder = xyes)
AM_CONDITIONAL(HAVE_OGG_ENCODER, test x$enable_vorbis_encoder = xyes || test x$enable_opus = xyes)
dnl ---------------------------------------------------------------------------
dnl Audio Output Plugins
@@ -1236,17 +1224,6 @@ fi
AM_CONDITIONAL(HAVE_ROAR, test x$enable_roar = xyes)
dnl ----------------------------------- FFADO ---------------------------------
MPD_AUTO_PKG(ffado, FFADO, [libffado],
[libffado output plugin], [libffado not found])
if test x$enable_ffado = xyes; then
AC_DEFINE(ENABLE_FFADO_OUTPUT, 1, [Define to enable the libffado output plugin])
fi
AM_CONDITIONAL(ENABLE_FFADO_OUTPUT, test x$enable_ffado = xyes)
dnl ----------------------------------- FIFO ----------------------------------
if test x$enable_fifo = xyes; then
AC_CHECK_FUNC([mkfifo],
@@ -1302,31 +1279,28 @@ fi
AM_CONDITIONAL(HAVE_AO, test x$enable_ao = xyes)
dnl ----------------------------------- MVP -----------------------------------
if test x$enable_mvp = xyes; then
AC_DEFINE(HAVE_MVP,1,[Define to enable Hauppauge Media MVP support])
fi
AM_CONDITIONAL(HAVE_MVP, test x$enable_mvp = xyes)
dnl ---------------------------------- OpenAL ---------------------------------
AC_SUBST(OPENAL_CFLAGS,"")
AC_SUBST(OPENAL_LIBS,"")
if test x$enable_openal = xyes; then
if test x$enable_osx = xyes; then
AC_CHECK_HEADERS([OpenAL/al.h OpenAL/alc.h], [], [enable_openal=no])
if test x$enable_openal = xyes; then
OPENAL_LIBS="-framework OpenAL"
AC_DEFINE(HAVE_OPENAL, 1, [Define for OpenAL support])
else
AC_MSG_WARN(OpenAL headers not found -- disabling OpenAL support)
fi
else
PKG_CHECK_MODULES([OPENAL], [openal],
AC_DEFINE(HAVE_OPENAL, 1, [Define for OpenAL support]),
enable_openal=no)
if test x$host_is_darwin = xyes; then
if test x$enable_openal != xno; then
AC_CHECK_HEADERS([OpenAL/al.h OpenAL/alc.h],
[found_openal=yes], [found_openal=no])
fi
MPD_AUTO_RESULT(openal, [OpenAL output plugin], [OpenAL not found])
if test x$enable_openal = xyes; then
OPENAL_LIBS="-framework OpenAL"
fi
else
MPD_AUTO_PKG(openal, [OPENAL], [openal],
[OpenAL output plugin], [OpenAL not found])
fi
if test x$enable_openal = xyes; then
AC_DEFINE(HAVE_OPENAL, 1, [Define for OpenAL support])
fi
AM_CONDITIONAL(HAVE_OPENAL, test x$enable_openal = xyes)
@@ -1342,13 +1316,10 @@ fi
AM_CONDITIONAL(HAVE_OSS, test x$enable_oss = xyes)
dnl ----------------------------------- OSX -----------------------------------
enable_osx=no
case "$host_os" in
darwin*)
AC_DEFINE(HAVE_OSX, 1, [Define for compiling OS X support])
LIBS="$LIBS -framework AudioUnit -framework CoreAudio -framework CoreServices"
enable_osx=yes ;;
esac
if test x$enable_osx = xyes; then
AC_DEFINE(HAVE_OSX, 1, [Define for compiling OS X support])
LIBS="$LIBS -framework AudioUnit -framework CoreAudio -framework CoreServices"
fi
AM_CONDITIONAL(HAVE_OSX, test x$enable_osx = xyes)
@@ -1360,7 +1331,7 @@ fi
AM_CONDITIONAL(ENABLE_PIPE_OUTPUT, test x$enable_pipe_output = xyes)
dnl -------------------------------- PulseAudio -------------------------------
MPD_AUTO_PKG(pulse, PULSE, [libpulse],
MPD_AUTO_PKG(pulse, PULSE, [libpulse >= 0.9.16],
[PulseAudio output plugin], [libpulse not found])
if test x$enable_pulse = xyes; then
AC_DEFINE([HAVE_PULSE], 1,
@@ -1444,11 +1415,9 @@ if
test x$enable_alsa = xno &&
test x$enable_roar = xno &&
test x$enable_ao = xno &&
test x$enable_ffado = xno &&
test x$enable_fifo = xno &&
test x$enable_httpd_output = xno &&
test x$enable_jack = xno &&
test x$enable_mvp = xno; then
test x$enable_openal = xno &&
test x$enable_oss = xno &&
test x$enable_osx = xno &&
@@ -1457,7 +1426,7 @@ if
test x$enable_recorder_output = xno &&
test x$enable_shout = xno &&
test x$enable_solaris_output = xno &&
test x$enable_winmm_output = xno &&
test x$enable_winmm_output = xno; then
AC_MSG_ERROR([No Audio Output types configured!])
fi
@@ -1485,15 +1454,52 @@ AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
dnl ---------------------------------------------------------------------------
dnl test suite
dnl ---------------------------------------------------------------------------
if test "x$enable_test" = xyes; then
PKG_CHECK_MODULES([CPPUNIT], [cppunit],,
[AC_MSG_ERROR([cppunit not found])])
fi
AM_CONDITIONAL(ENABLE_TEST, test "x$enable_test" = xyes)
dnl ---------------------------------------------------------------------------
dnl CFLAGS
dnl ---------------------------------------------------------------------------
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
CFLAGS="$CFLAGS -Werror -pedantic-errors"
CXXFLAGS="$CXXFLAGS -Werror"
fi
dnl ---------------------------- language features ----------------------------
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden])
AX_APPEND_COMPILE_FLAGS([-fno-threadsafe-statics])
AX_APPEND_COMPILE_FLAGS([-fmerge-all-constants])
AX_APPEND_COMPILE_FLAGS([-fno-exceptions])
AX_APPEND_COMPILE_FLAGS([-fno-rtti])
AX_APPEND_COMPILE_FLAGS([-ffast-math])
AX_APPEND_COMPILE_FLAGS([-ftree-vectorize])
AC_LANG_POP
dnl ---------------------------------- debug ----------------------------------
if test "x$enable_debug" = xno; then
AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
AX_APPEND_COMPILE_FLAGS([-fdata-sections])
AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-ffunction-sections])
AX_APPEND_COMPILE_FLAGS([-fdata-sections])
AC_LANG_POP
AX_APPEND_LINK_FLAGS([-Wl,--gc-sections])
fi
dnl ----------------------------------- GCC -----------------------------------
@@ -1508,12 +1514,17 @@ then
AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
AX_APPEND_COMPILE_FLAGS([-pedantic])
fi
dnl ---------------------------- warnings as errors ---------------------------
if test "x$enable_werror" = xyes; then
AM_CFLAGS="$AM_CFLAGS -Werror -pedantic-errors"
AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
AC_LANG_PUSH([C++])
AX_APPEND_COMPILE_FLAGS([-Wall])
AX_APPEND_COMPILE_FLAGS([-Wextra])
AX_APPEND_COMPILE_FLAGS([-Wmissing-declarations])
AX_APPEND_COMPILE_FLAGS([-Wshadow])
AX_APPEND_COMPILE_FLAGS([-Wpointer-arith])
AX_APPEND_COMPILE_FLAGS([-Wcast-qual])
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
AX_APPEND_COMPILE_FLAGS([-Wsign-compare])
AC_LANG_POP
fi
dnl ---------------------------------------------------------------------------
@@ -1540,20 +1551,21 @@ results(un,[UNIX Domain Sockets])
printf '\nFile format support:\n\t'
results(aac, [AAC])
results(adplug, [AdPlug])
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
results(flac, [FLAC])
results(fluidsynth, [FluidSynth])
results(gme, [GME])
results(sndfile, [libsndfile])
printf '\n\t'
results(sndfile, [libsndfile])
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mad, [MAD])
results(mpg123, [MPG123])
results(mp4, [MP4])
results(mpc, [Musepack])
printf '\n\t'
results(opus, [Opus])
results(tremor, [OggTremor])
results(vorbis, [OggVorbis])
results(audiofile, [WAVE])
@@ -1562,6 +1574,7 @@ results(wildmidi, [WildMidi])
printf '\nOther features:\n\t'
results(lsr, [libsamplerate])
results(libmpdclient, [libmpdclient])
results(inotify, [inotify])
results(sqlite, [SQLite])
@@ -1570,14 +1583,12 @@ results(id3,[ID3])
printf '\nPlayback support:\n\t'
results(alsa,ALSA)
results(ffado,FFADO)
results(fifo,FIFO)
results(recorder_output,[File Recorder])
results(httpd_output,[HTTP Daemon])
results(jack,[JACK])
printf '\n\t'
results(ao,[libao])
results(mvp, [Media MVP])
results(oss,[OSS])
results(openal,[OpenAL])
results(osx, [OS X])
@@ -1597,6 +1608,7 @@ if
results(flac_encoder, [FLAC])
results(lame_encoder, [LAME])
results(vorbis_encoder, [Ogg Vorbis])
results(opus, [Opus])
results(twolame_encoder, [TwoLAME])
results(wave_encoder, [WAVE])
fi
@@ -1605,11 +1617,9 @@ printf '\nStreaming support:\n\t'
results(cdio_paranoia, [CDIO_PARANOIA])
results(curl,[CURL])
results(despotify,[Despotify])
results(lastfm,[Last.FM])
results(soundcloud,[Soundcloud])
printf '\n\t'
results(mms,[MMS])
results(soup, [SOUP])
printf '\n\n##########################################\n\n'

View File

@@ -32,23 +32,16 @@
<listitem>
<para>
don't write CPP when you can write C: use inline functions
and enums instead of macros
don't write CPP when you can write C++: use inline
functions and constexpr instead of macros
</para>
</listitem>
<listitem>
<para>
the code should be C99 compliant, and must compile with
<application>GCC</application>;
<application>clang</application> support is highly desirable
</para>
</listitem>
<listitem>
<para>
C++ is ok (for integrating C++ only libraries), but it
should be avoided
the code should be C++11 compliant, and must compile with
<application>GCC</application> 4.6 and
<application>clang</application> 3.2
</para>
</listitem>
@@ -61,7 +54,7 @@
foo(const char *abc, int xyz)
{
if (abc == NULL) {
g_warning("Foo happened!\n");
LogWarning("Foo happened!");
return -1;
}
@@ -75,12 +68,28 @@ foo(const char *abc, int xyz)
<chapter>
<title>Hacking The Source</title>
<para>
MPD sources are managed in a git repository on <ulink
url="http://git.musicpd.org/">git.musicpd.org</ulink>.
</para>
<para>
Always write your code against the latest git:
</para>
<programlisting>git clone git://git.musicpd.org/master/mpd.git</programlisting>
<para>
If you already have a clone, update it:
</para>
<programlisting>git pull --rebase git://git.musicpd.org/master/mpd.git master</programlisting>
<para>
You can do without "--rebase", but we recommend that you rebase
your repository on the "master" repository all the time.
</para>
<para>
Configure with the options <option>--enable-debug
--enable-werror</option>. Enable as many plugins as possible,
@@ -90,8 +99,55 @@ foo(const char *abc, int xyz)
<para>
Don't mix several changes in one single patch. Create a
separate patch for every change. Tools like
<application>stgit</application> help you with that.
<application>stgit</application> help you with that. This way,
we can review your patches more easily, and we can pick the
patches we like most first.
</para>
<section>
<title> Basic stgit usage</title>
<para>
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.
</para>
<para>
stgit needs to be initialized on a git repository: stg init
</para>
<para>
Before you edit the code, create a patch: stg new
my-patch-name (stgit now asks you for the commit message).
</para>
<para>
Now edit the code. Once you're finished, you have to "refresh"
the patch, i.e. your edits are incorporated into the patch you
have created: stg refresh
</para>
<para>
You may now continue editing the same patch, and refresh it as
often as you like. Create more patches, edit and refresh them.
</para>
<para>
To view the list of patches, type stg series. To go back to a
specific patch, type stg goto my-patch-name; now you can
re-edit it (don't forget stg refresh when you're finished with
that patch).
</para>
<para>
When the whole patch series is finished, convert stgit patches
to git commits: stg commit
</para>
</section>
</chapter>
<chapter>
@@ -99,7 +155,7 @@ foo(const char *abc, int xyz)
<para>
Send your patches to the mailing list:
musicpd-dev-team@lists.sourceforge.net
mpd-devel@musicpd.org
</para>
</chapter>
</book>

View File

@@ -1158,7 +1158,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
PREDEFINED = G_GNUC_UNUSED=
PREDEFINED =
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.

View File

@@ -12,29 +12,29 @@ stores info about all available music, and this info can be easily searched and
retrieved. Player control, info retrieval, and playlist management can all be
managed remotely.
MPD searches for a config file in \fB~/.mpdconf\fP then \fB/etc/mpd.conf\fP or
uses CONF_FILE.
MPD searches for a config file in \fB$XDG_CONFIG_HOME/mpd/mpd.conf\fP then
\fB~/.mpdconf\fP then \fB/etc/mpd.conf\fP or uses CONF_FILE.
Read more about MPD at <\fBhttp://www.musicpd.org/\fP>.
.SH OPTIONS
.TP
.BI --help
.BI \-\-help
Output a brief help message.
.TP
.BI --kill
.BI \-\-kill
Kill the currently running mpd session. The pid_file parameter must be
specified in the config file for this to work.
.TP
.BI --no-daemon
.BI \-\-no\-daemon
Don't detach from console.
.TP
.BI --stderr
.BI \-\-stderr
Print messages stderr.
.TP
.BI --verbose
.BI \-\-verbose
Verbose logging.
.TP
.BI --version
.BI \-\-version
Print version information.
.SH FILES
.TP
@@ -48,8 +48,8 @@ mpd.conf(5), mpc(1)
.SH BUGS
If you find a bug, please report it at
.br
<\fBhttp://www.musicpd.org/mantis/bug_report_page.php\fP>.
<\fBhttp://bugs.musicpd.org/bug_report_page.php\fP>.
.SH AUTHORS
Warren Dukes <warren.dukes@gmail.com>
Max Kellermann <max@duempel.org>
Special thanks to all the people that provided feedback and patches.

View File

@@ -3,8 +3,9 @@
mpd.conf \- Music Player Daemon configuration file
.SH DESCRIPTION
\fBmpd.conf\fP is the configuration file for mpd(1). If not specified on the
command line, MPD first searches for it at \fB~/.mpdconf\fP then at
\fB~/.mpd/mpd.conf\fP and then in \fB/etc/mpd.conf\fP.
command line, MPD first searches for it at \fB$XDG_CONFIG_HOME/mpd/mpd.conf\fP
then at \fB~/.mpdconf\fP then at \fB~/.mpd/mpd.conf\fP and then in
\fB/etc/mpd.conf\fP.
Lines beginning with a "#" character are comments. All other non-empty lines
specify parameters and their values. These lines contain the parameter name
@@ -27,31 +28,24 @@ paths.
See \fBdocs/mpdconf.example\fP in the source tarball for an example
configuration file.
This manual is not complete, it lists only the most important options.
Please read the MPD user manual for a complete configuration guide:
<\fBhttp://www.musicpd.org/doc/user/\fP>
.SH REQUIRED PARAMETERS
.TP
.B follow_outside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing outside the music dir.
You must recreate the database after changing this option.
The default is "yes".
.TP
.B follow_inside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing inside the music dir,
potentially adding duplicates to the database.
You must recreate the database after changing this option.
The default is "yes".
.TP
.B db_file <file>
This specifies where the db file will be stored.
.TP
.B sticker_file <file>
The location of the sticker database. This is a database which
manages dynamic information attached to songs.
.TP
.B log_file <file>
This specifies where the log file should be located.
The special value "syslog" makes MPD use the local syslog daemon.
.SH OPTIONAL PARAMETERS
.TP
.B sticker_file <file>
The location of the sticker database. This is a database which
manages dynamic information attached to songs.
.TP
.B pid_file <file>
This specifies the file to save mpd's process ID in.
.TP
@@ -87,8 +81,9 @@ You can set a port that is different from the global port setting,
e.g. "localhost:6602". IPv6 addresses must be enclosed in square
brackets if you want to configure a port, e.g. "[::1]:6602".
To bind to a Unix domain socket, specify an absolute path. For a
system-wide MPD, we suggest the path "\fB/var/run/mpd/socket\fP".
To bind to a Unix domain socket, specify an absolute path or a path starting
with a tilde (~). For a system-wide MPD, we suggest the path
"\fB/var/run/mpd/socket\fP".
.TP
.B port <port>
This specifies the port that mpd listens on. The default is 6600.
@@ -99,6 +94,17 @@ reports from what address a connection is opened, and when it is closed, and
"verbose" records excessive amounts of information for debugging purposes. The
default is "default".
.TP
.B follow_outside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing outside the music dir.
You must recreate the database after changing this option.
The default is "yes".
.TP
.B follow_inside_symlinks <yes or no>
Control if MPD will follow symbolic links pointing inside the music dir,
potentially adding duplicates to the database.
You must recreate the database after changing this option.
The default is "yes".
.TP
.B zeroconf_enabled <yes or no>
If yes, and MPD has been compiled with support for Avahi or Bonjour, service
information will be published with Zeroconf. The default is yes.
@@ -175,7 +181,7 @@ only choice) if MPD was compiled without libsamplerate.
.RE
.IP
For an up-to-date list of available converters, please see the libsamplerate
documentation (available online at <\fBhttp://www.mega-nerd.com/SRC/\fP>).
documentation (available online at <\fBhttp://www.mega\-nerd.com/SRC/\fP>).
.TP
.B replaygain <off or album or track or auto>
If specified, mpd will adjust the volume of songs played using ReplayGain tags
@@ -186,14 +192,14 @@ tags if random play is activated otherwise the album ReplayGain tags. Currently
only FLAC, Ogg Vorbis, Musepack, and MP3 (through ID3v2 ReplayGain tags, not
APEv2) are supported.
.TP
.B replaygain_preamp <-15 to 15>
.B replaygain_preamp <\-15 to 15>
This is the gain (in dB) applied to songs with ReplayGain tags.
.TP
.B volume_normalization <yes or no>
If yes, mpd will normalize the volume of songs as they play. The default is no.
.TP
.B audio_buffer_size <size in KiB>
This specifies the size of the audio buffer in kibibytes. The default is 2048,
This specifies the size of the audio buffer in kibibytes. The default is 4096,
large enough for nearly 12 seconds of CD-quality audio.
.TP
.B buffer_before_play <0-100%>
@@ -216,7 +222,7 @@ default is 5.
.TP
.B max_playlist_length <number>
This specifies the maximum number of songs that can be in the playlist. The
default is 4096.
default is 16384.
.TP
.B max_command_list_size <size in KiB>
This specifies the maximum size a command list can be. The default is 2048.
@@ -227,12 +233,12 @@ is 8192.
.TP
.B filesystem_charset <charset>
This specifies the character set used for the filesystem. A list of supported
character sets can be obtained by running "iconv -l". The default is
character sets can be obtained by running "iconv \-l". The default is
determined from the locale when the db was originally created.
.TP
.B id3v1_encoding <charset>
This specifies the character set which ID3v1 tags are encoded in. A list of
supported character sets can be obtained by running "iconv -l". The default is
supported character sets can be obtained by running "iconv \-l". The default is
to let libid3tag convert them (from ISO-8859-1, as the standard specifies) and
do no additional conversion.
.TP
@@ -252,14 +258,15 @@ when saving playlists. The default is "no".
This specifies the tag types that will be scanned for and made available to
clients. Note that you must recreate (not update) your database for changes to
this parameter to take effect. Possible values are artist, album, title,
track, name, genre, date, composer, performer, comment, and disc. Multiple
tags may be specified as a comma separated list. An example value is
"artist,album,title,track". The special value "none" may be used alone to
disable all metadata. The default is to use all known tag types except for
comments.
track, name, genre, date, composer, performer, comment, disc,
musicbrainz_artistid, musicbrainz_albumid, musicbrainz_albumartistid,
musicbrainz_trackid. Multiple tags may be specified as a comma separated list.
An example value is "artist,album,title,track". The special value "none" may
be used alone to disable all metadata. The default is to use all known tag
types except for comments and those starting with "musicbrainz".
.TP
.B auto_update <yes or no>
This specifies the wheter to support automatic update of music database when
This specifies the whether to support automatic update of music database when
files are changed in music_directory. The default is to disable autoupdate
of database.
.TP
@@ -281,7 +288,7 @@ better but requires more processing and higher bandwidth. Default is yes.
.TP
.B type <type>
This specifies the audio output type. See the list of supported outputs in mpd
--version for possible values.
\-\-version for possible values.
.TP
.B name <name>
This specifies a unique name for the audio output.
@@ -356,152 +363,6 @@ 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 OPTIONAL OSS OUTPUT PARAMETERS
.TP
.B device <dev>
This specifies the device to use for audio output. The default is "/dev/dsp".
.TP
.B mixer_device <mixer dev>
This specifies which mixer to use. The default is "/dev/mixer".
.TP
.B mixer_control <mixer ctrl>
This specifies which mixer control to use (sometimes referred to as the
"device"). The default is to use the main PCM mixer. An example is "Pcm".
.SH OPTIONAL PULSE OUTPUT PARAMETERS
.TP
.B server <server list>
A space separated list of servers to try to connect to. See
<\fBhttp://www.pulseaudio.org/wiki/ServerStrings\fP> for more details. The
default is to let PulseAudio choose a server.
If you specify more than one server name, MPD tries to connect to one
after another until it successfully establishes a connection.
.TP
.B sink <sink>
The sink to output to. The default is to let PulseAudio choose a sink.
.SH OPTIONAL JACK OUTPUT PARAMETERS
.TP
.B client_name <name>
The client name to use when connecting to JACK. The output ports <name>:left
and <name>:right will also be created for the left and right channels,
respectively.
.TP
.B ports <left_port,right_port>
This specifies the left and right ports to connect to for the left and right
channels, respectively. The default is to let JACK choose a pair of ports.
.TP
.B ringbuffer_size <size in bytes>
This specifies the size of the ringbuffer in bytes. The default is 32768.
.SH OPTIONAL AO OUTPUT PARAMETERS
.TP
.B driver <driver>
This specifies the libao driver to use for audio output. Possible values
depend on what libao drivers are available. See
<\fBhttp://www.xiph.org/ao/doc/drivers.html\fP> for information on some
commonly used drivers. Typical values for Linux include "oss" and "alsa09".
The default is "default", which causes libao to select an appropriate plugin.
.TP
.B options <opts>
This specifies the options to use for the selected libao driver. For oss, the
only option available is "dsp". For alsa09, the available options are: "dev",
"buf_size", and "periods". See <\fBhttp://www.xiph.org/ao/doc/drivers.html\fP>
for available options for some commonly used drivers. Options are assigned
using "=", and ";" is used to separate options. An example for oss:
"dsp=/dev/dsp". An example for alsa09: "dev=hw:0,0;buf_size=4096". The
default is "".
.TP
.B write_size <size in bytes>
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.
.SH REQUIRED FIFO OUTPUT PARAMETERS
.TP
.B path <path>
This specifies the path of the FIFO to output 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 \fBnot\fP 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.
.SH REQUIRED SHOUT OUTPUT PARAMETERS
.TP
.B name <name>
This specifies not only the unique audio output name, but also the stream
title.
.TP
.B host <hostname>
This specifies the hostname of the icecast server to connect to.
.TP
.B port <port>
This specifies the port of the icecast server to connect to.
.TP
.B mount <mountpoint>
This specifies the icecast mountpoint to use.
.TP
.B password <password>
This specifies the password to use when logging in to the icecast server.
.TP
.B quality <quality>
This specifies the encoding quality to use. The value must be between 0
and 10. Fractional values, such as 2.5, are permitted. Either the quality or
the bitrate parameter must be specified, but not both. For Ogg, a
higher quality number produces higher quality output. For MP3, it's
just the opposite, with lower numbers producing higher quality output.
.TP
.B bitrate <kbps>
This specifies the bitrate to use for encoding. Either the quality or the
bitrate parameter must be specified, but not both.
.TP
.B format <sample_rate:bits:channels>
This specifies the sample rate, bits per sample, and number of channels to use
for encoding.
.SH OPTIONAL SHOUT OUTPUT PARAMETERS
.TP
.B encoding <encoding>
This specifies which output encoding to use. Should be either "ogg"
or "mp3", "mp3" is needed for shoutcast streaming. The default is "ogg".
.TP
.B protocol <protocol>
This specifies the protocol that wil be used to connect to the
icecast/shoutcast server. The options are "shoutcast", "icecast1" and
"icecast2". The default is "icecast2".
.TP
.B user <username>
This specifies the username to use when logging in to the icecast server. The
default is "source".
.TP
.B public <yes or no>
This specifies whether to request that the stream be listed in all public
stream directories that the icecast server knows about. The default is no.
.TP
.B timeout <seconds>
This specifies the number of seconds to wait before giving up on trying to
connect to the icecast server. The default is 2 seconds.
.TP
.B description <description>
This specifies a description of the stream.
.TP
.B url <url>
This specifies a URL associated with the stream.
.TP
.B genre <genre>
This specifies the genre(s) of the stream.
.SH OPTIONAL TCP KEEPALIVE PARAMETERS
.TP
.B tcp_keep_alive <yes or no>
Enable tcp keepalive on new client connections. (default is "no")
.TP
.B tcp_keep_alive_idle <seconds>
Time in seconds since the last communication on the connection and before
the keepalive probing is started. (default is 7200 seconds)
.TP
.B tcp_keep_alive_interval <seconds>
Interval in seconds between keepalive probes, once a probe started. (default is 75 seconds)
.TP
.B tcp_keep_alive_count <number of times>
Number of failed probes before the connection is pronounced dead and
the connection is closed. (default is 9 times)
.SH FILES
.TP
.BI ~/.mpdconf

View File

@@ -1,5 +1,5 @@
# An example configuration file for MPD
# See the mpd.conf man page for a more detailed description of each parameter.
# An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# Files and directories #######################################################
@@ -113,10 +113,9 @@
#
#save_absolute_paths_in_playlists "no"
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. Optionally, 'comment' can be added to this
# list.
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. The complete list of possible values can be
# found in the mpd.conf man page.
#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This setting enables automatic update of MPD's database when files in
@@ -176,6 +175,15 @@
###############################################################################
# Database #######################################################################
#
#database {
# plugin "proxy"
# host "other.mpd.host"
# port "6600"
#}
# Input #######################################################################
#
@@ -196,16 +204,12 @@ input {
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# See <http://mpd.wikia.com/wiki/Configuration#Audio_Outputs> for examples of
# other audio outputs.
#
# An example of an ALSA output:
#
#audio_output {
# type "alsa"
# name "My ALSA Device"
## device "hw:0,0" # optional
## format "44100:16:2" # optional
## mixer_type "hardware" # optional
## mixer_device "default" # optional
## mixer_control "PCM" # optional
@@ -218,7 +222,6 @@ input {
# type "oss"
# name "My OSS Device"
## device "/dev/dsp" # optional
## format "44100:16:2" # optional
## mixer_type "hardware" # optional
## mixer_device "/dev/mixer" # optional
## mixer_control "PCM" # optional
@@ -282,6 +285,25 @@ input {
## sink "remote_server_sink" # optional
#}
#
# An example of a winmm output (Windows multimedia API).
#
#audio_output {
# type "winmm"
# name "My WinMM output"
## device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
# or
## device "0" # optional
## mixer_type "hardware" # optional
#}
#
# An example of an openal output.
#
#audio_output {
# type "openal"
# name "My OpenAL output"
## device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#}
#
## Example "pipe" output:
#
#audio_output {
@@ -303,12 +325,6 @@ input {
# mixer_type "none" # optional
#}
#
# This setting will change all decoded audio to be converted to the specified
# format before being passed to the audio outputs. By default, this setting is
# disabled.
#
#audio_output_format "44100:16:2"
#
# If MPD has been compiled with libsamplerate support, this setting specifies
# the sample rate converter to use. Possible values can be found in the
# mpd.conf man page or the libsamplerate documentation. By default, this is
@@ -322,8 +338,11 @@ input {
# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "off", "album" or "track". See <http://www.replaygain.org>
# for more details. This setting is off by default.
# the argument "off", "album", "track" or "auto". "auto" is a special mode that
# chooses between "track" and "album" depending on the current state of
# random playback. If random playback is enabled then "track" mode is used.
# See <http://www.replaygain.org> for more details about ReplayGain.
# This setting is off by default.
#
#replaygain "album"
#
@@ -332,6 +351,20 @@ input {
#
#replaygain_preamp "0"
#
# This setting sets the pre-amp used for files that do NOT have ReplayGain tags.
# By default this setting is disabled.
#
#replaygain_missing_preamp "0"
#
# This setting enables or disables ReplayGain limiting.
# MPD calculates actual amplification based on the ReplayGain tags
# and replaygain_preamp / replaygain_missing_preamp setting.
# If replaygain_limit is enabled MPD will never amplify audio signal
# above its original level. If replaygain_limit is disabled such amplification
# might occur. By default this setting is enabled.
#
#replaygain_limit "yes"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
@@ -347,7 +380,7 @@ input {
# this may have undesired effects. Don't change this if you don't know what you
# are doing.
#
#audio_buffer_size "2048"
#audio_buffer_size "4096"
#
# This setting controls the percentage of the buffer which is filled before
# beginning to play. Increasing this reduces the chance of audio file skipping,
@@ -372,36 +405,6 @@ input {
#
###############################################################################
# Client TCP keep alive #######################################################
#
# For clients connected by TCP on supported platforms.
# Allows detection of dangling connections due to clients disappearing from
# the network without closing their connections.
#
# This is not usually necessary but can be useful in cases such as wifi connectected
# clients that go in and out of network range or turn off wifi without closing their
# connections. Combined with low max_connections this can soon cause clients to not
# be able to connect.
#
#
# Enable tcp keepalive on new client connections (default is "no")
#
#tcp_keep_alive "no"
#
# Time in seconds since the last communication on the connection and before
# the keepalive probing is started. (default is 7200 seconds)
#tcp_keep_alive_idle "7200"
#
# Interval in seconds between keepalive probes, once a probe started.
# (default is 75 seconds)
#tcp_keep_alive_interval "75"
#
# Number of failed probes before the connection is pronounced dead and
# the connection is closed. (default is 9 times)
#tcp_keep_alive_count "9"
#
###############################################################################
# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you

View File

@@ -768,6 +768,25 @@
</para>
</listitem>
</varlistentry>
<varlistentry id="command_volume">
<term>
<cmdsynopsis>
<command>volume</command>
<arg choice="req"><replaceable>CHANGE</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Changes volume by amount <varname>CHANGE</varname>.
</para>
<note>
<para>
<command>volume</command> is deprecated, use
<command>setvol</command> instead.
</para>
</note>
</listitem>
</varlistentry>
</variablelist>
</section>
@@ -1464,9 +1483,13 @@ OK
<para>
Finds songs in the db that are exactly
<varname>WHAT</varname>. <varname>TYPE</varname> can
be any tag supported by MPD, or one of the two special
be any tag supported by MPD, or one of the three special
parameters — <parameter>file</parameter> to search by
full path (relative to database root), and
full path (relative to the music directory),
<parameter>in</parameter> to restrict the search to
songs in the given directory (also relative to the music
directory) and
<parameter>any</parameter> to match against all
available tags. <varname>WHAT</varname> is what to find.
</para>
@@ -1563,6 +1586,32 @@ OK
</para>
</listitem>
</varlistentry>
<varlistentry id="command_readcomments">
<term>
<cmdsynopsis>
<command>readcomments</command>
<arg><replaceable>URI</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Read "comments" (i.e. key-value pairs) from the file
specified by "URI". This "URI" can be a path relative
to the music directory or a URL in the form
"file:///foo/bar.ogg".
</para>
<para>
The response consists of lines in the form "KEY: VALUE".
Comments with suspicious characters (e.g. newlines) are
ignored silently.
</para>
<para>
The meaning of these depends on the codec, and not all
decoder plugins support it. For example, on Ogg files,
this lists the Vorbis comments.
</para>
</listitem>
</varlistentry>
<varlistentry id="command_search">
<term>
<cmdsynopsis>
@@ -1800,7 +1849,10 @@ OK
</term>
<listitem>
<para>
Closes the connection to MPD.
Closes the connection to MPD. MPD will try to send the
remaining output buffer before it actually closes the
connection, but that cannot be guaranteed. This command
will not generate a response.
</para>
</listitem>
</varlistentry>
@@ -1876,6 +1928,20 @@ OK
</para>
</listitem>
</varlistentry>
<varlistentry id="command_toggleoutput">
<term>
<cmdsynopsis>
<command>toggleoutput</command>
<arg choice="req"><replaceable>ID</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Turns an output on or off, depending on the current
state.
</para>
</listitem>
</varlistentry>
<varlistentry id="command_outputs">
<term>
<cmdsynopsis>

View File

@@ -67,11 +67,11 @@
<para>
Download the source tarball from <ulink
url="http://mpd.wikia.com/wiki/Server">the MPD home
url="http://www.musicpd.org/download.html">the MPD home
page</ulink> and unpack it:
</para>
<programlisting>tar xjf mpd-version.tar.bz
<programlisting>tar xf mpd-version.tar.xz
cd mpd-version</programlisting>
<para>
@@ -164,6 +164,53 @@ systemctl start mpd.socket</programlisting>
</para>
</section>
<section>
<title>Configuring database plugins</title>
<para>
If a music directory is configured, one database plugin is
used. To configure this plugin, add a
<varname>database</varname> block to
<filename>mpd.conf</filename>:
</para>
<programlisting>database {
plugin "simple"
path "/var/lib/mpd/db"
}
</programlisting>
<para>
The following table lists the <varname>database</varname>
options valid for all plugins:
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>
Name
</entry>
<entry>
Description
</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>plugin</varname>
</entry>
<entry>
The name of the plugin.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title>Configuring input plugins</title>
@@ -173,7 +220,7 @@ systemctl start mpd.socket</programlisting>
</para>
<programlisting>input {
plugin "lastfm"
plugin "despotify"
user "foo"
password "bar"
}
@@ -389,6 +436,18 @@ systemctl start mpd.socket</programlisting>
enabled.
</entry>
</row>
<row>
<entry>
<varname>tags</varname>
<parameter>yes|no</parameter>
</entry>
<entry>
If set to "no", then MPD will not send tags to this
output. This is only useful for output plugins that
can receive tags, for example the
<varname>httpd</varname> output plugin.
</entry>
</row>
<row>
<entry>
<varname>always_on</varname>
@@ -571,7 +630,7 @@ systemctl start mpd.socket</programlisting>
</para>
<para>
The <ulink url="http://mpd.wikia.com/wiki/Clients">MPD
The <ulink url="http://www.musicpd.org/clients/">MPD
Wiki</ulink> contains an extensive list of clients to choose
from.
</para>
@@ -617,6 +676,81 @@ systemctl start mpd.socket</programlisting>
<chapter>
<title>Plugin reference</title>
<section>
<title>Database plugins</title>
<section>
<title><varname>simple</varname></title>
<para>
The default plugin. Stores a copy of the database in
memory. A file is used for permanent storage.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>path</varname>
</entry>
<entry>
The path of the database file.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>proxy</varname></title>
<para>
Provides access to the database of another MPD instance
using <filename>libmpdclient</filename>. This is useful
when you run mount the music directory via NFS/SMB, and the
file server already runs a MPD instance. Only the file
server needs to update the database.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>host</varname>
</entry>
<entry>
The host name of the "master" MPD instance.
</entry>
</row>
<row>
<entry>
<varname>port</varname>
</entry>
<entry>
The port number of the "master" MPD instance.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section>
<title>Input plugins</title>
@@ -683,6 +817,30 @@ systemctl start mpd.socket</programlisting>
simplest form <filename>cdda://</filename> plays the whole
disc in the default drive.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>default_byte_order</varname>
<parameter>little_endian|big_endian</parameter>
</entry>
<entry>
If the CD drive does not specify a byte order, MPD
assumes it is the CPU's native byte order. This
setting allows overriding this.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
@@ -744,35 +902,6 @@ systemctl start mpd.socket</programlisting>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>soup</varname></title>
<para>
Opens remote files or streams over HTTP.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>proxy</varname>
</entry>
<entry>
Sets the address of the HTTP proxy server.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section>
@@ -818,6 +947,46 @@ systemctl start mpd.socket</programlisting>
</section>
<section>
<title><varname>fluidsynth</varname></title>
<para>
MIDI decoder based on libfluidsynth.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>sample_rate</varname>
</entry>
<entry>
The sample rate that shall be synthesized by the
plugin. Defaults to 48000.
</entry>
</row>
<row>
<entry>
<varname>soundfont</varname>
</entry>
<entry>
The absolute path of the soundfont file. Defaults
to
<filename>/usr/share/sounds/sf2/FluidR3_GM.sf2</filename>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>mikmod</varname></title>
@@ -834,6 +1003,16 @@ systemctl start mpd.socket</programlisting>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>loop</varname>
<parameter>yes|no</parameter>
</entry>
<entry>
Allow backward loops in modules. Default is
<parameter>no</parameter>.
</entry>
</row>
<row>
<entry>
<varname>sample_rate</varname>
@@ -847,6 +1026,68 @@ systemctl start mpd.socket</programlisting>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>modplug</varname></title>
<para>
Module player based on MODPlug.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>loop_count</varname>
</entry>
<entry>
Number of times to loop the module if it uses backward loops.
Default is <parameter>0</parameter> which prevents looping.
<parameter>-1</parameter> loops forever.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>wildmidi</varname></title>
<para>
MIDI decoder based on libwildmidi.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>config_file</varname>
</entry>
<entry>
The absolute path of the timidity config file. Defaults
to
<filename>/etc/timidity/timidity.cfg</filename>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
<section>
@@ -1157,6 +1398,59 @@ systemctl start mpd.socket</programlisting>
The <varname>ao</varname> plugin uses the portable
<filename>libao</filename> library.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>driver</varname>
<parameter>D</parameter>
</entry>
<entry>
The <filename>libao</filename> driver to use for
audio output. Possible values depend on what libao
drivers are available. See <ulink
url="http://www.xiph.org/ao/doc/drivers.html">http://www.xiph.org/ao/doc/drivers.html</ulink>
for information on some commonly used drivers.
Typical values for Linux include "oss" and "alsa09".
The default is "default", which causes libao to
select an appropriate plugin.
</entry>
</row>
<row>
<entry>
<varname>options</varname>
<parameter>O</parameter>
</entry>
<entry>
Options to pass to the selected
<filename>libao</filename> driver.
</entry>
</row>
<row>
<entry>
<varname>write_size</varname>
<parameter>O</parameter>
</entry>
<entry>
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.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
@@ -1167,21 +1461,6 @@ systemctl start mpd.socket</programlisting>
FIFO (First In, First Out) file. The data can be read by
another program.
</para>
</section>
<section>
<title><varname>ffado</varname></title>
<para>
The <varname>ffado</varname> plugin connects to FireWire
audio devices via <filename>libffado</filename>.
</para>
<para>
Warning: this plugin was not tested successfully. I just
couldn't keep libffado2 from crashing. Use at your own
risk.
</para>
<informaltable>
<tgroup cols="2">
@@ -1194,11 +1473,21 @@ systemctl start mpd.socket</programlisting>
<tbody>
<row>
<entry>
<varname>device</varname>
<parameter>NAME</parameter>
<varname>path</varname>
<parameter>P</parameter>
</entry>
<entry>
Sets the device which should be used, e.g. "hw:0".
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.
</entry>
</row>
</tbody>
@@ -1290,16 +1579,6 @@ systemctl start mpd.socket</programlisting>
</informaltable>
</section>
<section>
<title><varname>mvp</varname></title>
<para>
The <varname>mvp</varname> plugin uses the proprietary
Hauppauge Media MVP interface. We do not know any user of
this plugin, and we do not know if it actually works.
</para>
</section>
<section>
<title><varname>httpd</varname></title>
@@ -1573,6 +1852,51 @@ systemctl start mpd.socket</programlisting>
</informaltable>
</section>
<section>
<title><varname>roar</varname></title>
<para>
The <varname>roar</varname> plugin connects to a <ulink
url="http://roaraudio.keep-cool.org/">RoarAudio</ulink>
server.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>server</varname>
<parameter>HOSTNAME</parameter>
</entry>
<entry>
The host name of the RoarAudio server. If not
specified, then MPD will connect to the default
locations.
</entry>
</row>
<row>
<entry>
<varname>role</varname>
<parameter>ROLE</parameter>
</entry>
<entry>
The "role" that MPD registers itself as in the
RoarAudio server. The default is "music".
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>recorder</varname></title>
@@ -1689,6 +2013,18 @@ systemctl start mpd.socket</programlisting>
Defaults to 2 seconds.
</entry>
</row>
<row>
<entry>
<varname>protocol</varname>
<parameter>icecast2|icecast1|shoutcast</parameter>
</entry>
<entry>
Specifies the protocol that wil be used to connect
to the icecast/shoutcast server. The default
is "<parameter>icecast2</parameter>".
</entry>
</row>
<row>
<entry>
<varname>mount</varname>
@@ -1817,45 +2153,6 @@ systemctl start mpd.socket</programlisting>
<section>
<title>Playlist plugins</title>
<section>
<title><varname>lastfm</varname></title>
<para>
Plays last.fm radio.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>user</varname>
<parameter>USERNAME</parameter>
</entry>
<entry>
The last.fm user name.
</entry>
</row>
<row>
<entry>
<varname>password</varname>
<parameter>PWD</parameter>
</entry>
<entry>
The last.fm password.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>embcue</varname></title>

View File

@@ -0,0 +1,61 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_link_flags.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_LINK_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
#
# DESCRIPTION
#
# For every FLAG1, FLAG2 it is checked whether the linker works with the
# flag. If it does, the flag is added FLAGS-VARIABLE
#
# If FLAGS-VARIABLE is not specified, the linker's flags (LDFLAGS) is
# used. During the check the flag is always added to the linker's flags.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# NOTE: This macro depends on the AX_APPEND_FLAG and AX_CHECK_LINK_FLAG.
# Please keep this macro in sync with AX_APPEND_COMPILE_FLAGS.
#
# LICENSE
#
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_APPEND_LINK_FLAGS],
[for flag in $1; do
AX_CHECK_LINK_FLAG([$flag], [AX_APPEND_FLAG([$flag], [m4_default([$2], [LDFLAGS])])], [], [$3])
done
])dnl AX_APPEND_LINK_FLAGS

71
m4/ax_check_link_flag.m4 Normal file
View File

@@ -0,0 +1,71 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the linker or gives an error.
# (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
# when the check is done. The check is thus made with the flags: "LDFLAGS
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
# issue an error when a bad flag is given.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_CHECK_LINK_FLAG],
[AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
ax_check_save_flags=$LDFLAGS
LDFLAGS="$LDFLAGS $4 $1"
AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
LDFLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_LINK_FLAGS

View File

@@ -0,0 +1,107 @@
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_0X
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++0x
# standard.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [
AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
ax_cv_cxx_compile_cxx0x_native,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no)
AC_LANG_RESTORE
])
AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
ax_cv_cxx_compile_cxx0x_cxx,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=c++0x"
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
ax_cv_cxx_compile_cxx0x_gxx,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -std=gnu++0x"
AC_TRY_COMPILE([
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);],,
ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no)
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ax_cv_cxx_compile_cxx0x_native" = yes ||
test "$ax_cv_cxx_compile_cxx0x_cxx" = yes ||
test "$ax_cv_cxx_compile_cxx0x_gxx" = yes; then
AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
fi
])

View File

@@ -8,38 +8,14 @@ AC_ARG_ENABLE(aac,
[disable AAC support (default: enable)]),,
enable_aac=yes)
AC_ARG_WITH(faad,
AS_HELP_STRING([--with-faad=PFX],
[prefix where faad2 is installed (optional)]),,
faad_prefix="")
AC_ARG_WITH(faad-libraries,
AS_HELP_STRING([--with-faad-libraries=DIR],
[directory where faad2 library is installed (optional)]),,
faad_libraries="")
AC_ARG_WITH(faad-includes,
AS_HELP_STRING([--with-faad-includes=DIR],
[directory where faad2 header files are installed (optional)]),,
faad_includes="")
if test x$enable_aac = xyes; then
if test "x$faad_libraries" != "x" ; then
FAAD_LIBS="-L$faad_libraries"
elif test "x$faad_prefix" != "x" ; then
FAAD_LIBS="-L$faad_prefix/lib"
fi
FAAD_LIBS="$FAAD_LIBS -lfaad"
if test "x$faad_includes" != "x" ; then
FAAD_CFLAGS="-I$faad_includes"
elif test "x$faad_prefix" != "x" ; then
FAAD_CFLAGS="-I$faad_prefix/include"
fi
FAAD_LIBS="-lfaad"
FAAD_CFLAGS=""
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $FAAD_CFLAGS -I."
CFLAGS="$CFLAGS $FAAD_CFLAGS"
LIBS="$LIBS $FAAD_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADER(faad.h,,enable_aac=no)
@@ -47,77 +23,36 @@ if test x$enable_aac = xyes; then
AC_CHECK_DECL(FAAD2_VERSION,,enable_aac=no,[#include <faad.h>])
fi
if test x$enable_aac = xyes; then
AC_CHECK_DECL(faacDecInit2,,enable_aac=no,[#include <faad.h>])
AC_CHECK_LIB(faad,NeAACDecInit2,,enable_aac=no)
fi
if test x$enable_aac = xyes; then
AC_CHECK_LIB(faad,faacDecInit2,,enable_aac=no)
if test x$enable_aac = xno; then
enable_aac=yes
AC_CHECK_LIB(faad,NeAACDecInit2,,enable_aac=no)
fi
fi
if test x$enable_aac = xyes; then
AC_MSG_CHECKING(that FAAD2 uses buffer and bufferlen)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
int main() {
char buffer;
long bufferlen = 0;
faacDecHandle decoder;
faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config;
unsigned char channels;
long sampleRate;
mp4AudioSpecificConfig mp4ASC;
decoder = faacDecOpen();
config = faacDecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT;
faacDecSetConfiguration(decoder,config);
AudioSpecificConfig(&buffer, bufferlen, &mp4ASC);
faacDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecDecode(decoder,&frameInfo,&buffer,bufferlen);
return 0;
}
])],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_FAAD_BUFLEN_FUNCS,1,[Define if FAAD2 uses buflen in function calls])],[AC_MSG_RESULT(no);
AC_MSG_CHECKING(that FAAD2 can even be used)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
int main() {
char buffer;
faacDecHandle decoder;
faacDecFrameInfo frameInfo;
faacDecConfigurationPtr config;
NeAACDecHandle decoder;
NeAACDecFrameInfo frameInfo;
NeAACDecConfigurationPtr config;
unsigned char channels;
long sampleRate;
long bufferlen = 0;
unsigned long dummy1_32;
unsigned char dummy2_8, dummy3_8, dummy4_8, dummy5_8, dummy6_8,
dummy7_8, dummy8_8;
decoder = faacDecOpen();
config = faacDecGetCurrentConfiguration(decoder);
decoder = NeAACDecOpen();
config = NeAACDecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT;
faacDecSetConfiguration(decoder,config);
AudioSpecificConfig(&buffer,&dummy1_32,&dummy2_8,
&dummy3_8,&dummy4_8,&dummy5_8,
&dummy6_8,&dummy7_8,&dummy8_8);
faacDecInit(decoder,&buffer,&sampleRate,&channels);
faacDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
faacDecDecode(decoder,&frameInfo,&buffer);
faacDecClose(decoder);
NeAACDecSetConfiguration(decoder,config);
NeAACDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
NeAACDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
NeAACDecDecode(decoder,&frameInfo,&buffer,bufferlen);
NeAACDecClose(decoder);
return 0;
}
])],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
])
fi
if test x$enable_aac = xyes; then
AC_CHECK_MEMBERS([faacDecConfiguration.downMatrix,faacDecConfiguration.dontUpSampleImplicitSBR,faacDecFrameInfo.samplerate],,,[#include <faad.h>])
AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
else
AC_MSG_WARN([faad2 lib needed for MP4/AAC support -- disabling MP4/AAC support])
@@ -145,7 +80,7 @@ int main() {
unsigned char channels;
uint32_t sample_rate;
faacDecInit2(NULL, NULL, 0, &sample_rate, &channels);
NeAACDecInit2(NULL, NULL, 0, &sample_rate, &channels);
return 0;
}
])],
@@ -153,43 +88,12 @@ int main() {
[AC_MSG_RESULT(broken);
AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
fi
if test x$enable_aac = xyes; then
enable_mp4=yes
MP4FF_LIBS="-lmp4ff"
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $FAAD_CFLAGS"
LIBS="$LIBS $FAAD_LIBS $MP4FF_LIBS"
CPPFLAGS=$CFLAGS
AC_CHECK_HEADER(mp4ff.h,,enable_mp4=no)
if test x$enable_mp4 = xyes; then
AC_CHECK_LIB(mp4ff,mp4ff_open_read,,enable_mp4=no)
fi
if test x$enable_mp4 = xyes; then
AC_SUBST(MP4FF_LIBS)
AC_DEFINE(HAVE_MP4, 1, [Define to use FAAD2+mp4ff for MP4 decoding])
else
AC_MSG_WARN([libmp4ff needed for MP4 support -- disabling MP4 support])
unset MP4FF_LIBS
fi
CFLAGS=$oldcflags
LIBS=$oldlibs
CPPFLAGS=$oldcppflags
else
enable_mp4=no
FAAD_CFLAGS=""
FAAD_LIBS=""
FAAD_CFLAGS=""
fi
AC_SUBST(FAAD_CFLAGS)

View File

@@ -73,8 +73,26 @@ AC_DEFUN([MPD_AUTO_PKG_LIB], [
[eval "found_$1=yes"],
AC_CHECK_LIB($4, $5,
[eval "found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'"],
[eval "found_$1=no"]))
[eval "found_$1=no"],
[$6]))
fi
MPD_AUTO_RESULT([$1], [$8], [$9])
])
dnl Wrapper for AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_LIB], [
AC_SUBST([$2_LIBS], [])
AC_SUBST([$2_CFLAGS], [])
if eval "test x`echo '$'enable_$1` != xno"; then
AC_CHECK_LIB($3, $4,
[eval "found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'"],
[eval "found_$1=no"],
[$5])
fi
MPD_AUTO_RESULT([$1], [$7], [$8])
])

12
m4/mpd_func.m4 Normal file
View File

@@ -0,0 +1,12 @@
dnl MPD_OPTIONAL_FUNC(name, func, macro)
dnl
dnl Allow the user to enable or disable the use of a function. If the
dnl option is not specified, the function is auto-detected.
AC_DEFUN([MPD_OPTIONAL_FUNC], [
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1],
[use the function "$1" (default: auto)]),
[test xenable_$1 = xyes && AC_DEFINE([$3], 1, [Define to use $1])],
[AC_CHECK_FUNC([$2],
[AC_DEFINE([$3], 1, [Define to use $1])],)])
])

View File

@@ -1,6 +1,6 @@
[Unit]
Description=Music Player Daemon
After=sound.target
After=network.target sound.target
[Service]
ExecStart=@prefix@/bin/mpd --no-daemon

View File

@@ -1,25 +0,0 @@
#!/bin/sh
PWD=`pwd`
## If we're not in the scripts directory
## assume the base directory.
if test "`basename $PWD`" = "scripts"; then
cd ../
else
MYOLDPWD=`pwd`
cd `dirname $0`/../
fi
if test -e Makefile
then
make distclean
fi
./autogen.sh
make
make dist
if test "`basename $PWD`" = "scripts"; then
cd contrib/
else
cd $MYOLDPWD
fi

View File

@@ -1,6 +0,0 @@
#!/bin/sh
indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cdw -cd0 -c0 -cp0 "$@"
# there doesn't seem to be an indent switch for this, but this
# forces goto labels to the left-most column, without indentation
perl -i -p -e 's/^\s+(\w+):/$1:/g unless /^\s+default:/' "$@"

View File

@@ -1,93 +0,0 @@
#!/bin/sh -e
#
# This shell script tests the build of MPD with various compile-time
# options.
#
# Author: Max Kellermann <max@duempel.org>
PREFIX=/tmp/mpd
rm -rf $PREFIX
test "x$MAKE" != x || MAKE=make
export CFLAGS="-Os"
test -x configure || NOCONFIGURE=1 ./autogen.sh
# all features on
./configure --prefix=$PREFIX/full \
--disable-dependency-tracking --enable-debug --enable-werror \
--enable-un \
--enable-modplug \
--enable-ao --enable-mikmod --enable-mvp
$MAKE install
$MAKE distclean
# no UN, no oggvorbis, no flac, enable oggflac
./configure --prefix=$PREFIX/small \
--disable-dependency-tracking --enable-debug --enable-werror \
--disable-un \
--disable-flac --disable-vorbis --enable-oggflac
$MAKE install
$MAKE distclean
# strip down (disable TCP, disable nearly all plugins)
CFLAGS="$CFLAGS -DNDEBUG" \
./configure --prefix=$PREFIX/tiny \
--disable-dependency-tracking --disable-debug --enable-werror \
--disable-tcp \
--disable-curl \
--disable-id3 --disable-lsr \
--disable-ao --disable-alsa --disable-jack --disable-pulse --disable-fifo \
--disable-shout-ogg --disable-shout-mp3 --disable-lame-encoder \
--disable-ffmpeg --disable-wavpack --disable-mpc --disable-aac \
--disable-flac --disable-vorbis --disable-oggflac --disable-audiofile \
--disable-cue \
--with-zeroconf=no
$MAKE install
$MAKE distclean
# shout: ogg without mp3
# sndfile instead of modplug
./configure --prefix=$PREFIX/shout_ogg \
--disable-dependency-tracking --disable-debug --enable-werror \
--disable-tcp \
--disable-curl \
--disable-id3 --disable-lsr \
--disable-ao --disable-alsa --disable-jack --disable-pulse --disable-fifo \
--enable-shout-ogg --disable-shout-mp3 --disable-lame-encoder \
--disable-ffmpeg --disable-wavpack --disable-mpc --disable-aac \
--disable-flac --enable-vorbis --disable-oggflac --disable-audiofile \
--disable-modplug --enable-sndfile \
--with-zeroconf=no
$MAKE install
$MAKE distclean
# shout: mp3 without ogg
./configure --prefix=$PREFIX/shout_mp3 \
--disable-dependency-tracking --disable-debug --enable-werror \
--disable-tcp \
--disable-curl \
--disable-id3 --disable-lsr \
--disable-ao --disable-alsa --disable-jack --disable-pulse --disable-fifo \
--disable-shout-ogg --enable-shout-mp3 --enable-lame-encoder \
--disable-ffmpeg --disable-wavpack --disable-mpc --disable-aac \
--disable-flac --disable-vorbis --disable-oggflac --disable-audiofile \
--with-zeroconf=no
$MAKE install
$MAKE distclean
# oggvorbis + oggflac
./configure --prefix=$PREFIX/oggvorbisflac \
--disable-dependency-tracking --disable-debug --enable-werror \
--disable-tcp \
--disable-curl \
--disable-id3 --disable-lsr \
--disable-mp3 \
--disable-ao --disable-alsa --disable-jack --disable-pulse --disable-fifo \
--disable-shout-ogg --disable-shout-mp3 --disable-lame-encoder \
--disable-ffmpeg --disable-wavpack --disable-mpc --disable-aac \
--disable-flac --enable-vorbis --enable-oggflac --disable-audiofile \
--with-zeroconf=no
$MAKE install
$MAKE distclean

23
src/ArchiveDomain.cxx Normal file
View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ArchiveDomain.hxx"
#include "util/Domain.hxx"
const Domain archive_domain("archive");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,9 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef INPUT_DESPOTIFY_H
#define INPUT_DESPOTIFY_H
#ifndef MPD_ARCHIVE_DOMAIN_HXX
#define MPD_ARCHIVE_DOMAIN_HXX
extern const struct input_plugin input_plugin_despotify;
extern const class Domain archive_domain;
#endif

58
src/ArchiveFile.hxx Normal file
View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ARCHIVE_FILE_HXX
#define MPD_ARCHIVE_FILE_HXX
class Mutex;
class Cond;
class Error;
class ArchiveFile {
public:
const struct archive_plugin &plugin;
ArchiveFile(const struct archive_plugin &_plugin)
:plugin(_plugin) {}
protected:
/**
* Use Close() instead of delete.
*/
~ArchiveFile() {}
public:
virtual void Close() = 0;
/**
* Visit all entries inside this archive.
*/
virtual void Visit(ArchiveVisitor &visitor) = 0;
/**
* Opens an InputStream of a file within the archive.
*
* @param path the path within the archive
*/
virtual InputStream *OpenStream(const char *path,
Mutex &mutex, Cond &cond,
Error &error) = 0;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,15 +18,15 @@
*/
#include "config.h"
#include "archive_list.h"
#include "archive_plugin.h"
#include "string_util.h"
#include "archive/bz2_archive_plugin.h"
#include "archive/iso9660_archive_plugin.h"
#include "archive/zzip_archive_plugin.h"
#include "ArchiveList.hxx"
#include "ArchivePlugin.hxx"
#include "util/StringUtil.hxx"
#include "archive/Bzip2ArchivePlugin.hxx"
#include "archive/Iso9660ArchivePlugin.hxx"
#include "archive/ZzipArchivePlugin.hxx"
#include "util/Macros.hxx"
#include <string.h>
#include <glib.h>
const struct archive_plugin *const archive_plugins[] = {
#ifdef HAVE_BZ2
@@ -38,11 +38,11 @@ const struct archive_plugin *const archive_plugins[] = {
#ifdef HAVE_ISO9660
&iso9660_archive_plugin,
#endif
NULL
nullptr
};
/** which plugins have been initialized successfully? */
static bool archive_plugins_enabled[G_N_ELEMENTS(archive_plugins) - 1];
static bool archive_plugins_enabled[ARRAY_SIZE(archive_plugins) - 1];
#define archive_plugins_for_each_enabled(plugin) \
archive_plugins_for_each(plugin) \
@@ -51,15 +51,15 @@ static bool archive_plugins_enabled[G_N_ELEMENTS(archive_plugins) - 1];
const struct archive_plugin *
archive_plugin_from_suffix(const char *suffix)
{
if (suffix == NULL)
return NULL;
if (suffix == nullptr)
return nullptr;
archive_plugins_for_each_enabled(plugin)
if (plugin->suffixes != NULL &&
if (plugin->suffixes != nullptr &&
string_array_contains(plugin->suffixes, suffix))
return plugin;
return NULL;
return nullptr;
}
const struct archive_plugin *
@@ -69,14 +69,14 @@ archive_plugin_from_name(const char *name)
if (strcmp(plugin->name, name) == 0)
return plugin;
return NULL;
return nullptr;
}
void archive_plugin_init_all(void)
{
for (unsigned i = 0; archive_plugins[i] != NULL; ++i) {
for (unsigned i = 0; archive_plugins[i] != nullptr; ++i) {
const struct archive_plugin *plugin = archive_plugins[i];
if (plugin->init == NULL || archive_plugins[i]->init())
if (plugin->init == nullptr || archive_plugins[i]->init())
archive_plugins_enabled[i] = true;
}
}
@@ -84,7 +84,7 @@ void archive_plugin_init_all(void)
void archive_plugin_deinit_all(void)
{
archive_plugins_for_each_enabled(plugin)
if (plugin->finish != NULL)
if (plugin->finish != nullptr)
plugin->finish();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ARCHIVE_LIST_H
#define MPD_ARCHIVE_LIST_H
#ifndef MPD_ARCHIVE_LIST_HXX
#define MPD_ARCHIVE_LIST_HXX
struct archive_plugin;
@@ -27,7 +27,7 @@ extern const struct archive_plugin *const archive_plugins[];
#define archive_plugins_for_each(plugin) \
for (const struct archive_plugin *plugin, \
*const*archive_plugin_iterator = &archive_plugins[0]; \
(plugin = *archive_plugin_iterator) != NULL; \
(plugin = *archive_plugin_iterator) != nullptr; \
++archive_plugin_iterator)
/* interface for using plugins */

104
src/ArchiveLookup.cxx Normal file
View File

@@ -0,0 +1,104 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h" /* must be first for large file support */
#include "ArchiveLookup.hxx"
#include "ArchiveDomain.hxx"
#include "Log.hxx"
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
gcc_pure
static char *
FindSlash(char *p, size_t i)
{
for (; i > 0; --i)
if (p[i] == '/')
return p + i;
return nullptr;
}
gcc_pure
static const char *
FindSuffix(const char *p, const char *i)
{
for (; i > p; --i) {
if (*i == '.')
return i + 1;
}
return nullptr;
}
bool
archive_lookup(char *pathname, const char **archive,
const char **inpath, const char **suffix)
{
size_t idx = strlen(pathname);
char *slash = nullptr;
while (true) {
//try to stat if its real directory
struct stat st_info;
if (stat(pathname, &st_info) == -1) {
if (errno != ENOTDIR) {
FormatErrno(archive_domain,
"Failed to stat %s", pathname);
return false;
}
} else {
//is something found ins original path (is not an archive)
if (slash == nullptr)
return false;
//its a file ?
if (S_ISREG(st_info.st_mode)) {
//so the upper should be file
*archive = pathname;
*inpath = slash + 1;
//try to get suffix
*suffix = FindSuffix(pathname, slash - 1);
return true;
} else {
FormatError(archive_domain,
"Not a regular file: %s",
pathname);
return false;
}
}
//find one dir up
if (slash != nullptr)
*slash = '/';
slash = FindSlash(pathname, idx - 1);
if (slash == nullptr)
return false;
*slash = 0;
idx = slash - pathname;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,17 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h" /* must be first for large file support */
#include "archive_api.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <glib.h>
#ifndef MPD_ARCHIVE_LOOKUP_HXX
#define MPD_ARCHIVE_LOOKUP_HXX
/**
*
@@ -46,66 +37,9 @@
* inarchive pathname: Talco - Combat Circus/12 - A la pachenka.mp3
* and suffix: zip
*/
bool
archive_lookup(char *pathname, const char **archive,
const char **inpath, const char **suffix);
bool archive_lookup(char *pathname, char **archive, char **inpath, char **suffix)
{
char *pathdupe;
int len, idx;
struct stat st_info;
bool ret = false;
*archive = NULL;
*inpath = NULL;
*suffix = NULL;
pathdupe = g_strdup(pathname);
len = idx = strlen(pathname);
while (idx > 0) {
//try to stat if its real directory
if (stat(pathdupe, &st_info) == -1) {
if (errno != ENOTDIR) {
g_warning("stat %s failed (errno=%d)\n", pathdupe, errno);
break;
}
} else {
//is something found ins original path (is not an archive)
if (idx == len) {
break;
}
//its a file ?
if (S_ISREG(st_info.st_mode)) {
//so the upper should be file
pathname[idx] = 0;
ret = true;
*archive = pathname;
*inpath = pathname + idx+1;
//try to get suffix
*suffix = NULL;
while (idx > 0) {
if (pathname[idx] == '.') {
*suffix = pathname + idx + 1;
break;
}
idx--;
}
break;
} else {
g_warning("not a regular file %s\n", pathdupe);
break;
}
}
//find one dir up
while (idx > 0) {
if (pathdupe[idx] == '/') {
pathdupe[idx] = 0;
break;
}
idx--;
}
}
g_free(pathdupe);
return ret;
}
#endif

39
src/ArchivePlugin.cxx Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ArchivePlugin.hxx"
#include "ArchiveFile.hxx"
#include "util/Error.hxx"
#include <assert.h>
ArchiveFile *
archive_file_open(const struct archive_plugin *plugin, const char *path,
Error &error)
{
assert(plugin != nullptr);
assert(plugin->open != nullptr);
assert(path != nullptr);
ArchiveFile *file = plugin->open(path, error);
assert((file == nullptr) == error.IsDefined());
return file;
}

62
src/ArchivePlugin.hxx Normal file
View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ARCHIVE_PLUGIN_HXX
#define MPD_ARCHIVE_PLUGIN_HXX
struct InputStream;
class ArchiveFile;
class ArchiveVisitor;
class Error;
struct archive_plugin {
const char *name;
/**
* optional, set this to nullptr if the archive plugin doesn't
* have/need one this must false if there is an error and
* true otherwise
*/
bool (*init)(void);
/**
* optional, set this to nullptr if the archive plugin doesn't
* have/need one
*/
void (*finish)(void);
/**
* tryes to open archive file and associates handle with archive
* returns pointer to handle used is all operations with this archive
* or nullptr when opening fails
*/
ArchiveFile *(*open)(const char *path_fs, Error &error);
/**
* suffixes handled by this plugin.
* last element in these arrays must always be a nullptr
*/
const char *const*suffixes;
};
ArchiveFile *
archive_file_open(const struct archive_plugin *plugin, const char *path,
Error &error);
#endif

28
src/ArchiveVisitor.hxx Normal file
View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ARCHIVE_VISITOR_HXX
#define MPD_ARCHIVE_VISITOR_HXX
class ArchiveVisitor {
public:
virtual void VisitArchiveEntry(const char *path_utf8) = 0;
};
#endif

View File

@@ -33,6 +33,9 @@ struct Compressor {
struct Compressor *Compressor_new(unsigned int history)
{
struct Compressor *obj = malloc(sizeof(struct Compressor));
if (obj == NULL)
/* out of memory, not much we can do */
abort();
obj->prefs.target = TARGET;
obj->prefs.maxgain = GAINMAX;
@@ -61,6 +64,10 @@ void Compressor_delete(struct Compressor *obj)
static int *resizeArray(int *data, int newsz, int oldsz)
{
data = realloc(data, newsz*sizeof(int));
if (data == NULL)
/* out of memory, not much we can do */
abort();
if (newsz > oldsz)
memset(data + oldsz, 0, sizeof(int)*(newsz - oldsz));
return data;

View File

@@ -19,6 +19,10 @@ struct CompressorConfig {
struct Compressor;
#ifdef __cplusplus
extern "C" {
#endif
//! Create a new compressor (use history value of 0 for default)
struct Compressor *Compressor_new(unsigned int history);
@@ -34,7 +38,12 @@ struct CompressorConfig *Compressor_getConfig(struct Compressor *);
//! Process 16-bit signed data
void Compressor_Process_int16(struct Compressor *, int16_t *data, unsigned int count);
#ifdef __cplusplus
}
#endif
//! TODO: Compressor_Process_int32, Compressor_Process_float, others as needed
//! TODO: functions for getting at the peak/gain/clip history buffers (for monitoring)
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,42 +18,35 @@
*/
#include "config.h"
#include "audio_config.h"
#include "audio_format.h"
#include "audio_parser.h"
#include "output_internal.h"
#include "output_plugin.h"
#include "output_all.h"
#include "conf.h"
#include "mpd_error.h"
#include "AudioConfig.hxx"
#include "AudioFormat.hxx"
#include "AudioParser.hxx"
#include "ConfigData.hxx"
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
#include "util/Error.hxx"
#include "system/FatalError.hxx"
#include <glib.h>
static AudioFormat configured_audio_format;
#include <assert.h>
#include <stdlib.h>
static struct audio_format configured_audio_format;
void getOutputAudioFormat(const struct audio_format *inAudioFormat,
struct audio_format *outAudioFormat)
AudioFormat
getOutputAudioFormat(AudioFormat inAudioFormat)
{
*outAudioFormat = *inAudioFormat;
audio_format_mask_apply(outAudioFormat, &configured_audio_format);
AudioFormat out_audio_format = inAudioFormat;
out_audio_format.ApplyMask(configured_audio_format);
return out_audio_format;
}
void initAudioConfig(void)
{
const struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
GError *error = NULL;
bool ret;
if (param == NULL)
if (param == nullptr)
return;
ret = audio_format_parse(&configured_audio_format, param->value,
true, &error);
if (!ret)
MPD_ERROR("error parsing \"%s\" at line %i: %s",
CONF_AUDIO_OUTPUT_FORMAT, param->line,
error->message);
Error error;
if (!audio_format_parse(configured_audio_format, param->value.c_str(),
true, error))
FormatFatalError("error parsing line %i: %s",
param->line, error.GetMessage());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,15 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_AUDIO_CONFIG_H
#define MPD_AUDIO_CONFIG_H
#ifndef MPD_AUDIO_CONFIG_HXX
#define MPD_AUDIO_CONFIG_HXX
#include <stdbool.h>
struct AudioFormat;
struct audio_format;
void getOutputAudioFormat(const struct audio_format *inFormat,
struct audio_format *outFormat);
AudioFormat
getOutputAudioFormat(AudioFormat inFormat);
/* make sure initPlayerData is called before this function!! */
void initAudioConfig(void);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,71 +17,69 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "audio_format.h"
#include "AudioFormat.hxx"
#include <assert.h>
#include <stdio.h>
void
audio_format_mask_apply(struct audio_format *af,
const struct audio_format *mask)
AudioFormat::ApplyMask(AudioFormat mask)
{
assert(audio_format_valid(af));
assert(audio_format_mask_valid(mask));
assert(IsValid());
assert(mask.IsMaskValid());
if (mask->sample_rate != 0)
af->sample_rate = mask->sample_rate;
if (mask.sample_rate != 0)
sample_rate = mask.sample_rate;
if (mask->format != SAMPLE_FORMAT_UNDEFINED)
af->format = mask->format;
if (mask.format != SampleFormat::UNDEFINED)
format = mask.format;
if (mask->channels != 0)
af->channels = mask->channels;
if (mask.channels != 0)
channels = mask.channels;
assert(audio_format_valid(af));
assert(IsValid());
}
const char *
sample_format_to_string(enum sample_format format)
sample_format_to_string(SampleFormat format)
{
switch (format) {
case SAMPLE_FORMAT_UNDEFINED:
case SampleFormat::UNDEFINED:
return "?";
case SAMPLE_FORMAT_S8:
case SampleFormat::S8:
return "8";
case SAMPLE_FORMAT_S16:
case SampleFormat::S16:
return "16";
case SAMPLE_FORMAT_S24_P32:
case SampleFormat::S24_P32:
return "24";
case SAMPLE_FORMAT_S32:
case SampleFormat::S32:
return "32";
case SAMPLE_FORMAT_FLOAT:
case SampleFormat::FLOAT:
return "f";
case SAMPLE_FORMAT_DSD:
case SampleFormat::DSD:
return "dsd";
}
/* unreachable */
assert(false);
return "?";
gcc_unreachable();
}
const char *
audio_format_to_string(const struct audio_format *af,
audio_format_to_string(const AudioFormat af,
struct audio_format_string *s)
{
assert(af != NULL);
assert(s != NULL);
assert(s != nullptr);
snprintf(s->buffer, sizeof(s->buffer), "%u:%s:%u",
af->sample_rate, sample_format_to_string(af->format),
af->channels);
af.sample_rate, sample_format_to_string(af.format),
af.channels);
return s->buffer;
}

315
src/AudioFormat.hxx Normal file
View File

@@ -0,0 +1,315 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_AUDIO_FORMAT_HXX
#define MPD_AUDIO_FORMAT_HXX
#include "Compiler.h"
#include <stdint.h>
#include <assert.h>
#if defined(WIN32) && GCC_CHECK_VERSION(4,6)
/* on WIN32, "FLOAT" is already defined, and this triggers -Wshadow */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
enum class SampleFormat : uint8_t {
UNDEFINED = 0,
S8,
S16,
/**
* Signed 24 bit integer samples, packed in 32 bit integers
* (the most significant byte is filled with the sign bit).
*/
S24_P32,
S32,
/**
* 32 bit floating point samples in the host's format. The
* range is -1.0f to +1.0f.
*/
FLOAT,
/**
* Direct Stream Digital. 1-bit samples; each frame has one
* byte (8 samples) per channel.
*/
DSD,
};
#if defined(WIN32) && GCC_CHECK_VERSION(4,6)
#pragma GCC diagnostic pop
#endif
static constexpr unsigned MAX_CHANNELS = 8;
/**
* This structure describes the format of a raw PCM stream.
*/
struct AudioFormat {
/**
* The sample rate in Hz. A better name for this attribute is
* "frame rate", because technically, you have two samples per
* frame in stereo sound.
*/
uint32_t sample_rate;
/**
* The format samples are stored in. See the #sample_format
* enum for valid values.
*/
SampleFormat format;
/**
* The number of channels. Only mono (1) and stereo (2) are
* fully supported currently.
*/
uint8_t channels;
AudioFormat() = default;
constexpr AudioFormat(uint32_t _sample_rate,
SampleFormat _format, uint8_t _channels)
:sample_rate(_sample_rate),
format(_format), channels(_channels) {}
static constexpr AudioFormat Undefined() {
return AudioFormat(0, SampleFormat::UNDEFINED,0);
}
/**
* Clears the #audio_format object, i.e. sets all attributes to an
* undefined (invalid) value.
*/
void Clear() {
sample_rate = 0;
format = SampleFormat::UNDEFINED;
channels = 0;
}
/**
* Checks whether the object has a defined value.
*/
constexpr bool IsDefined() const {
return sample_rate != 0;
}
/**
* Checks whether the object is full, i.e. all attributes are
* defined. This is more complete than IsDefined(), but
* slower.
*/
constexpr bool IsFullyDefined() const {
return sample_rate != 0 && format != SampleFormat::UNDEFINED &&
channels != 0;
}
/**
* Checks whether the object has at least one defined value.
*/
constexpr bool IsMaskDefined() const {
return sample_rate != 0 || format != SampleFormat::UNDEFINED ||
channels != 0;
}
bool IsValid() const;
bool IsMaskValid() const;
constexpr bool operator==(const AudioFormat other) const {
return sample_rate == other.sample_rate &&
format == other.format &&
channels == other.channels;
}
constexpr bool operator!=(const AudioFormat other) const {
return !(*this == other);
}
void ApplyMask(AudioFormat mask);
/**
* Returns the size of each (mono) sample in bytes.
*/
unsigned GetSampleSize() const;
/**
* Returns the size of each full frame in bytes.
*/
unsigned GetFrameSize() const;
/**
* Returns the floating point factor which converts a time
* span to a storage size in bytes.
*/
double GetTimeToSize() const;
};
/**
* Buffer for audio_format_string().
*/
struct audio_format_string {
char buffer[24];
};
/**
* Checks whether the sample rate is valid.
*
* @param sample_rate the sample rate in Hz
*/
static constexpr inline bool
audio_valid_sample_rate(unsigned sample_rate)
{
return sample_rate > 0 && sample_rate < (1 << 30);
}
/**
* Checks whether the sample format is valid.
*
* @param bits the number of significant bits per sample
*/
static inline bool
audio_valid_sample_format(SampleFormat format)
{
switch (format) {
case SampleFormat::S8:
case SampleFormat::S16:
case SampleFormat::S24_P32:
case SampleFormat::S32:
case SampleFormat::FLOAT:
case SampleFormat::DSD:
return true;
case SampleFormat::UNDEFINED:
break;
}
return false;
}
/**
* Checks whether the number of channels is valid.
*/
static constexpr inline bool
audio_valid_channel_count(unsigned channels)
{
return channels >= 1 && channels <= MAX_CHANNELS;
}
/**
* Returns false if the format is not valid for playback with MPD.
* This function performs some basic validity checks.
*/
inline bool
AudioFormat::IsValid() const
{
return audio_valid_sample_rate(sample_rate) &&
audio_valid_sample_format(format) &&
audio_valid_channel_count(channels);
}
/**
* Returns false if the format mask is not valid for playback with
* MPD. This function performs some basic validity checks.
*/
inline bool
AudioFormat::IsMaskValid() const
{
return (sample_rate == 0 ||
audio_valid_sample_rate(sample_rate)) &&
(format == SampleFormat::UNDEFINED ||
audio_valid_sample_format(format)) &&
(channels == 0 || audio_valid_channel_count(channels));
}
gcc_const
static inline unsigned
sample_format_size(SampleFormat format)
{
switch (format) {
case SampleFormat::S8:
return 1;
case SampleFormat::S16:
return 2;
case SampleFormat::S24_P32:
case SampleFormat::S32:
case SampleFormat::FLOAT:
return 4;
case SampleFormat::DSD:
/* each frame has 8 samples per channel */
return 1;
case SampleFormat::UNDEFINED:
return 0;
}
assert(false);
gcc_unreachable();
}
inline unsigned
AudioFormat::GetSampleSize() const
{
return sample_format_size(format);
}
inline unsigned
AudioFormat::GetFrameSize() const
{
return GetSampleSize() * channels;
}
inline double
AudioFormat::GetTimeToSize() const
{
return sample_rate * GetFrameSize();
}
/**
* Renders a #sample_format enum into a string, e.g. for printing it
* in a log file.
*
* @param format a #sample_format enum value
* @return the string
*/
gcc_pure gcc_malloc
const char *
sample_format_to_string(SampleFormat format);
/**
* Renders the #audio_format object into a string, e.g. for printing
* it in a log file.
*
* @param af the #audio_format object
* @param s a buffer to print into
* @return the string, or nullptr if the #audio_format object is invalid
*/
gcc_pure gcc_malloc
const char *
audio_format_to_string(AudioFormat af,
struct audio_format_string *s);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,27 +23,19 @@
*/
#include "config.h"
#include "audio_parser.h"
#include "audio_format.h"
#include "audio_check.h"
#include "gcc.h"
#include "AudioParser.hxx"
#include "AudioFormat.hxx"
#include "CheckAudioFormat.hxx"
#include "util/Error.hxx"
#include "Compiler.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
/**
* The GLib quark used for errors reported by this library.
*/
static inline GQuark
audio_parser_quark(void)
{
return g_quark_from_static_string("audio_parser");
}
static bool
parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r,
const char **endptr_r, GError **error_r)
const char **endptr_r, Error &error)
{
unsigned long value;
char *endptr;
@@ -56,10 +48,10 @@ parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r,
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
"Failed to parse the sample rate");
error.Set(audio_format_domain,
"Failed to parse the sample rate");
return false;
} else if (!audio_check_sample_rate(value, error_r))
} else if (!audio_check_sample_rate(value, error))
return false;
*sample_rate_r = value;
@@ -69,45 +61,45 @@ parse_sample_rate(const char *src, bool mask, uint32_t *sample_rate_r,
static bool
parse_sample_format(const char *src, bool mask,
enum sample_format *sample_format_r,
const char **endptr_r, GError **error_r)
SampleFormat *sample_format_r,
const char **endptr_r, Error &error)
{
unsigned long value;
char *endptr;
enum sample_format sample_format;
SampleFormat sample_format;
if (mask && *src == '*') {
*sample_format_r = SAMPLE_FORMAT_UNDEFINED;
*sample_format_r = SampleFormat::UNDEFINED;
*endptr_r = src + 1;
return true;
}
if (*src == 'f') {
*sample_format_r = SAMPLE_FORMAT_FLOAT;
*sample_format_r = SampleFormat::FLOAT;
*endptr_r = src + 1;
return true;
}
if (memcmp(src, "dsd", 3) == 0) {
*sample_format_r = SAMPLE_FORMAT_DSD;
*sample_format_r = SampleFormat::DSD;
*endptr_r = src + 3;
return true;
}
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
"Failed to parse the sample format");
error.Set(audio_format_domain,
"Failed to parse the sample format");
return false;
}
switch (value) {
case 8:
sample_format = SAMPLE_FORMAT_S8;
sample_format = SampleFormat::S8;
break;
case 16:
sample_format = SAMPLE_FORMAT_S16;
sample_format = SampleFormat::S16;
break;
case 24:
@@ -115,16 +107,16 @@ parse_sample_format(const char *src, bool mask,
/* for backwards compatibility */
endptr += 2;
sample_format = SAMPLE_FORMAT_S24_P32;
sample_format = SampleFormat::S24_P32;
break;
case 32:
sample_format = SAMPLE_FORMAT_S32;
sample_format = SampleFormat::S32;
break;
default:
g_set_error(error_r, audio_parser_quark(), 0,
"Invalid sample format: %lu", value);
error.Format(audio_format_domain,
"Invalid sample format: %lu", value);
return false;
}
@@ -137,7 +129,7 @@ parse_sample_format(const char *src, bool mask,
static bool
parse_channel_count(const char *src, bool mask, uint8_t *channels_r,
const char **endptr_r, GError **error_r)
const char **endptr_r, Error &error)
{
unsigned long value;
char *endptr;
@@ -150,10 +142,10 @@ parse_channel_count(const char *src, bool mask, uint8_t *channels_r,
value = strtoul(src, &endptr, 10);
if (endptr == src) {
g_set_error(error_r, audio_parser_quark(), 0,
"Failed to parse the channel count");
error.Set(audio_format_domain,
"Failed to parse the channel count");
return false;
} else if (!audio_check_channel_count(value, error_r))
} else if (!audio_check_channel_count(value, error))
return false;
*channels_r = value;
@@ -162,14 +154,14 @@ parse_channel_count(const char *src, bool mask, uint8_t *channels_r,
}
bool
audio_format_parse(struct audio_format *dest, const char *src,
bool mask, GError **error_r)
audio_format_parse(AudioFormat &dest, const char *src,
bool mask, Error &error)
{
uint32_t rate;
enum sample_format sample_format;
SampleFormat sample_format;
uint8_t channels;
audio_format_clear(dest);
dest.Clear();
/* parse sample rate */
@@ -178,12 +170,11 @@ audio_format_parse(struct audio_format *dest, const char *src,
rate = 0;
#endif
if (!parse_sample_rate(src, mask, &rate, &src, error_r))
if (!parse_sample_rate(src, mask, &rate, &src, error))
return false;
if (*src++ != ':') {
g_set_error(error_r, audio_parser_quark(), 0,
"Sample format missing");
error.Set(audio_format_domain, "Sample format missing");
return false;
}
@@ -191,32 +182,32 @@ audio_format_parse(struct audio_format *dest, const char *src,
#if GCC_CHECK_VERSION(4,7)
/* workaround -Wmaybe-uninitialized false positive */
sample_format = SAMPLE_FORMAT_UNDEFINED;
sample_format = SampleFormat::UNDEFINED;
#endif
if (!parse_sample_format(src, mask, &sample_format, &src, error_r))
if (!parse_sample_format(src, mask, &sample_format, &src, error))
return false;
if (*src++ != ':') {
g_set_error(error_r, audio_parser_quark(), 0,
"Channel count missing");
error.Set(audio_format_domain, "Channel count missing");
return false;
}
/* parse channel count */
if (!parse_channel_count(src, mask, &channels, &src, error_r))
if (!parse_channel_count(src, mask, &channels, &src, error))
return false;
if (*src != 0) {
g_set_error(error_r, audio_parser_quark(), 0,
error.Format(audio_format_domain,
"Extra data after channel count: %s", src);
return false;
}
audio_format_init(dest, rate, sample_format, channels);
assert(mask ? audio_format_mask_valid(dest)
: audio_format_valid(dest));
dest = AudioFormat(rate, sample_format, channels);
assert(mask
? dest.IsMaskValid()
: dest.IsValid());
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -22,14 +22,11 @@
* Parser functions for audio related objects.
*/
#ifndef AUDIO_PARSER_H
#define AUDIO_PARSER_H
#ifndef MPD_AUDIO_PARSER_HXX
#define MPD_AUDIO_PARSER_HXX
#include <glib.h>
#include <stdbool.h>
struct audio_format;
struct AudioFormat;
class Error;
/**
* Parses a string in the form "SAMPLE_RATE:BITS:CHANNELS" into an
@@ -43,7 +40,7 @@ struct audio_format;
* @return true on success
*/
bool
audio_format_parse(struct audio_format *dest, const char *src,
bool mask, GError **error_r);
audio_format_parse(AudioFormat &dest, const char *src,
bool mask, Error &error);
#endif

151
src/AvahiPoll.cxx Normal file
View File

@@ -0,0 +1,151 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "AvahiPoll.hxx"
#include "event/Loop.hxx"
#include "event/SocketMonitor.hxx"
#include "event/TimeoutMonitor.hxx"
static unsigned
FromAvahiWatchEvent(AvahiWatchEvent e)
{
return (e & AVAHI_WATCH_IN ? SocketMonitor::READ : 0) |
(e & AVAHI_WATCH_OUT ? SocketMonitor::WRITE : 0) |
(e & AVAHI_WATCH_ERR ? SocketMonitor::ERROR : 0) |
(e & AVAHI_WATCH_HUP ? SocketMonitor::HANGUP : 0);
}
static AvahiWatchEvent
ToAvahiWatchEvent(unsigned e)
{
return AvahiWatchEvent((e & SocketMonitor::READ ? AVAHI_WATCH_IN : 0) |
(e & SocketMonitor::WRITE ? AVAHI_WATCH_OUT : 0) |
(e & SocketMonitor::ERROR ? AVAHI_WATCH_ERR : 0) |
(e & SocketMonitor::HANGUP ? AVAHI_WATCH_HUP : 0));
}
struct AvahiWatch final : private SocketMonitor {
private:
const AvahiWatchCallback callback;
void *const userdata;
AvahiWatchEvent received;
public:
AvahiWatch(int _fd, AvahiWatchEvent _event,
AvahiWatchCallback _callback, void *_userdata,
EventLoop &_loop)
:SocketMonitor(_fd, _loop),
callback(_callback), userdata(_userdata),
received(AvahiWatchEvent(0)) {
Schedule(FromAvahiWatchEvent(_event));
}
~AvahiWatch() {
Steal();
}
static void WatchUpdate(AvahiWatch *w, AvahiWatchEvent event) {
w->Schedule(FromAvahiWatchEvent(event));
}
static AvahiWatchEvent WatchGetEvents(AvahiWatch *w) {
return w->received;
}
static void WatchFree(AvahiWatch *w) {
delete w;
}
protected:
virtual bool OnSocketReady(unsigned flags) {
received = ToAvahiWatchEvent(flags);
callback(this, Get(), received, userdata);
received = AvahiWatchEvent(0);
return true;
}
};
static constexpr unsigned
TimevalToMS(const timeval &tv)
{
return tv.tv_sec * 1000 + (tv.tv_usec + 500) / 1000;
}
struct AvahiTimeout final : private TimeoutMonitor {
private:
const AvahiTimeoutCallback callback;
void *const userdata;
public:
AvahiTimeout(const struct timeval *tv,
AvahiTimeoutCallback _callback, void *_userdata,
EventLoop &_loop)
:TimeoutMonitor(_loop),
callback(_callback), userdata(_userdata) {
if (tv != nullptr)
Schedule(TimevalToMS(*tv));
}
static void TimeoutUpdate(AvahiTimeout *t, const struct timeval *tv) {
if (tv != nullptr)
t->Schedule(TimevalToMS(*tv));
else
t->Cancel();
}
static void TimeoutFree(AvahiTimeout *t) {
delete t;
}
protected:
virtual void OnTimeout() {
callback(this, userdata);
}
};
MyAvahiPoll::MyAvahiPoll(EventLoop &_loop):event_loop(_loop)
{
watch_new = WatchNew;
watch_update = AvahiWatch::WatchUpdate;
watch_get_events = AvahiWatch::WatchGetEvents;
watch_free = AvahiWatch::WatchFree;
timeout_new = TimeoutNew;
timeout_update = AvahiTimeout::TimeoutUpdate;
timeout_free = AvahiTimeout::TimeoutFree;
}
AvahiWatch *
MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event,
AvahiWatchCallback callback, void *userdata) {
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
return new AvahiWatch(fd, event, callback, userdata,
poll.event_loop);
}
AvahiTimeout *
MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv,
AvahiTimeoutCallback callback, void *userdata) {
const MyAvahiPoll &poll = *(const MyAvahiPoll *)api;
return new AvahiTimeout(tv, callback, userdata,
poll.event_loop);
}

48
src/AvahiPoll.hxx Normal file
View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_AVAHI_POLL_HXX
#define MPD_AVAHI_POLL_HXX
#include "check.h"
#include "Compiler.h"
#include <avahi-common/watch.h>
class EventLoop;
class MyAvahiPoll final : public AvahiPoll {
EventLoop &event_loop;
public:
MyAvahiPoll(EventLoop &_loop);
private:
static AvahiWatch *WatchNew(const AvahiPoll *api, int fd,
AvahiWatchEvent event,
AvahiWatchCallback callback,
void *userdata);
static AvahiTimeout *TimeoutNew(const AvahiPoll *api,
const struct timeval *tv,
AvahiTimeoutCallback callback,
void *userdata);
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,17 +17,22 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "audio_check.h"
#include "audio_format.h"
#include "config.h"
#include "CheckAudioFormat.hxx"
#include "AudioFormat.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <assert.h>
const Domain audio_format_domain("audio_format");
bool
audio_check_sample_rate(unsigned long sample_rate, GError **error_r)
audio_check_sample_rate(unsigned long sample_rate, Error &error)
{
if (!audio_valid_sample_rate(sample_rate)) {
g_set_error(error_r, audio_format_quark(), 0,
"Invalid sample rate: %lu", sample_rate);
error.Format(audio_format_domain,
"Invalid sample rate: %lu", sample_rate);
return false;
}
@@ -35,11 +40,12 @@ audio_check_sample_rate(unsigned long sample_rate, GError **error_r)
}
bool
audio_check_sample_format(enum sample_format sample_format, GError **error_r)
audio_check_sample_format(SampleFormat sample_format, Error &error)
{
if (!audio_valid_sample_format(sample_format)) {
g_set_error(error_r, audio_format_quark(), 0,
"Invalid sample format: %u", sample_format);
error.Format(audio_format_domain,
"Invalid sample format: %u",
unsigned(sample_format));
return false;
}
@@ -47,11 +53,11 @@ audio_check_sample_format(enum sample_format sample_format, GError **error_r)
}
bool
audio_check_channel_count(unsigned channels, GError **error_r)
audio_check_channel_count(unsigned channels, Error &error)
{
if (!audio_valid_channel_count(channels)) {
g_set_error(error_r, audio_format_quark(), 0,
"Invalid channel count: %u", channels);
error.Format(audio_format_domain,
"Invalid channel count: %u", channels);
return false;
}
@@ -59,15 +65,15 @@ audio_check_channel_count(unsigned channels, GError **error_r)
}
bool
audio_format_init_checked(struct audio_format *af, unsigned long sample_rate,
enum sample_format sample_format, unsigned channels,
GError **error_r)
audio_format_init_checked(AudioFormat &af, unsigned long sample_rate,
SampleFormat sample_format, unsigned channels,
Error &error)
{
if (audio_check_sample_rate(sample_rate, error_r) &&
audio_check_sample_format(sample_format, error_r) &&
audio_check_channel_count(channels, error_r)) {
audio_format_init(af, sample_rate, sample_format, channels);
assert(audio_format_valid(af));
if (audio_check_sample_rate(sample_rate, error) &&
audio_check_sample_format(sample_format, error) &&
audio_check_channel_count(channels, error)) {
af = AudioFormat(sample_rate, sample_format, channels);
assert(af.IsValid());
return true;
} else
return false;

46
src/CheckAudioFormat.hxx Normal file
View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CHECK_AUDIO_FORMAT_HXX
#define MPD_CHECK_AUDIO_FORMAT_HXX
#include "AudioFormat.hxx"
class Error;
extern const class Domain audio_format_domain;
bool
audio_check_sample_rate(unsigned long sample_rate, Error &error);
bool
audio_check_sample_format(SampleFormat sample_format, Error &error);
bool
audio_check_channel_count(unsigned sample_format, Error &error);
/**
* Wrapper for audio_format_init(), which checks all attributes.
*/
bool
audio_format_init_checked(AudioFormat &af, unsigned long sample_rate,
SampleFormat sample_format, unsigned channels,
Error &error);
#endif

24
src/Client.cxx Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "util/Domain.hxx"
const Domain client_domain("client");

187
src/Client.hxx Normal file
View File

@@ -0,0 +1,187 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CLIENT_H
#define MPD_CLIENT_H
#include "check.h"
#include "ClientMessage.hxx"
#include "command/CommandListBuilder.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "Compiler.h"
#include <set>
#include <string>
#include <list>
#include <stddef.h>
#include <stdarg.h>
struct sockaddr;
class EventLoop;
struct Partition;
class Client final : private FullyBufferedSocket, TimeoutMonitor {
public:
Partition &partition;
struct playlist &playlist;
struct PlayerControl &player_control;
unsigned permission;
/** the uid of the client process, or -1 if unknown */
int uid;
CommandListBuilder cmd_list;
unsigned int num; /* client number */
/** is this client waiting for an "idle" response? */
bool idle_waiting;
/** idle flags pending on this client, to be sent as soon as
the client enters "idle" */
unsigned idle_flags;
/** idle flags that the client wants to receive */
unsigned idle_subscriptions;
/**
* A list of channel names this client is subscribed to.
*/
std::set<std::string> subscriptions;
/**
* The number of subscriptions in #subscriptions. Used to
* limit the number of subscriptions.
*/
unsigned num_subscriptions;
/**
* A list of messages this client has received.
*/
std::list<ClientMessage> messages;
Client(EventLoop &loop, Partition &partition,
int fd, int uid, int num);
bool IsConnected() const {
return FullyBufferedSocket::IsDefined();
}
gcc_pure
bool IsExpired() const {
return !FullyBufferedSocket::IsDefined();
}
void Close();
void SetExpired();
using FullyBufferedSocket::Write;
/**
* returns the uid of the client process, or a negative value
* if the uid is unknown
*/
int GetUID() const {
return uid;
}
/**
* Is this client running on the same machine, connected with
* a local (UNIX domain) socket?
*/
bool IsLocal() const {
return uid > 0;
}
unsigned GetPermission() const {
return permission;
}
void SetPermission(unsigned _permission) {
permission = _permission;
}
/**
* Send "idle" response to this client.
*/
void IdleNotify();
void IdleAdd(unsigned flags);
bool IdleWait(unsigned flags);
enum class SubscribeResult {
/** success */
OK,
/** invalid channel name */
INVALID,
/** already subscribed to this channel */
ALREADY,
/** too many subscriptions */
FULL,
};
gcc_pure
bool IsSubscribed(const char *channel_name) const {
return subscriptions.find(channel_name) != subscriptions.end();
}
SubscribeResult Subscribe(const char *channel);
bool Unsubscribe(const char *channel);
void UnsubscribeAll();
bool PushMessage(const ClientMessage &msg);
private:
/* virtual methods from class BufferedSocket */
virtual InputResult OnSocketInput(void *data, size_t length) override;
virtual void OnSocketError(Error &&error) override;
virtual void OnSocketClosed() override;
/* virtual methods from class TimeoutMonitor */
virtual void OnTimeout() override;
};
void client_manager_init(void);
void
client_new(EventLoop &loop, Partition &partition,
int fd, const struct sockaddr *sa, size_t sa_length, int uid);
/**
* Write a C string to the client.
*/
void client_puts(Client &client, const char *s);
/**
* Write a printf-like formatted string to the client.
*/
void client_vprintf(Client &client, const char *fmt, va_list args);
/**
* Write a printf-like formatted string to the client.
*/
gcc_printf(2,3)
void
client_printf(Client &client, const char *fmt, ...);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,16 +18,20 @@
*/
#include "config.h"
#include "mixer_api.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "mixer"
#include "ClientInternal.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
void
mixer_init(struct mixer *mixer, const struct mixer_plugin *plugin)
Client::OnSocketError(Error &&error)
{
mixer->plugin = plugin;
mixer->mutex = g_mutex_new();
mixer->open = false;
mixer->failed = false;
FormatError(error, "error on client %d", num);
SetExpired();
}
void
Client::OnSocketClosed()
{
SetExpired();
}

43
src/ClientExpire.cxx Normal file
View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "Log.hxx"
void
Client::SetExpired()
{
if (IsExpired())
return;
FullyBufferedSocket::Close();
TimeoutMonitor::Schedule(0);
}
void
Client::OnTimeout()
{
if (!IsExpired()) {
assert(!idle_waiting);
FormatDebug(client_domain, "[%u] timeout", num);
}
Close();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,9 +17,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "client_file.h"
#include "client.h"
#include "ack.h"
#include "config.h"
#include "ClientFile.hxx"
#include "Client.hxx"
#include "protocol/Ack.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <sys/stat.h>
#include <sys/types.h>
@@ -27,18 +32,16 @@
#include <unistd.h>
bool
client_allow_file(const struct client *client, const char *path_fs,
GError **error_r)
client_allow_file(const Client &client, Path path_fs, Error &error)
{
#ifdef WIN32
(void)client;
(void)path_fs;
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
"Access denied");
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
return false;
#else
const int uid = client_get_uid(client);
const int uid = client.GetUID();
if (uid >= 0 && (uid_t)uid == geteuid())
/* always allow access if user runs his own MPD
instance */
@@ -46,22 +49,19 @@ client_allow_file(const struct client *client, const char *path_fs,
if (uid <= 0) {
/* unauthenticated client */
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
"Access denied");
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
return false;
}
struct stat st;
if (stat(path_fs, &st) < 0) {
g_set_error(error_r, g_file_error_quark(), errno,
"%s", g_strerror(errno));
if (!StatFile(path_fs, st)) {
error.SetErrno();
return false;
}
if (st.st_uid != (uid_t)uid && (st.st_mode & 0444) != 0444) {
/* client is not owner */
g_set_error(error_r, ack_quark(), ACK_ERROR_PERMISSION,
"Access denied");
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,13 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CLIENT_FILE_H
#define MPD_CLIENT_FILE_H
#ifndef MPD_CLIENT_FILE_HXX
#define MPD_CLIENT_FILE_HXX
#include <glib.h>
#include <stdbool.h>
struct client;
class Client;
class Path;
class Error;
/**
* Is this client allowed to use the specified local file?
@@ -35,9 +34,7 @@ struct client;
* @param path_fs the absolute path name in filesystem encoding
* @return true if access is allowed
*/
G_GNUC_PURE
bool
client_allow_file(const struct client *client, const char *path_fs,
GError **error_r);
client_allow_file(const Client &client, Path path_fs, Error &error);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,18 +18,14 @@
*/
#include "config.h"
#include "client_internal.h"
#include "conf.h"
#include <assert.h>
#include "ClientInternal.hxx"
#include "ClientList.hxx"
#include "ConfigGlobal.hxx"
#define CLIENT_TIMEOUT_DEFAULT (60)
#define CLIENT_MAX_CONNECTIONS_DEFAULT (10)
#define CLIENT_MAX_COMMAND_LIST_DEFAULT (2048*1024)
#define CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT (8192*1024)
/* set this to zero to indicate we have no possible clients */
unsigned int client_max_connections;
int client_timeout;
size_t client_max_command_list_size;
size_t client_max_output_buffer_size;
@@ -38,9 +34,6 @@ void client_manager_init(void)
{
client_timeout = config_get_positive(CONF_CONN_TIMEOUT,
CLIENT_TIMEOUT_DEFAULT);
client_max_connections =
config_get_positive(CONF_MAX_CONN,
CLIENT_MAX_CONNECTIONS_DEFAULT);
client_max_command_list_size =
config_get_positive(CONF_MAX_COMMAND_LIST_SIZE,
CLIENT_MAX_COMMAND_LIST_DEFAULT / 1024)
@@ -51,23 +44,3 @@ void client_manager_init(void)
CLIENT_MAX_OUTPUT_BUFFER_SIZE_DEFAULT / 1024)
* 1024;
}
static void client_close_all(void)
{
while (!client_list_is_empty()) {
struct client *client = client_list_get_first();
client_close(client);
}
assert(client_list_is_empty());
}
void client_manager_deinit(void)
{
client_close_all();
client_max_connections = 0;
client_deinit_expire();
}

75
src/ClientIdle.cxx Normal file
View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "Idle.hxx"
#include <assert.h>
void
Client::IdleNotify()
{
assert(idle_waiting);
assert(idle_flags != 0);
unsigned flags = idle_flags;
idle_flags = 0;
idle_waiting = false;
const char *const*idle_names = idle_get_names();
for (unsigned i = 0; idle_names[i]; ++i) {
if (flags & (1 << i) & idle_subscriptions)
client_printf(*this, "changed: %s\n",
idle_names[i]);
}
client_puts(*this, "OK\n");
TimeoutMonitor::ScheduleSeconds(client_timeout);
}
void
Client::IdleAdd(unsigned flags)
{
if (IsExpired())
return;
idle_flags |= flags;
if (idle_waiting && (idle_flags & idle_subscriptions))
IdleNotify();
}
bool
Client::IdleWait(unsigned flags)
{
assert(!idle_waiting);
idle_waiting = true;
idle_subscriptions = flags;
if (idle_flags & idle_subscriptions) {
IdleNotify();
return true;
} else {
/* disable timeouts while in "idle" */
TimeoutMonitor::Cancel();
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,27 +17,23 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_INPUT_INTERNAL_H
#define MPD_INPUT_INTERNAL_H
#ifndef MPD_CLIENT_INTERNAL_HXX
#define MPD_CLIENT_INTERNAL_HXX
#include "check.h"
#include "Client.hxx"
#include "command/CommandResult.hxx"
#include <glib.h>
static constexpr unsigned CLIENT_MAX_SUBSCRIPTIONS = 16;
static constexpr unsigned CLIENT_MAX_MESSAGES = 64;
struct input_stream;
struct input_plugin;
extern const class Domain client_domain;
void
input_stream_init(struct input_stream *is, const struct input_plugin *plugin,
const char *uri, GMutex *mutex, GCond *cond);
extern int client_timeout;
extern size_t client_max_command_list_size;
extern size_t client_max_output_buffer_size;
void
input_stream_deinit(struct input_stream *is);
void
input_stream_signal_client(struct input_stream *is);
void
input_stream_set_ready(struct input_stream *is);
CommandResult
client_process_line(Client &client, char *line);
#endif

56
src/ClientList.cxx Normal file
View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientList.hxx"
#include "ClientInternal.hxx"
#include <algorithm>
#include <assert.h>
void
ClientList::Remove(Client &client)
{
assert(size > 0);
assert(!list.empty());
auto i = std::find(list.begin(), list.end(), &client);
assert(i != list.end());
list.erase(i);
--size;
}
void
ClientList::CloseAll()
{
while (!list.empty())
list.front()->Close();
assert(size == 0);
}
void
ClientList::IdleAdd(unsigned flags)
{
assert(flags != 0);
for (const auto &client : list)
client->IdleAdd(flags);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,38 +17,48 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_STATS_H
#define MPD_STATS_H
#ifndef MPD_CLIENT_LIST_HXX
#define MPD_CLIENT_LIST_HXX
#include <glib.h>
#include <list>
struct client;
class Client;
struct stats {
GTimer *timer;
class ClientList {
const unsigned max_size;
/** number of song files in the music directory */
unsigned song_count;
unsigned size;
std::list<Client *> list;
/** sum of all song durations in the music directory (in
seconds) */
unsigned long song_duration;
public:
ClientList(unsigned _max_size)
:max_size(_max_size), size(0) {}
~ClientList() {
CloseAll();
}
/** number of distinct artist names in the music directory */
unsigned artist_count;
std::list<Client *>::iterator begin() {
return list.begin();
}
/** number of distinct album names in the music directory */
unsigned album_count;
std::list<Client *>::iterator end() {
return list.end();
}
bool IsFull() const {
return size >= max_size;
}
void Add(Client &client) {
list.push_front(&client);
++size;
}
void Remove(Client &client);
void CloseAll();
void IdleAdd(unsigned flags);
};
extern struct stats stats;
void stats_global_init(void);
void stats_global_finish(void);
void stats_update(void);
int stats_print(struct client *client);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,26 +17,25 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_SIMPLE_DB_PLUGIN_H
#define MPD_SIMPLE_DB_PLUGIN_H
#include "ClientMessage.hxx"
#include "util/CharUtil.hxx"
#include "Compiler.h"
#include <glib.h>
#include <stdbool.h>
#include <time.h>
extern const struct db_plugin simple_db_plugin;
struct db;
G_GNUC_PURE
struct directory *
simple_db_get_root(struct db *db);
gcc_const
static bool
valid_channel_char(const char ch)
{
return IsAlphaNumericASCII(ch) ||
ch == '_' || ch == '-' || ch == '.' || ch == ':';
}
bool
simple_db_save(struct db *db, GError **error_r);
client_message_valid_channel_name(const char *name)
{
do {
if (!valid_channel_char(*name))
return false;
} while (*++name != 0);
G_GNUC_PURE
time_t
simple_db_get_mtime(const struct db *db);
#endif
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,35 +17,36 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* The .mpdignore backend code.
*
*/
#ifndef MPD_CLIENT_MESSAGE_H
#define MPD_CLIENT_MESSAGE_H
#ifndef MPD_EXCLUDE_H
#define MPD_EXCLUDE_H
#include "Compiler.h"
#include <glib.h>
#include <stdbool.h>
#include <string>
/**
* Loads and parses a .mpdignore file.
* A client-to-client message.
*/
GSList *
exclude_list_load(const char *path_fs);
class ClientMessage {
std::string channel, message;
/**
* Frees a list returned by exclude_list_load().
*/
void
exclude_list_free(GSList *list);
public:
template<typename T, typename U>
ClientMessage(T &&_channel, U &&_message)
:channel(std::forward<T>(_channel)),
message(std::forward<U>(_message)) {}
/**
* Checks whether one of the patterns in the .mpdignore file matches
* the specified file name.
*/
const char *GetChannel() const {
return channel.c_str();
}
const char *GetMessage() const {
return message.c_str();
}
};
gcc_pure
bool
exclude_list_check(GSList *list, const char *name_fs);
client_message_valid_channel_name(const char *name);
#endif

126
src/ClientNew.cxx Normal file
View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "ClientList.hxx"
#include "Partition.hxx"
#include "Instance.hxx"
#include "system/fd_util.h"
#include "system/Resolver.hxx"
#include "Permission.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
#include <sys/types.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#endif
#include <unistd.h>
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#endif
static const char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
Client::Client(EventLoop &_loop, Partition &_partition,
int _fd, int _uid, int _num)
:FullyBufferedSocket(_fd, _loop, 16384, client_max_output_buffer_size),
TimeoutMonitor(_loop),
partition(_partition),
playlist(partition.playlist), player_control(partition.pc),
permission(getDefaultPermissions()),
uid(_uid),
num(_num),
idle_waiting(false), idle_flags(0),
num_subscriptions(0)
{
TimeoutMonitor::ScheduleSeconds(client_timeout);
}
void
client_new(EventLoop &loop, Partition &partition,
int fd, const struct sockaddr *sa, size_t sa_length, int uid)
{
static unsigned int next_client_num;
char *remote;
assert(fd >= 0);
#ifdef HAVE_LIBWRAP
if (sa->sa_family != AF_UNIX) {
char *hostaddr = sockaddr_to_string(sa, sa_length,
IgnoreError());
const char *progname = g_get_prgname();
struct request_info req;
request_init(&req, RQ_FILE, fd, RQ_DAEMON, progname, 0);
fromhost(&req);
if (!hosts_access(&req)) {
/* tcp wrappers says no */
FormatWarning(client_domain,
"libwrap refused connection (libwrap=%s) from %s",
progname, hostaddr);
g_free(hostaddr);
close_socket(fd);
return;
}
g_free(hostaddr);
}
#endif /* HAVE_WRAP */
ClientList &client_list = *partition.instance.client_list;
if (client_list.IsFull()) {
LogWarning(client_domain, "Max connections reached");
close_socket(fd);
return;
}
Client *client = new Client(loop, partition, fd, uid,
next_client_num++);
(void)send(fd, GREETING, sizeof(GREETING) - 1, 0);
client_list.Add(*client);
remote = sockaddr_to_string(sa, sa_length, IgnoreError());
FormatInfo(client_domain, "[%u] opened from %s", client->num, remote);
g_free(remote);
}
void
Client::Close()
{
partition.instance.client_list->Remove(*this);
SetExpired();
FormatInfo(client_domain, "[%u] closed", num);
delete this;
}

141
src/ClientProcess.cxx Normal file
View File

@@ -0,0 +1,141 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "protocol/Result.hxx"
#include "command/AllCommands.hxx"
#include "Log.hxx"
#include <string.h>
#define CLIENT_LIST_MODE_BEGIN "command_list_begin"
#define CLIENT_LIST_OK_MODE_BEGIN "command_list_ok_begin"
#define CLIENT_LIST_MODE_END "command_list_end"
static CommandResult
client_process_command_list(Client &client, bool list_ok,
std::list<std::string> &&list)
{
CommandResult ret = CommandResult::OK;
unsigned num = 0;
for (auto &&i : list) {
char *cmd = &*i.begin();
FormatDebug(client_domain, "process command \"%s\"", cmd);
ret = command_process(client, num++, cmd);
FormatDebug(client_domain, "command returned %i", ret);
if (ret != CommandResult::OK || client.IsExpired())
break;
else if (list_ok)
client_puts(client, "list_OK\n");
}
return ret;
}
CommandResult
client_process_line(Client &client, char *line)
{
CommandResult ret;
if (strcmp(line, "noidle") == 0) {
if (client.idle_waiting) {
/* send empty idle response and leave idle mode */
client.idle_waiting = false;
command_success(client);
}
/* do nothing if the client wasn't idling: the client
has already received the full idle response from
client_idle_notify(), which he can now evaluate */
return CommandResult::OK;
} else if (client.idle_waiting) {
/* during idle mode, clients must not send anything
except "noidle" */
FormatWarning(client_domain,
"[%u] command \"%s\" during idle",
client.num, line);
return CommandResult::CLOSE;
}
if (client.cmd_list.IsActive()) {
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
FormatDebug(client_domain,
"[%u] process command list",
client.num);
auto &&cmd_list = client.cmd_list.Commit();
ret = client_process_command_list(client,
client.cmd_list.IsOKMode(),
std::move(cmd_list));
FormatDebug(client_domain,
"[%u] process command "
"list returned %i", client.num, ret);
if (ret == CommandResult::CLOSE ||
client.IsExpired())
return CommandResult::CLOSE;
if (ret == CommandResult::OK)
command_success(client);
client.cmd_list.Reset();
} else {
if (!client.cmd_list.Add(line)) {
FormatWarning(client_domain,
"[%u] command list size "
"is larger than the max (%lu)",
client.num,
(unsigned long)client_max_command_list_size);
return CommandResult::CLOSE;
}
ret = CommandResult::OK;
}
} else {
if (strcmp(line, CLIENT_LIST_MODE_BEGIN) == 0) {
client.cmd_list.Begin(false);
ret = CommandResult::OK;
} else if (strcmp(line, CLIENT_LIST_OK_MODE_BEGIN) == 0) {
client.cmd_list.Begin(true);
ret = CommandResult::OK;
} else {
FormatDebug(client_domain,
"[%u] process command \"%s\"",
client.num, line);
ret = command_process(client, 0, line);
FormatDebug(client_domain,
"[%u] command returned %i",
client.num, ret);
if (ret == CommandResult::CLOSE ||
client.IsExpired())
return CommandResult::CLOSE;
if (ret == CommandResult::OK)
command_success(client);
}
}
return ret;
}

76
src/ClientRead.cxx Normal file
View File

@@ -0,0 +1,76 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "Main.hxx"
#include "event/Loop.hxx"
#include "util/CharUtil.hxx"
#include <assert.h>
#include <string.h>
BufferedSocket::InputResult
Client::OnSocketInput(void *data, size_t length)
{
char *p = (char *)data;
char *newline = (char *)memchr(p, '\n', length);
if (newline == nullptr)
return InputResult::MORE;
TimeoutMonitor::ScheduleSeconds(client_timeout);
BufferedSocket::ConsumeInput(newline + 1 - p);
/* skip whitespace at the end of the line */
while (newline > p && IsWhitespaceOrNull(newline[-1]))
--newline;
/* terminate the string at the end of the line */
*newline = 0;
CommandResult result = client_process_line(*this, p);
switch (result) {
case CommandResult::OK:
case CommandResult::IDLE:
case CommandResult::ERROR:
break;
case CommandResult::KILL:
Close();
main_loop->Break();
return InputResult::CLOSED;
case CommandResult::FINISH:
if (Flush())
Close();
return InputResult::CLOSED;
case CommandResult::CLOSE:
Close();
return InputResult::CLOSED;
}
if (IsExpired()) {
Close();
return InputResult::CLOSED;
}
return InputResult::AGAIN;
}

92
src/ClientSubscribe.cxx Normal file
View File

@@ -0,0 +1,92 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "Idle.hxx"
#include <assert.h>
#include <string.h>
bool Unsubscribe(const char *channel);
void UnsubscribeAll();
bool PushMessage(const ClientMessage &msg);
Client::SubscribeResult
Client::Subscribe(const char *channel)
{
assert(channel != nullptr);
if (!client_message_valid_channel_name(channel))
return Client::SubscribeResult::INVALID;
if (num_subscriptions >= CLIENT_MAX_SUBSCRIPTIONS)
return Client::SubscribeResult::FULL;
auto r = subscriptions.insert(channel);
if (!r.second)
return Client::SubscribeResult::ALREADY;
++num_subscriptions;
idle_add(IDLE_SUBSCRIPTION);
return Client::SubscribeResult::OK;
}
bool
Client::Unsubscribe(const char *channel)
{
const auto i = subscriptions.find(channel);
if (i == subscriptions.end())
return false;
assert(num_subscriptions > 0);
subscriptions.erase(i);
--num_subscriptions;
idle_add(IDLE_SUBSCRIPTION);
assert((num_subscriptions == 0) ==
subscriptions.empty());
return true;
}
void
Client::UnsubscribeAll()
{
subscriptions.clear();
num_subscriptions = 0;
}
bool
Client::PushMessage(const ClientMessage &msg)
{
if (messages.size() >= CLIENT_MAX_MESSAGES ||
!IsSubscribed(msg.GetChannel()))
return false;
if (messages.empty())
IdleAdd(IDLE_MESSAGE);
messages.push_back(msg);
return true;
}

61
src/ClientWrite.cxx Normal file
View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ClientInternal.hxx"
#include "util/FormatString.hxx"
#include <string.h>
/**
* Write a block of data to the client.
*/
static void
client_write(Client &client, const char *data, size_t length)
{
/* if the client is going to be closed, do nothing */
if (client.IsExpired() || length == 0)
return;
client.Write(data, length);
}
void
client_puts(Client &client, const char *s)
{
client_write(client, s, strlen(s));
}
void
client_vprintf(Client &client, const char *fmt, va_list args)
{
char *p = FormatNewV(fmt, args);
client_write(client, p, strlen(p));
delete[] p;
}
void
client_printf(Client &client, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
client_vprintf(client, fmt, args);
va_end(args);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,30 +18,34 @@
*/
#include "config.h"
#include "cmdline.h"
#include "path.h"
#include "log.h"
#include "conf.h"
#include "decoder_list.h"
#include "decoder_plugin.h"
#include "output_list.h"
#include "output_plugin.h"
#include "input_registry.h"
#include "input_plugin.h"
#include "playlist_list.h"
#include "playlist_plugin.h"
#include "ls.h"
#include "mpd_error.h"
#include "glib_compat.h"
#include "CommandLine.hxx"
#include "ls.hxx"
#include "LogInit.hxx"
#include "Log.hxx"
#include "ConfigGlobal.hxx"
#include "DecoderList.hxx"
#include "DecoderPlugin.hxx"
#include "OutputList.hxx"
#include "OutputPlugin.hxx"
#include "InputRegistry.hxx"
#include "InputPlugin.hxx"
#include "PlaylistRegistry.hxx"
#include "PlaylistPlugin.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/FileSystem.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "system/FatalError.hxx"
#ifdef ENABLE_ENCODER
#include "encoder_list.h"
#include "encoder_plugin.h"
#include "EncoderList.hxx"
#include "EncoderPlugin.hxx"
#endif
#ifdef ENABLE_ARCHIVE
#include "archive_list.h"
#include "archive_plugin.h"
#include "ArchiveList.hxx"
#include "ArchivePlugin.hxx"
#endif
#include <glib.h>
@@ -49,41 +53,38 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef G_OS_WIN32
#ifdef WIN32
#define CONFIG_FILE_LOCATION "\\mpd\\mpd.conf"
#else /* G_OS_WIN32 */
#else
#define USER_CONFIG_FILE_LOCATION1 ".mpdconf"
#define USER_CONFIG_FILE_LOCATION2 ".mpd/mpd.conf"
#define USER_CONFIG_FILE_LOCATION_XDG "mpd/mpd.conf"
#endif
static GQuark
cmdline_quark(void)
{
return g_quark_from_static_string("cmdline");
}
static constexpr Domain cmdline_domain("cmdline");
G_GNUC_NORETURN
gcc_noreturn
static void version(void)
{
puts(PACKAGE " (MPD: Music Player Daemon) " VERSION " \n"
puts("Music Player Daemon " VERSION "\n"
"\n"
"Copyright (C) 2003-2007 Warren Dukes <warren.dukes@gmail.com>\n"
"Copyright (C) 2008-2012 Max Kellermann <max@duempel.org>\n"
"Copyright (C) 2008-2013 Max Kellermann <max@duempel.org>\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"
"\n"
"Decoders plugins:");
decoder_plugins_for_each(plugin) {
printf(" [%s]", plugin->name);
decoder_plugins_for_each([](const DecoderPlugin &plugin){
printf(" [%s]", plugin.name);
const char *const*suffixes = plugin->suffixes;
if (suffixes != NULL)
for (; *suffixes != NULL; ++suffixes)
printf(" %s", *suffixes);
const char *const*suffixes = plugin.suffixes;
if (suffixes != nullptr)
for (; *suffixes != nullptr; ++suffixes)
printf(" %s", *suffixes);
puts("");
}
puts("");
});
puts("\n"
"Output plugins:");
@@ -106,8 +107,8 @@ static void version(void)
printf(" [%s]", plugin->name);
const char *const*suffixes = plugin->suffixes;
if (suffixes != NULL)
for (; *suffixes != NULL; ++suffixes)
if (suffixes != nullptr)
for (; *suffixes != nullptr; ++suffixes)
printf(" %s", *suffixes);
puts("");
@@ -134,11 +135,20 @@ static void version(void)
static const char *summary =
"Music Player Daemon - a daemon for playing music.";
gcc_pure
static AllocatedPath
PathBuildChecked(const AllocatedPath &a, PathTraits::const_pointer b)
{
if (a.IsNull())
return AllocatedPath::Null();
return AllocatedPath::Build(a, b);
}
bool
parse_cmdline(int argc, char **argv, struct options *options,
GError **error_r)
Error &error)
{
GError *error = NULL;
GOptionContext *context;
bool ret;
static gboolean option_version,
@@ -146,20 +156,20 @@ parse_cmdline(int argc, char **argv, struct options *options,
option_no_config;
const GOptionEntry entries[] = {
{ "kill", 0, 0, G_OPTION_ARG_NONE, &options->kill,
"kill the currently running mpd session", NULL },
"kill the currently running mpd session", nullptr },
{ "no-config", 0, 0, G_OPTION_ARG_NONE, &option_no_config,
"don't read from config", NULL },
"don't read from config", nullptr },
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &option_no_daemon,
"don't detach from console", NULL },
"don't detach from console", nullptr },
{ "stdout", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
NULL, NULL },
nullptr, nullptr },
{ "stderr", 0, 0, G_OPTION_ARG_NONE, &options->log_stderr,
"print messages to stderr", NULL },
"print messages to stderr", nullptr },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &options->verbose,
"verbose logging", NULL },
"verbose logging", nullptr },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &option_version,
"print version number", NULL },
{ .long_name = NULL }
"print version number", nullptr },
{ nullptr, 0, 0, G_OPTION_ARG_NONE, nullptr, nullptr, nullptr }
};
options->kill = false;
@@ -168,15 +178,16 @@ parse_cmdline(int argc, char **argv, struct options *options,
options->verbose = false;
context = g_option_context_new("[path/to/mpd.conf]");
g_option_context_add_main_entries(context, entries, NULL);
g_option_context_add_main_entries(context, entries, nullptr);
g_option_context_set_summary(context, summary);
ret = g_option_context_parse(context, &argc, &argv, &error);
GError *gerror = nullptr;
ret = g_option_context_parse(context, &argc, &argv, &gerror);
g_option_context_free(context);
if (!ret)
MPD_ERROR("option parsing failed: %s\n", error->message);
FatalError("option parsing failed", gerror);
if (option_version)
version();
@@ -188,66 +199,55 @@ parse_cmdline(int argc, char **argv, struct options *options,
options->daemon = !option_no_daemon;
if (option_no_config) {
g_debug("Ignoring config, using daemon defaults\n");
LogDebug(cmdline_domain,
"Ignoring config, using daemon defaults");
return true;
} else if (argc <= 1) {
/* default configuration file path */
char *path1;
#ifdef G_OS_WIN32
path1 = g_build_filename(g_get_user_config_dir(),
CONFIG_FILE_LOCATION, NULL);
if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
ret = config_read_file(path1, error_r);
else {
int i = 0;
char *system_path = NULL;
const char * const *system_config_dirs;
#ifdef WIN32
AllocatedPath path = PathBuildChecked(AllocatedPath::FromUTF8(g_get_user_config_dir()),
CONFIG_FILE_LOCATION);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
system_config_dirs = g_get_system_config_dirs();
const char *const*system_config_dirs =
g_get_system_config_dirs();
while(system_config_dirs[i] != NULL) {
system_path = g_build_filename(system_config_dirs[i],
CONFIG_FILE_LOCATION,
NULL);
if(g_file_test(system_path,
G_FILE_TEST_IS_REGULAR)) {
ret = config_read_file(system_path,error_r);
break;
}
++i;;
}
g_free(system_path);
g_free(&system_config_dirs);
for (unsigned i = 0; system_config_dirs[i] != nullptr; ++i) {
path = PathBuildChecked(AllocatedPath::FromUTF8(system_config_dirs[i]),
CONFIG_FILE_LOCATION);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
}
#else /* G_OS_WIN32 */
char *path2;
path1 = g_build_filename(g_get_home_dir(),
USER_CONFIG_FILE_LOCATION1, NULL);
path2 = g_build_filename(g_get_home_dir(),
USER_CONFIG_FILE_LOCATION2, NULL);
if (g_file_test(path1, G_FILE_TEST_IS_REGULAR))
ret = config_read_file(path1, error_r);
else if (g_file_test(path2, G_FILE_TEST_IS_REGULAR))
ret = config_read_file(path2, error_r);
else if (g_file_test(SYSTEM_CONFIG_FILE_LOCATION,
G_FILE_TEST_IS_REGULAR))
ret = config_read_file(SYSTEM_CONFIG_FILE_LOCATION,
error_r);
#else
AllocatedPath path = PathBuildChecked(AllocatedPath::FromUTF8(g_get_user_config_dir()),
USER_CONFIG_FILE_LOCATION_XDG);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
path = PathBuildChecked(AllocatedPath::FromUTF8(g_get_home_dir()),
USER_CONFIG_FILE_LOCATION1);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
path = PathBuildChecked(AllocatedPath::FromUTF8(g_get_home_dir()),
USER_CONFIG_FILE_LOCATION2);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
path = AllocatedPath::FromUTF8(SYSTEM_CONFIG_FILE_LOCATION);
if (!path.IsNull() && FileExists(path))
return ReadConfigFile(path, error);
#endif
g_free(path1);
#ifndef G_OS_WIN32
g_free(path2);
#endif
return ret;
error.Set(cmdline_domain, "No configuration file found");
return false;
} else if (argc == 2) {
/* specified configuration file */
return config_read_file(argv[1], error_r);
return ReadConfigFile(Path::FromFS(argv[1]), error);
} else {
g_set_error(error_r, cmdline_quark(), 0,
"too many arguments");
error.Set(cmdline_domain, "too many arguments");
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,12 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef CMDLINE_H
#define CMDLINE_H
#ifndef MPD_COMMAND_LINE_HXX
#define MPD_COMMAND_LINE_HXX
#include <glib.h>
#include <stdbool.h>
class Error;
struct options {
gboolean kill;
@@ -33,6 +33,6 @@ struct options {
bool
parse_cmdline(int argc, char **argv, struct options *options,
GError **error_r);
Error &error);
#endif

174
src/Compiler.h Normal file
View File

@@ -0,0 +1,174 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef COMPILER_H
#define COMPILER_H
#define GCC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && \
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
#ifdef __clang__
# define CLANG_VERSION (__clang_major__ * 10000 \
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)
# if __clang_major__ < 3
# error Sorry, your clang version is too old. You need at least version 3.1.
# endif
#elif defined(__GNUC__)
# if !GCC_CHECK_VERSION(4,6)
# error Sorry, your gcc version is too old. You need at least version 4.6.
# endif
#else
# warning Untested compiler. Use at your own risk!
#endif
#if GCC_CHECK_VERSION(4,0)
/* GCC 4.x */
#define gcc_const __attribute__((const))
#define gcc_deprecated __attribute__((deprecated))
#define gcc_may_alias __attribute__((may_alias))
#define gcc_malloc __attribute__((malloc))
#define gcc_noreturn __attribute__((noreturn))
#define gcc_packed __attribute__((packed))
#define gcc_printf(a,b) __attribute__((format(printf, a, b)))
#define gcc_pure __attribute__((pure))
#define gcc_sentinel __attribute__((sentinel))
#define gcc_unused __attribute__((unused))
#define gcc_warn_unused_result __attribute__((warn_unused_result))
#define gcc_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
#define gcc_nonnull_all __attribute__((nonnull))
#define gcc_likely(x) __builtin_expect (!!(x), 1)
#define gcc_unlikely(x) __builtin_expect (!!(x), 0)
#define gcc_aligned(n) __attribute__((aligned(n)))
#define gcc_visibility_hidden __attribute__((visibility("hidden")))
#define gcc_visibility_default __attribute__((visibility("default")))
#define gcc_always_inline __attribute__((always_inline))
#else
/* generic C compiler */
#define gcc_const
#define gcc_deprecated
#define gcc_may_alias
#define gcc_malloc
#define gcc_noreturn
#define gcc_packed
#define gcc_printf(a,b)
#define gcc_pure
#define gcc_sentinel
#define gcc_unused
#define gcc_warn_unused_result
#define gcc_nonnull(...)
#define gcc_nonnull_all
#define gcc_likely(x) (x)
#define gcc_unlikely(x) (x)
#define gcc_aligned(n)
#define gcc_visibility_hidden
#define gcc_visibility_default
#define gcc_always_inline inline
#endif
#if GCC_CHECK_VERSION(4,3)
#define gcc_hot __attribute__((hot))
#define gcc_cold __attribute__((cold))
#else /* ! GCC_UNUSED >= 40300 */
#define gcc_hot
#define gcc_cold
#endif /* ! GCC_UNUSED >= 40300 */
#if GCC_CHECK_VERSION(4,6) && !defined(__clang__)
#define gcc_flatten __attribute__((flatten))
#else
#define gcc_flatten
#endif
#ifndef __cplusplus
/* plain C99 has "restrict" */
#define gcc_restrict restrict
#elif GCC_CHECK_VERSION(4,0)
/* "__restrict__" is a GCC extension for C++ */
#define gcc_restrict __restrict__
#else
/* disable it on other compilers */
#define gcc_restrict
#endif
/* C++11 features */
#if defined(__cplusplus)
/* support for C++11 "override" was added in gcc 4.7 */
#if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
#define override
#define final
#endif
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
#define gcc_alignas(T, fallback) alignas(T)
#else
#define gcc_alignas(T, fallback) gcc_aligned(fallback)
#endif
#endif
#ifndef __has_feature
// define dummy macro for non-clang compilers
#define __has_feature(x) 0
#endif
#if __has_feature(attribute_unused_on_fields)
#define gcc_unused_field gcc_unused
#else
#define gcc_unused_field
#endif
#if defined(__GNUC__) || defined(__clang__)
#define gcc_unreachable() __builtin_unreachable()
#else
#define gcc_unreachable()
#endif
#endif

160
src/ConfigData.cxx Normal file
View File

@@ -0,0 +1,160 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ConfigData.hxx"
#include "ConfigParser.hxx"
#include "ConfigPath.hxx"
#include "util/Error.hxx"
#include "fs/AllocatedPath.hxx"
#include "system/FatalError.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
int
block_param::GetIntValue() const
{
char *endptr;
long value2 = strtol(value.c_str(), &endptr, 0);
if (*endptr != 0)
FormatFatalError("Not a valid number in line %i", line);
return value2;
}
unsigned
block_param::GetUnsignedValue() const
{
char *endptr;
unsigned long value2 = strtoul(value.c_str(), &endptr, 0);
if (*endptr != 0)
FormatFatalError("Not a valid number in line %i", line);
return (unsigned)value2;
}
bool
block_param::GetBoolValue() const
{
bool value2;
if (!get_bool(value.c_str(), &value2))
FormatFatalError("%s is not a boolean value (yes, true, 1) or "
"(no, false, 0) on line %i\n",
name.c_str(), line);
return value2;
}
config_param::config_param(const char *_value, int _line)
:next(nullptr), value(_value), line(_line) {}
config_param::~config_param()
{
delete next;
}
const block_param *
config_param::GetBlockParam(const char *name) const
{
for (const auto &i : block_params) {
if (i.name == name) {
i.used = true;
return &i;
}
}
return NULL;
}
const char *
config_param::GetBlockValue(const char *name, const char *default_value) const
{
const block_param *bp = GetBlockParam(name);
if (bp == nullptr)
return default_value;
return bp->value.c_str();
}
AllocatedPath
config_param::GetBlockPath(const char *name, const char *default_value,
Error &error) const
{
assert(!error.IsDefined());
int line2 = line;
const char *s;
const block_param *bp = GetBlockParam(name);
if (bp != nullptr) {
line2 = bp->line;
s = bp->value.c_str();
} else {
if (default_value == nullptr)
return AllocatedPath::Null();
s = default_value;
}
AllocatedPath path = ParsePath(s, error);
if (gcc_unlikely(path.IsNull()))
error.FormatPrefix("Invalid path in \"%s\" at line %i: ",
name, line2);
return path;
}
AllocatedPath
config_param::GetBlockPath(const char *name, Error &error) const
{
return GetBlockPath(name, nullptr, error);
}
int
config_param::GetBlockValue(const char *name, int default_value) const
{
const block_param *bp = GetBlockParam(name);
if (bp == nullptr)
return default_value;
return bp->GetIntValue();
}
unsigned
config_param::GetBlockValue(const char *name, unsigned default_value) const
{
const block_param *bp = GetBlockParam(name);
if (bp == nullptr)
return default_value;
return bp->GetUnsignedValue();
}
gcc_pure
bool
config_param::GetBlockValue(const char *name, bool default_value) const
{
const block_param *bp = GetBlockParam(name);
if (bp == NULL)
return default_value;
return bp->GetBoolValue();
}

134
src/ConfigData.hxx Normal file
View File

@@ -0,0 +1,134 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_DATA_HXX
#define MPD_CONFIG_DATA_HXX
#include "ConfigOption.hxx"
#include "Compiler.h"
#include <string>
#include <array>
#include <vector>
class AllocatedPath;
class Error;
struct block_param {
std::string name;
std::string value;
int line;
/**
* This flag is false when nobody has queried the value of
* this option yet.
*/
mutable bool used;
gcc_nonnull_all
block_param(const char *_name, const char *_value, int _line=-1)
:name(_name), value(_value), line(_line), used(false) {}
gcc_pure
int GetIntValue() const;
gcc_pure
unsigned GetUnsignedValue() const;
gcc_pure
bool GetBoolValue() const;
};
struct config_param {
/**
* The next config_param with the same name. The destructor
* deletes the whole chain.
*/
struct config_param *next;
std::string value;
unsigned int line;
std::vector<block_param> block_params;
/**
* This flag is false when nobody has queried the value of
* this option yet.
*/
bool used;
config_param(int _line=-1)
:next(nullptr), line(_line), used(false) {}
gcc_nonnull_all
config_param(const char *_value, int _line=-1);
config_param(const config_param &) = delete;
~config_param();
config_param &operator=(const config_param &) = delete;
/**
* Determine if this is a "null" instance, i.e. an empty
* object that was synthesized and not loaded from a
* configuration file.
*/
bool IsNull() const {
return line == unsigned(-1);
}
gcc_nonnull_all
void AddBlockParam(const char *_name, const char *_value,
int _line=-1) {
block_params.emplace_back(_name, _value, _line);
}
gcc_nonnull_all gcc_pure
const block_param *GetBlockParam(const char *_name) const;
gcc_pure
const char *GetBlockValue(const char *name,
const char *default_value=nullptr) const;
/**
* Same as config_dup_path(), but looks up the setting in the
* specified block.
*/
AllocatedPath GetBlockPath(const char *name, const char *default_value,
Error &error) const;
AllocatedPath GetBlockPath(const char *name, Error &error) const;
gcc_pure
int GetBlockValue(const char *name, int default_value) const;
gcc_pure
unsigned GetBlockValue(const char *name, unsigned default_value) const;
gcc_pure
bool GetBlockValue(const char *name, bool default_value) const;
};
struct ConfigData {
std::array<config_param *, std::size_t(CONF_MAX)> params;
};
#endif

26
src/ConfigDefaults.hxx Normal file
View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_DEFAULTS_HXX
#define MPD_CONFIG_DEFAULTS_HXX
static constexpr unsigned DEFAULT_PLAYLIST_MAX_LENGTH = 16 * 1024;
static constexpr bool DEFAULT_PLAYLIST_SAVE_ABSOLUTE_PATHS = false;
#endif

23
src/ConfigError.cxx Normal file
View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ConfigError.hxx"
#include "util/Domain.hxx"
const Domain config_domain("config");

25
src/ConfigError.hxx Normal file
View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_ERROR_HXX
#define MPD_CONFIG_ERROR_HXX
extern const class Domain config_domain;
#endif

272
src/ConfigFile.cxx Normal file
View File

@@ -0,0 +1,272 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ConfigFile.hxx"
#include "ConfigError.hxx"
#include "ConfigData.hxx"
#include "ConfigTemplates.hxx"
#include "util/Tokenizer.hxx"
#include "util/StringUtil.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "fs/Limits.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "Log.hxx"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#define MAX_STRING_SIZE MPD_PATH_MAX+80
#define CONF_COMMENT '#'
static constexpr Domain config_file_domain("config_file");
static bool
config_read_name_value(struct config_param *param, char *input, unsigned line,
Error &error)
{
Tokenizer tokenizer(input);
const char *name = tokenizer.NextWord(error);
if (name == nullptr) {
assert(!tokenizer.IsEnd());
return false;
}
const char *value = tokenizer.NextString(error);
if (value == nullptr) {
if (tokenizer.IsEnd()) {
error.Set(config_file_domain, "Value missing");
} else {
assert(error.IsDefined());
}
return false;
}
if (!tokenizer.IsEnd() && tokenizer.CurrentChar() != CONF_COMMENT) {
error.Set(config_file_domain, "Unknown tokens after value");
return false;
}
const struct block_param *bp = param->GetBlockParam(name);
if (bp != nullptr) {
error.Format(config_file_domain,
"\"%s\" is duplicate, first defined on line %i",
name, bp->line);
return false;
}
param->AddBlockParam(name, value, line);
return true;
}
static struct config_param *
config_read_block(FILE *fp, int *count, char *string, Error &error)
{
struct config_param *ret = new config_param(*count);
while (true) {
char *line;
line = fgets(string, MAX_STRING_SIZE, fp);
if (line == nullptr) {
delete ret;
error.Set(config_file_domain,
"Expected '}' before end-of-file");
return nullptr;
}
(*count)++;
line = strchug_fast(line);
if (*line == 0 || *line == CONF_COMMENT)
continue;
if (*line == '}') {
/* end of this block; return from the function
(and from this "while" loop) */
line = strchug_fast(line + 1);
if (*line != 0 && *line != CONF_COMMENT) {
delete ret;
error.Format(config_file_domain,
"line %i: Unknown tokens after '}'",
*count);
return nullptr;
}
return ret;
}
/* parse name and value */
if (!config_read_name_value(ret, line, *count, error)) {
assert(*line != 0);
delete ret;
error.FormatPrefix("line %i: ", *count);
return nullptr;
}
}
}
gcc_nonnull_all
static void
Append(config_param *&head, config_param *p)
{
assert(p->next == nullptr);
config_param **i = &head;
while (*i != nullptr)
i = &(*i)->next;
*i = p;
}
static bool
ReadConfigFile(ConfigData &config_data, FILE *fp, Error &error)
{
assert(fp != nullptr);
char string[MAX_STRING_SIZE + 1];
int count = 0;
struct config_param *param;
while (fgets(string, MAX_STRING_SIZE, fp)) {
char *line;
const char *name, *value;
count++;
line = strchug_fast(string);
if (*line == 0 || *line == CONF_COMMENT)
continue;
/* the first token in each line is the name, followed
by either the value or '{' */
Tokenizer tokenizer(line);
name = tokenizer.NextWord(error);
if (name == nullptr) {
assert(!tokenizer.IsEnd());
error.FormatPrefix("line %i: ", count);
return false;
}
/* get the definition of that option, and check the
"repeatable" flag */
const ConfigOption o = ParseConfigOptionName(name);
if (o == CONF_MAX) {
error.Format(config_file_domain,
"unrecognized parameter in config file at "
"line %i: %s\n", count, name);
return false;
}
const unsigned i = unsigned(o);
const ConfigTemplate &option = config_templates[i];
config_param *&head = config_data.params[i];
if (head != nullptr && !option.repeatable) {
param = head;
error.Format(config_file_domain,
"config parameter \"%s\" is first defined "
"on line %i and redefined on line %i\n",
name, param->line, count);
return false;
}
/* now parse the block or the value */
if (option.block) {
/* it's a block, call config_read_block() */
if (tokenizer.CurrentChar() != '{') {
error.Format(config_file_domain,
"line %i: '{' expected", count);
return false;
}
line = strchug_fast(tokenizer.Rest() + 1);
if (*line != 0 && *line != CONF_COMMENT) {
error.Format(config_file_domain,
"line %i: Unknown tokens after '{'",
count);
return false;
}
param = config_read_block(fp, &count, string, error);
if (param == nullptr) {
return false;
}
} else {
/* a string value */
value = tokenizer.NextString(error);
if (value == nullptr) {
if (tokenizer.IsEnd())
error.Format(config_file_domain,
"line %i: Value missing",
count);
else
error.FormatPrefix("line %i: ", count);
return false;
}
if (!tokenizer.IsEnd() &&
tokenizer.CurrentChar() != CONF_COMMENT) {
error.Format(config_file_domain,
"line %i: Unknown tokens after value",
count);
return false;
}
param = new config_param(value, count);
}
Append(head, param);
}
return true;
}
bool
ReadConfigFile(ConfigData &config_data, Path path, Error &error)
{
assert(!path.IsNull());
const std::string path_utf8 = path.ToUTF8();
FormatDebug(config_file_domain, "loading file %s", path_utf8.c_str());
FILE *fp = FOpen(path, FOpenMode::ReadText);
if (fp == nullptr) {
error.FormatErrno("Failed to open %s", path_utf8.c_str());
return false;
}
bool result = ReadConfigFile(config_data, fp, error);
fclose(fp);
return result;
}

30
src/ConfigFile.hxx Normal file
View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_FILE_HXX
#define MPD_CONFIG_FILE_HXX
class Error;
class Path;
struct ConfigData;
bool
ReadConfigFile(ConfigData &data, Path path, Error &error);
#endif

177
src/ConfigGlobal.cxx Normal file
View File

@@ -0,0 +1,177 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ConfigGlobal.hxx"
#include "ConfigParser.hxx"
#include "ConfigData.hxx"
#include "ConfigFile.hxx"
#include "ConfigPath.hxx"
#include "ConfigError.hxx"
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/Error.hxx"
#include "system/FatalError.hxx"
#include "Log.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
static ConfigData config_data;
void config_global_finish(void)
{
for (auto i : config_data.params)
delete i;
}
void config_global_init(void)
{
}
bool
ReadConfigFile(Path path, Error &error)
{
return ReadConfigFile(config_data, path, error);
}
static void
Check(const config_param *param)
{
if (!param->used)
/* this whole config_param was not queried at all -
the feature might be disabled at compile time?
Silently ignore it here. */
return;
for (const auto &i : param->block_params) {
if (!i.used)
FormatWarning(config_domain,
"option '%s' on line %i was not recognized",
i.name.c_str(), i.line);
}
}
void config_global_check(void)
{
for (auto i : config_data.params)
for (const config_param *p = i; p != nullptr; p = p->next)
Check(p);
}
const struct config_param *
config_get_next_param(ConfigOption option, const struct config_param * last)
{
config_param *param = last != nullptr
? last->next
: config_data.params[unsigned(option)];
if (param != nullptr)
param->used = true;
return param;
}
const char *
config_get_string(ConfigOption option, const char *default_value)
{
const struct config_param *param = config_get_param(option);
if (param == nullptr)
return default_value;
return param->value.c_str();
}
AllocatedPath
config_get_path(ConfigOption option, Error &error)
{
const struct config_param *param = config_get_param(option);
if (param == nullptr)
return AllocatedPath::Null();
return config_parse_path(param, error);
}
AllocatedPath
config_parse_path(const struct config_param *param, Error & error)
{
AllocatedPath path = ParsePath(param->value.c_str(), error);
if (gcc_unlikely(path.IsNull()))
error.FormatPrefix("Invalid path at line %i: ",
param->line);
return path;
}
unsigned
config_get_unsigned(ConfigOption option, unsigned default_value)
{
const struct config_param *param = config_get_param(option);
long value;
char *endptr;
if (param == nullptr)
return default_value;
value = strtol(param->value.c_str(), &endptr, 0);
if (*endptr != 0 || value < 0)
FormatFatalError("Not a valid non-negative number in line %i",
param->line);
return (unsigned)value;
}
unsigned
config_get_positive(ConfigOption option, unsigned default_value)
{
const struct config_param *param = config_get_param(option);
long value;
char *endptr;
if (param == nullptr)
return default_value;
value = strtol(param->value.c_str(), &endptr, 0);
if (*endptr != 0)
FormatFatalError("Not a valid number in line %i", param->line);
if (value <= 0)
FormatFatalError("Not a positive number in line %i",
param->line);
return (unsigned)value;
}
bool
config_get_bool(ConfigOption option, bool default_value)
{
const struct config_param *param = config_get_param(option);
bool success, value;
if (param == nullptr)
return default_value;
success = get_bool(param->value.c_str(), &value);
if (!success)
FormatFatalError("Expected boolean value (yes, true, 1) or "
"(no, false, 0) on line %i\n",
param->line);
return value;
}

95
src/ConfigGlobal.hxx Normal file
View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_GLOBAL_HXX
#define MPD_CONFIG_GLOBAL_HXX
#include "ConfigOption.hxx"
#include "Compiler.h"
class Error;
class Path;
class AllocatedPath;
void config_global_init(void);
void config_global_finish(void);
/**
* Call this function after all configuration has been evaluated. It
* checks for unused parameters, and logs warnings.
*/
void config_global_check(void);
bool
ReadConfigFile(Path path, Error &error);
/* don't free the returned value
set _last_ to nullptr to get first entry */
gcc_pure
const struct config_param *
config_get_next_param(enum ConfigOption option,
const struct config_param *last);
gcc_pure
static inline const struct config_param *
config_get_param(enum ConfigOption option)
{
return config_get_next_param(option, nullptr);
}
/* Note on gcc_pure: Some of the functions declared pure are not
really pure in strict sense. They have side effect such that they
validate parameter's value and signal an error if it's invalid.
However, if the argument was already validated or we don't care
about the argument at all, this may be ignored so in the end, we
should be fine with calling those functions pure. */
gcc_pure
const char *
config_get_string(enum ConfigOption option, const char *default_value);
/**
* Returns an optional configuration variable which contains an
* absolute path. If there is a tilde prefix, it is expanded.
* Returns AllocatedPath::Null() if the value is not present. If the path
* could not be parsed, returns AllocatedPath::Null() and sets the error.
*/
AllocatedPath
config_get_path(enum ConfigOption option, Error &error);
/**
* Parse a configuration parameter as a path.
* If there is a tilde prefix, it is expanded. If the path could
* not be parsed, returns AllocatedPath::Null() and sets the error.
*/
AllocatedPath
config_parse_path(const struct config_param *param, Error & error_r);
gcc_pure
unsigned
config_get_unsigned(enum ConfigOption option, unsigned default_value);
gcc_pure
unsigned
config_get_positive(enum ConfigOption option, unsigned default_value);
gcc_pure
bool config_get_bool(enum ConfigOption option, bool default_value);
#endif

90
src/ConfigOption.hxx Normal file
View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_OPTION_HXX
#define MPD_CONFIG_OPTION_HXX
#include "Compiler.h"
enum ConfigOption {
CONF_MUSIC_DIR,
CONF_PLAYLIST_DIR,
CONF_FOLLOW_INSIDE_SYMLINKS,
CONF_FOLLOW_OUTSIDE_SYMLINKS,
CONF_DB_FILE,
CONF_STICKER_FILE,
CONF_LOG_FILE,
CONF_PID_FILE,
CONF_STATE_FILE,
CONF_RESTORE_PAUSED,
CONF_USER,
CONF_GROUP,
CONF_BIND_TO_ADDRESS,
CONF_PORT,
CONF_LOG_LEVEL,
CONF_ZEROCONF_NAME,
CONF_ZEROCONF_ENABLED,
CONF_PASSWORD,
CONF_DEFAULT_PERMS,
CONF_AUDIO_OUTPUT,
CONF_AUDIO_OUTPUT_FORMAT,
CONF_MIXER_TYPE,
CONF_REPLAYGAIN,
CONF_REPLAYGAIN_PREAMP,
CONF_REPLAYGAIN_MISSING_PREAMP,
CONF_REPLAYGAIN_LIMIT,
CONF_VOLUME_NORMALIZATION,
CONF_SAMPLERATE_CONVERTER,
CONF_AUDIO_BUFFER_SIZE,
CONF_BUFFER_BEFORE_PLAY,
CONF_HTTP_PROXY_HOST,
CONF_HTTP_PROXY_PORT,
CONF_HTTP_PROXY_USER,
CONF_HTTP_PROXY_PASSWORD,
CONF_CONN_TIMEOUT,
CONF_MAX_CONN,
CONF_MAX_PLAYLIST_LENGTH,
CONF_MAX_COMMAND_LIST_SIZE,
CONF_MAX_OUTPUT_BUFFER_SIZE,
CONF_FS_CHARSET,
CONF_ID3V1_ENCODING,
CONF_METADATA_TO_USE,
CONF_SAVE_ABSOLUTE_PATHS,
CONF_DECODER,
CONF_INPUT,
CONF_GAPLESS_MP3_PLAYBACK,
CONF_PLAYLIST_PLUGIN,
CONF_AUTO_UPDATE,
CONF_AUTO_UPDATE_DEPTH,
CONF_DESPOTIFY_USER,
CONF_DESPOTIFY_PASSWORD,
CONF_DESPOTIFY_HIGH_BITRATE,
CONF_AUDIO_FILTER,
CONF_DATABASE,
CONF_MAX
};
/**
* @return #CONF_MAX if not found
*/
gcc_pure
enum ConfigOption
ParseConfigOptionName(const char *name);
#endif

40
src/ConfigParser.cxx Normal file
View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ConfigParser.hxx"
#include "util/StringUtil.hxx"
bool
get_bool(const char *value, bool *value_r)
{
static const char *t[] = { "yes", "true", "1", nullptr };
static const char *f[] = { "no", "false", "0", nullptr };
if (string_array_contains(t, value)) {
*value_r = true;
return true;
}
if (string_array_contains(f, value)) {
*value_r = false;
return true;
}
return false;
}

26
src/ConfigParser.hxx Normal file
View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_PARSER_HXX
#define MPD_CONFIG_PARSER_HXX
bool
get_bool(const char *value, bool *value_r);
#endif

132
src/ConfigPath.cxx Normal file
View File

@@ -0,0 +1,132 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "ConfigPath.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/Domain.hxx"
#include "util/Error.hxx"
#include "ConfigGlobal.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#ifndef WIN32
#include <pwd.h>
/**
* Determine a given user's home directory.
*/
static AllocatedPath
GetHome(const char *user, Error &error)
{
passwd *pw = getpwnam(user);
if (pw == nullptr) {
error.Format(path_domain,
"no such user: %s", user);
return AllocatedPath::Null();
}
return AllocatedPath::FromFS(pw->pw_dir);
}
/**
* Determine the current user's home directory.
*/
static AllocatedPath
GetHome(Error &error)
{
const char *home = g_get_home_dir();
if (home == nullptr) {
error.Set(path_domain,
"problems getting home for current user");
return AllocatedPath::Null();
}
return AllocatedPath::FromUTF8(home, error);
}
/**
* Determine the configured user's home directory.
*/
static AllocatedPath
GetConfiguredHome(Error &error)
{
const char *user = config_get_string(CONF_USER, nullptr);
return user != nullptr
? GetHome(user, error)
: GetHome(error);
}
#endif
AllocatedPath
ParsePath(const char *path, Error &error)
{
assert(path != nullptr);
#ifndef WIN32
if (path[0] == '~') {
++path;
if (*path == '\0')
return GetConfiguredHome(error);
AllocatedPath home = AllocatedPath::Null();
if (*path == '/') {
home = GetConfiguredHome(error);
++path;
} else {
const char *slash = strchr(path, '/');
const char *end = slash == nullptr
? path + strlen(path)
: slash;
const std::string user(path, end);
home = GetHome(user.c_str(), error);
if (slash == nullptr)
return home;
path = slash + 1;
}
if (home.IsNull())
return AllocatedPath::Null();
AllocatedPath path2 = AllocatedPath::FromUTF8(path, error);
if (path2.IsNull())
return AllocatedPath::Null();
return AllocatedPath::Build(home, path2);
} else if (!PathTraits::IsAbsoluteUTF8(path)) {
error.Format(path_domain,
"not an absolute path: %s", path);
return AllocatedPath::Null();
} else {
#endif
return AllocatedPath::FromUTF8(path, error);
#ifndef WIN32
}
#endif
}

29
src/ConfigPath.hxx Normal file
View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_PATH_HXX
#define MPD_CONFIG_PATH_HXX
class AllocatedPath;
class Error;
AllocatedPath
ParsePath(const char *path, Error &error);
#endif

96
src/ConfigTemplates.cxx Normal file
View File

@@ -0,0 +1,96 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ConfigTemplates.hxx"
#include "ConfigOption.hxx"
#include <string.h>
const ConfigTemplate config_templates[] = {
{ "music_directory", false, false },
{ "playlist_directory", false, false },
{ "follow_inside_symlinks", false, false },
{ "follow_outside_symlinks", false, false },
{ "db_file", false, false },
{ "sticker_file", false, false },
{ "log_file", false, false },
{ "pid_file", false, false },
{ "state_file", false, false },
{ "restore_paused", false, false },
{ "user", false, false },
{ "group", false, false },
{ "bind_to_address", true, false },
{ "port", false, false },
{ "log_level", false, false },
{ "zeroconf_name", false, false },
{ "zeroconf_enabled", false, false },
{ "password", true, false },
{ "default_permissions", false, false },
{ "audio_output", true, true },
{ "audio_output_format", false, false },
{ "mixer_type", false, false },
{ "replaygain", false, false },
{ "replaygain_preamp", false, false },
{ "replaygain_missing_preamp", false, false },
{ "replaygain_limit", false, false },
{ "volume_normalization", false, false },
{ "samplerate_converter", false, false },
{ "audio_buffer_size", false, false },
{ "buffer_before_play", false, false },
{ "http_proxy_host", false, false },
{ "http_proxy_port", false, false },
{ "http_proxy_user", false, false },
{ "http_proxy_password", false, false },
{ "connection_timeout", false, false },
{ "max_connections", false, false },
{ "max_playlist_length", false, false },
{ "max_command_list_size", false, false },
{ "max_output_buffer_size", false, false },
{ "filesystem_charset", false, false },
{ "id3v1_encoding", false, false },
{ "metadata_to_use", false, false },
{ "save_absolute_paths_in_playlists", false, false },
{ "decoder", true, true },
{ "input", true, true },
{ "gapless_mp3_playback", false, false },
{ "playlist_plugin", true, true },
{ "auto_update", false, false },
{ "auto_update_depth", false, false },
{ "despotify_user", false, false },
{ "despotify_password", false, false},
{ "despotify_high_bitrate", false, false },
{ "filter", true, true },
{ "database", false, true },
};
static constexpr unsigned n_config_templates =
sizeof(config_templates) / sizeof(config_templates[0]);
static_assert(n_config_templates == unsigned(CONF_MAX),
"Wrong number of config_templates");
ConfigOption
ParseConfigOptionName(const char *name)
{
for (unsigned i = 0; i < n_config_templates; ++i)
if (strcmp(config_templates[i].name, name) == 0)
return ConfigOption(i);
return CONF_MAX;
}

33
src/ConfigTemplates.hxx Normal file
View File

@@ -0,0 +1,33 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CONFIG_TEMPLATES_HXX
#define MPD_CONFIG_TEMPLATES_HXX
#include "ConfigOption.hxx"
struct ConfigTemplate {
const char *const name;
const bool repeatable;
const bool block;
};
extern const ConfigTemplate config_templates[];
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,31 +18,25 @@
*/
#include "config.h"
#include "crossfade.h"
#include "chunk.h"
#include "audio_format.h"
#include "tag.h"
#include "CrossFade.hxx"
#include "MusicChunk.hxx"
#include "AudioFormat.hxx"
#include "util/NumberParser.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "crossfade"
static constexpr Domain cross_fade_domain("cross_fade");
#ifdef G_OS_WIN32
static char *
strtok_r(char *str, const char *delim, G_GNUC_UNUSED char **saveptr)
gcc_pure
static float
mixramp_interpolate(const char *ramp_list, float required_db)
{
return strtok(str, delim);
}
#endif
static float mixramp_interpolate(char *ramp_list, float required_db)
{
float db, secs, last_db = nan(""), last_secs = 0;
char *ramp_str, *save_str = NULL;
float last_db = 0, last_secs = 0;
bool have_last = false;
/* ramp_list is a string of pairs of dBs and seconds that describe the
* volume profile. Delimiters are semi-colons between pairs and spaces
@@ -50,24 +44,22 @@ static float mixramp_interpolate(char *ramp_list, float required_db)
* The dB values must be monotonically increasing for this to work. */
while (1) {
/* Parse the dB tokens out of the input string. */
ramp_str = strtok_r(ramp_list, " ", &save_str);
/* Tell strtok to continue next time round. */
ramp_list = NULL;
/* Parse the dB value. */
if (NULL == ramp_str) {
return nan("");
}
db = (float)atof(ramp_str);
char *endptr;
const float db = ParseFloat(ramp_list, &endptr);
if (endptr == ramp_list || *endptr != ' ')
break;
ramp_list = endptr + 1;
/* Parse the time. */
ramp_str = strtok_r(NULL, ";", &save_str);
if (NULL == ramp_str) {
return nan("");
}
secs = (float)atof(ramp_str);
float secs = ParseFloat(ramp_list, &endptr);
if (endptr == ramp_list || (*endptr != ';' && *endptr != 0))
break;
ramp_list = endptr;
if (*ramp_list == ';')
++ramp_list;
/* Check for exact match. */
if (db == required_db) {
@@ -78,58 +70,70 @@ static float mixramp_interpolate(char *ramp_list, float required_db)
if (db < required_db) {
last_db = db;
last_secs = secs;
have_last = true;
continue;
}
/* If required db < any stored value, use the least. */
if (isnan(last_db)) {
if (!have_last)
return secs;
}
/* Finally, interpolate linearly. */
secs = last_secs + (required_db - last_db) * (secs - last_secs) / (db - last_db);
return secs;
}
return -1;
}
unsigned cross_fade_calc(float duration, float total_time,
float mixramp_db, float mixramp_delay,
float replay_gain_db, float replay_gain_prev_db,
char *mixramp_start, char *mixramp_prev_end,
const struct audio_format *af,
const struct audio_format *old_format,
unsigned max_chunks)
unsigned
CrossFadeSettings::Calculate(float total_time,
float replay_gain_db, float replay_gain_prev_db,
const char *mixramp_start, const char *mixramp_prev_end,
const AudioFormat af,
const AudioFormat old_format,
unsigned max_chunks) const
{
unsigned int chunks = 0;
float chunks_f;
float mixramp_overlap;
if (duration < 0 || duration >= total_time ||
/* we can't crossfade when the audio formats are different */
!audio_format_equals(af, old_format))
af != old_format)
return 0;
assert(duration >= 0);
assert(audio_format_valid(af));
assert(af.IsValid());
chunks_f = (float)audio_format_time_to_size(af) / (float)CHUNK_SIZE;
chunks_f = (float)af.GetTimeToSize() / (float)CHUNK_SIZE;
if (isnan(mixramp_delay) || !(mixramp_start) || !(mixramp_prev_end)) {
if (mixramp_delay <= 0 || !mixramp_start || !mixramp_prev_end) {
chunks = (chunks_f * duration + 0.5);
} else {
/* Calculate mixramp overlap. */
mixramp_overlap = mixramp_interpolate(mixramp_start, mixramp_db - replay_gain_db)
+ mixramp_interpolate(mixramp_prev_end, mixramp_db - replay_gain_prev_db);
if (!isnan(mixramp_overlap) && (mixramp_delay <= mixramp_overlap)) {
const float mixramp_overlap_current =
mixramp_interpolate(mixramp_start,
mixramp_db - replay_gain_db);
const float mixramp_overlap_prev =
mixramp_interpolate(mixramp_prev_end,
mixramp_db - replay_gain_prev_db);
const float mixramp_overlap =
mixramp_overlap_current + mixramp_overlap_prev;
if (mixramp_overlap_current >= 0 &&
mixramp_overlap_prev >= 0 &&
mixramp_delay <= mixramp_overlap) {
chunks = (chunks_f * (mixramp_overlap - mixramp_delay));
g_debug("will overlap %d chunks, %fs", chunks,
mixramp_overlap - mixramp_delay);
FormatDebug(cross_fade_domain,
"will overlap %d chunks, %fs", chunks,
mixramp_overlap - mixramp_delay);
}
}
if (chunks > max_chunks) {
chunks = max_chunks;
g_warning("audio_buffer_size too small for computed MixRamp overlap");
LogWarning(cross_fade_domain,
"audio_buffer_size too small for computed MixRamp overlap");
}
return chunks;

71
src/CrossFade.hxx Normal file
View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_CROSSFADE_HXX
#define MPD_CROSSFADE_HXX
#include "Compiler.h"
struct AudioFormat;
struct CrossFadeSettings {
/**
* The configured cross fade duration [s].
*/
float duration;
float mixramp_db;
/**
* The configured MixRapm delay [s]. A non-positive value
* disables MixRamp.
*/
float mixramp_delay;
CrossFadeSettings()
:duration(0),
mixramp_db(0),
mixramp_delay(-1)
{}
/**
* Calculate how many music pipe chunks should be used for crossfading.
*
* @param total_time total_time the duration of the new song
* @param replay_gain_db the ReplayGain adjustment used for this song
* @param replay_gain_prev_db the ReplayGain adjustment used on the last song
* @param mixramp_start the next songs mixramp_start tag
* @param mixramp_prev_end the last songs mixramp_end setting
* @param af the audio format of the new song
* @param old_format the audio format of the current song
* @param max_chunks the maximum number of chunks
* @return the number of chunks for crossfading, or 0 if cross fading
* should be disabled for this song change
*/
gcc_pure
unsigned Calculate(float total_time,
float replay_gain_db, float replay_gain_prev_db,
const char *mixramp_start,
const char *mixramp_prev_end,
AudioFormat af, AudioFormat old_format,
unsigned max_chunks) const;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,14 +18,18 @@
*/
#include "config.h"
#include "daemon.h"
#include "Daemon.hxx"
#include "system/FatalError.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/FileSystem.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -37,8 +41,7 @@
#include <grp.h>
#endif
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "daemon"
static constexpr Domain daemon_domain("daemon");
#ifndef WIN32
@@ -49,10 +52,10 @@ static char *user_name;
static uid_t user_uid = (uid_t)-1;
/** the Unix group id which MPD runs as */
static gid_t user_gid = (pid_t)-1;
static gid_t user_gid = (gid_t)-1;
/** the absolute path of the pidfile */
static char *pidfile;
static AllocatedPath pidfile = AllocatedPath::Null();
/* whether "group" conf. option was given */
static bool had_group = false;
@@ -64,24 +67,27 @@ daemonize_kill(void)
FILE *fp;
int pid, ret;
if (pidfile == NULL)
MPD_ERROR("no pid_file specified in the config file");
if (pidfile.IsNull())
FatalError("no pid_file specified in the config file");
fp = fopen(pidfile, "r");
if (fp == NULL)
MPD_ERROR("unable to open pid file \"%s\": %s",
pidfile, g_strerror(errno));
fp = FOpen(pidfile, "r");
if (fp == nullptr) {
const std::string utf8 = pidfile.ToUTF8();
FormatFatalSystemError("Unable to open pid file \"%s\"",
utf8.c_str());
}
if (fscanf(fp, "%i", &pid) != 1) {
MPD_ERROR("unable to read the pid from file \"%s\"",
pidfile);
const std::string utf8 = pidfile.ToUTF8();
FormatFatalError("unable to read the pid from file \"%s\"",
utf8.c_str());
}
fclose(fp);
ret = kill(pid, SIGTERM);
if (ret < 0)
MPD_ERROR("unable to kill process %i: %s",
pid, g_strerror(errno));
FormatFatalSystemError("unable to kill process %i",
int(pid));
exit(EXIT_SUCCESS);
}
@@ -96,33 +102,36 @@ daemonize_close_stdin(void)
void
daemonize_set_user(void)
{
if (user_name == NULL)
if (user_name == nullptr)
return;
/* set gid */
if (user_gid != (gid_t)-1 && user_gid != getgid()) {
if (setgid(user_gid) == -1) {
MPD_ERROR("cannot setgid to %d: %s",
(int)user_gid, g_strerror(errno));
}
if (user_gid != (gid_t)-1 && user_gid != getgid() &&
setgid(user_gid) == -1) {
FormatFatalSystemError("Failed to set group %d",
(int)user_gid);
}
#ifdef _BSD_SOURCE
/* init suplementary groups
/* init supplementary groups
* (must be done before we change our uid)
*/
if (!had_group && initgroups(user_name, user_gid) == -1) {
g_warning("cannot init supplementary groups "
"of user \"%s\": %s",
user_name, g_strerror(errno));
if (!had_group &&
/* no need to set the new user's supplementary groups if
we are already this user */
user_uid != getuid() &&
initgroups(user_name, user_gid) == -1) {
FormatFatalSystemError("Failed to set supplementary groups "
"of user \"%s\"",
user_name);
}
#endif
/* set uid */
if (user_uid != (uid_t)-1 && user_uid != getuid() &&
setuid(user_uid) == -1) {
MPD_ERROR("cannot change to uid of user \"%s\": %s",
user_name, g_strerror(errno));
FormatFatalSystemError("Failed to set user \"%s\"",
user_name);
}
}
@@ -131,12 +140,12 @@ daemonize_detach(void)
{
/* flush all file handles before duplicating the buffers */
fflush(NULL);
fflush(nullptr);
#ifdef HAVE_DAEMON
if (daemon(0, 1))
MPD_ERROR("daemon() failed: %s", g_strerror(errno));
FatalSystemError("daemon() failed");
#elif defined(HAVE_FORK)
@@ -144,7 +153,7 @@ daemonize_detach(void)
switch (fork()) {
case -1:
MPD_ERROR("fork() failed: %s", g_strerror(errno));
FatalSystemError("fork() failed");
case 0:
break;
default:
@@ -155,52 +164,53 @@ daemonize_detach(void)
/* release the current working directory */
if (chdir("/") < 0)
MPD_ERROR("problems changing to root directory");
FatalError("problems changing to root directory");
/* detach from the current session */
setsid();
#else
MPD_ERROR("no support for daemonizing");
FatalError("no support for daemonizing");
#endif
g_debug("daemonized!");
LogDebug(daemon_domain, "daemonized");
}
void
daemonize(bool detach)
{
FILE *fp = NULL;
FILE *fp = nullptr;
if (pidfile != NULL) {
if (!pidfile.IsNull()) {
/* do this before daemon'izing so we can fail gracefully if we can't
* write to the pid file */
g_debug("opening pid file");
fp = fopen(pidfile, "w+");
LogDebug(daemon_domain, "opening pid file");
fp = FOpen(pidfile, "w+");
if (!fp) {
MPD_ERROR("could not create pid file \"%s\": %s",
pidfile, g_strerror(errno));
const std::string utf8 = pidfile.ToUTF8();
FormatFatalSystemError("Failed to create pid file \"%s\"",
pidfile.c_str());
}
}
if (detach)
daemonize_detach();
if (pidfile != NULL) {
g_debug("writing pid file");
if (!pidfile.IsNull()) {
LogDebug(daemon_domain, "writing pid file");
fprintf(fp, "%lu\n", (unsigned long)getpid());
fclose(fp);
}
}
void
daemonize_init(const char *user, const char *group, const char *_pidfile)
daemonize_init(const char *user, const char *group, AllocatedPath &&_pidfile)
{
if (user) {
struct passwd *pwd = getpwnam(user);
if (!pwd)
MPD_ERROR("no such user \"%s\"", user);
if (pwd == nullptr)
FormatFatalError("no such user \"%s\"", user);
user_uid = pwd->pw_uid;
user_gid = pwd->pw_gid;
@@ -212,25 +222,26 @@ daemonize_init(const char *user, const char *group, const char *_pidfile)
}
if (group) {
struct group *grp = grp = getgrnam(group);
if (!grp)
MPD_ERROR("no such group \"%s\"", group);
struct group *grp = getgrnam(group);
if (grp == nullptr)
FormatFatalError("no such group \"%s\"", group);
user_gid = grp->gr_gid;
had_group = true;
}
pidfile = g_strdup(_pidfile);
pidfile = std::move(_pidfile);
}
void
daemonize_finish(void)
{
if (pidfile != NULL)
unlink(pidfile);
if (!pidfile.IsNull()) {
RemoveFile(pidfile);
pidfile = AllocatedPath::Null();
}
g_free(user_name);
g_free(pidfile);
}
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,19 +17,17 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef DAEMON_H
#define DAEMON_H
#ifndef MPD_DAEMON_HXX
#define MPD_DAEMON_HXX
#include "mpd_error.h"
#include <stdbool.h>
class AllocatedPath;
#ifndef WIN32
void
daemonize_init(const char *user, const char *group, const char *pidfile);
daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile);
#else
static inline void
daemonize_init(const char *user, const char *group, const char *pidfile)
daemonize_init(const char *user, const char *group, AllocatedPath &&pidfile)
{ (void)user; (void)group; (void)pidfile; }
#endif
@@ -50,10 +48,12 @@ daemonize_finish(void)
void
daemonize_kill(void);
#else
#include <glib.h>
#include "system/FatalError.hxx"
static inline void
daemonize_kill(void)
{ MPD_ERROR("--kill is not available on WIN32"); }
{
FatalError("--kill is not available on WIN32");
}
#endif
/**

24
src/DatabaseError.cxx Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "DatabaseError.hxx"
#include "util/Domain.hxx"
const Domain db_domain("db");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,10 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DB_ERROR_H
#define MPD_DB_ERROR_H
#ifndef MPD_DB_ERROR_HXX
#define MPD_DB_ERROR_HXX
#include <glib.h>
class Domain;
enum db_error {
/**
@@ -32,14 +32,6 @@ enum db_error {
DB_NOT_FOUND,
};
/**
* Quark for GError.domain; the code is an enum #db_error.
*/
G_GNUC_CONST
static inline GQuark
db_quark(void)
{
return g_quark_from_static_string("db");
}
extern const Domain db_domain;
#endif

159
src/DatabaseGlue.cxx Normal file
View File

@@ -0,0 +1,159 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "DatabaseGlue.hxx"
#include "DatabaseSimple.hxx"
#include "DatabaseRegistry.hxx"
#include "DatabaseSave.hxx"
#include "DatabaseError.hxx"
#include "Directory.hxx"
#include "util/Error.hxx"
#include "ConfigData.hxx"
#include "Stats.hxx"
#include "DatabasePlugin.hxx"
#include "db/SimpleDatabasePlugin.hxx"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
static Database *db;
static bool db_is_open;
static bool is_simple;
bool
DatabaseGlobalInit(const config_param &param, Error &error)
{
assert(db == nullptr);
assert(!db_is_open);
const char *plugin_name =
param.GetBlockValue("plugin", "simple");
is_simple = strcmp(plugin_name, "simple") == 0;
const DatabasePlugin *plugin = GetDatabasePluginByName(plugin_name);
if (plugin == nullptr) {
error.Format(db_domain,
"No such database plugin: %s", plugin_name);
return false;
}
db = plugin->create(param, error);
return db != nullptr;
}
void
DatabaseGlobalDeinit(void)
{
if (db_is_open)
db->Close();
if (db != nullptr)
delete db;
}
const Database *
GetDatabase()
{
assert(db == nullptr || db_is_open);
return db;
}
const Database *
GetDatabase(Error &error)
{
assert(db == nullptr || db_is_open);
if (db == nullptr)
error.Set(db_domain, DB_DISABLED, "No database");
return db;
}
bool
db_is_simple(void)
{
assert(db == nullptr || db_is_open);
return is_simple;
}
Directory *
db_get_root(void)
{
assert(db != nullptr);
assert(db_is_simple());
return ((SimpleDatabase *)db)->GetRoot();
}
Directory *
db_get_directory(const char *name)
{
if (db == nullptr)
return nullptr;
Directory *music_root = db_get_root();
if (name == nullptr)
return music_root;
return music_root->LookupDirectory(name);
}
bool
db_save(Error &error)
{
assert(db != nullptr);
assert(db_is_open);
assert(db_is_simple());
return ((SimpleDatabase *)db)->Save(error);
}
bool
DatabaseGlobalOpen(Error &error)
{
assert(db != nullptr);
assert(!db_is_open);
if (!db->Open(error))
return false;
db_is_open = true;
stats_update();
return true;
}
bool
db_exists()
{
assert(db != nullptr);
assert(db_is_open);
assert(db_is_simple());
return ((SimpleDatabase *)db)->GetUpdateStamp() > 0;
}

59
src/DatabaseGlue.hxx Normal file
View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DATABASE_GLUE_HXX
#define MPD_DATABASE_GLUE_HXX
#include "Compiler.h"
struct config_param;
class Database;
class Error;
/**
* Initialize the database library.
*
* @param param the database configuration block
*/
bool
DatabaseGlobalInit(const config_param &param, Error &error);
void
DatabaseGlobalDeinit(void);
bool
DatabaseGlobalOpen(Error &error);
/**
* Returns the global #Database instance. May return nullptr if this MPD
* configuration has no database (no music_directory was configured).
*/
gcc_pure
const Database *
GetDatabase();
/**
* Returns the global #Database instance. May return nullptr if this MPD
* configuration has no database (no music_directory was configured).
*/
gcc_pure
const Database *
GetDatabase(Error &error);
#endif

134
src/DatabaseHelpers.cxx Normal file
View File

@@ -0,0 +1,134 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "DatabaseHelpers.hxx"
#include "DatabasePlugin.hxx"
#include "Song.hxx"
#include "tag/Tag.hxx"
#include <functional>
#include <set>
#include <string.h>
struct StringLess {
gcc_pure
bool operator()(const char *a, const char *b) const {
return strcmp(a, b) < 0;
}
};
typedef std::set<const char *, StringLess> StringSet;
static bool
CollectTags(StringSet &set, TagType tag_type, Song &song)
{
Tag *tag = song.tag;
if (tag == nullptr)
return true;
bool found = false;
for (unsigned i = 0; i < tag->num_items; ++i) {
if (tag->items[i]->type == tag_type) {
set.insert(tag->items[i]->value);
found = true;
}
}
if (!found)
set.insert("");
return true;
}
bool
VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type,
VisitString visit_string,
Error &error)
{
StringSet set;
using namespace std::placeholders;
const auto f = std::bind(CollectTags, std::ref(set), tag_type, _1);
if (!db.Visit(selection, f, error))
return false;
for (auto value : set)
if (!visit_string(value, error))
return false;
return true;
}
static void
StatsVisitTag(DatabaseStats &stats, StringSet &artists, StringSet &albums,
const Tag &tag)
{
if (tag.time > 0)
stats.total_duration += tag.time;
for (unsigned i = 0; i < tag.num_items; ++i) {
const TagItem &item = *tag.items[i];
switch (item.type) {
case TAG_ARTIST:
artists.insert(item.value);
break;
case TAG_ALBUM:
albums.insert(item.value);
break;
default:
break;
}
}
}
static bool
StatsVisitSong(DatabaseStats &stats, StringSet &artists, StringSet &albums,
Song &song)
{
++stats.song_count;
if (song.tag != nullptr)
StatsVisitTag(stats, artists, albums, *song.tag);
return true;
}
bool
GetStats(const Database &db, const DatabaseSelection &selection,
DatabaseStats &stats, Error &error)
{
stats.Clear();
StringSet artists, albums;
using namespace std::placeholders;
const auto f = std::bind(StatsVisitSong,
std::ref(stats), std::ref(artists),
std::ref(albums), _1);
if (!db.Visit(selection, f, error))
return false;
stats.artist_count = artists.size();
stats.album_count = albums.size();
return true;
}

42
src/DatabaseHelpers.hxx Normal file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_MEMORY_DATABASE_PLUGIN_HXX
#define MPD_MEMORY_DATABASE_PLUGIN_HXX
#include "DatabaseVisitor.hxx"
#include "tag/TagType.h"
#include "Compiler.h"
class Error;
class Database;
struct DatabaseSelection;
struct DatabaseStats;
bool
VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
TagType tag_type,
VisitString visit_string,
Error &error);
bool
GetStats(const Database &db, const DatabaseSelection &selection,
DatabaseStats &stats, Error &error);
#endif

28
src/DatabaseLock.cxx Normal file
View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "DatabaseLock.hxx"
#include "Compiler.h"
Mutex db_mutex;
#ifndef NDEBUG
ThreadId db_mutex_holder;
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -23,29 +23,31 @@
* multi-threading.
*/
#ifndef MPD_DB_LOCK_H
#define MPD_DB_LOCK_H
#ifndef MPD_DB_LOCK_HXX
#define MPD_DB_LOCK_HXX
#include "check.h"
#include "thread/Mutex.hxx"
#include "Compiler.h"
#include <glib.h>
#include <assert.h>
#include <stdbool.h>
extern GStaticMutex db_mutex;
extern Mutex db_mutex;
#ifndef NDEBUG
extern GThread *db_mutex_holder;
#include "thread/Id.hxx"
extern ThreadId db_mutex_holder;
/**
* Does the current thread hold the database lock?
*/
G_GNUC_PURE
gcc_pure
static inline bool
holding_db_lock(void)
{
return db_mutex_holder == g_thread_self();
return db_mutex_holder.IsInside();
}
#endif
@@ -59,11 +61,11 @@ db_lock(void)
{
assert(!holding_db_lock());
g_static_mutex_lock(&db_mutex);
db_mutex.lock();
assert(db_mutex_holder == NULL);
assert(db_mutex_holder.IsNull());
#ifndef NDEBUG
db_mutex_holder = g_thread_self();
db_mutex_holder = ThreadId::GetCurrent();
#endif
}
@@ -75,10 +77,21 @@ db_unlock(void)
{
assert(holding_db_lock());
#ifndef NDEBUG
db_mutex_holder = NULL;
db_mutex_holder = ThreadId::Null();
#endif
g_static_mutex_unlock(&db_mutex);
db_mutex.unlock();
}
class ScopeDatabaseLock {
public:
ScopeDatabaseLock() {
db_lock();
}
~ScopeDatabaseLock() {
db_unlock();
}
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,41 +18,33 @@
*/
#include "config.h"
#include "pcm_buffer.h"
#include "poison.h"
#include "DatabasePlaylist.hxx"
#include "DatabaseSelection.hxx"
#include "PlaylistFile.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
/**
* Align the specified size to the next 8k boundary.
*/
G_GNUC_CONST
static size_t
align_8k(size_t size)
#include <functional>
static bool
AddSong(const char *playlist_path_utf8,
Song &song, Error &error)
{
return ((size - 1) | 0x1fff) + 1;
return spl_append_song(playlist_path_utf8, song, error);
}
void *
pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
bool
search_add_to_playlist(const char *uri, const char *playlist_path_utf8,
const SongFilter *filter,
Error &error)
{
assert(buffer != NULL);
const Database *db = GetDatabase(error);
if (db == nullptr)
return false;
if (size == 0)
/* never return NULL, because NULL would be assumed to
be an error condition */
size = 1;
const DatabaseSelection selection(uri, true, filter);
if (buffer->size < size) {
/* free the old buffer */
g_free(buffer->buffer);
buffer->size = align_8k(size);
buffer->buffer = g_malloc(buffer->size);
} else {
/* discard old buffer contents */
poison_undefined(buffer->buffer, buffer->size);
}
assert(buffer->size >= size);
return buffer->buffer;
using namespace std::placeholders;
const auto f = std::bind(AddSong, playlist_path_utf8, _1, _2);
return db->Visit(selection, f, error);
}

34
src/DatabasePlaylist.hxx Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DATABASE_PLAYLIST_HXX
#define MPD_DATABASE_PLAYLIST_HXX
#include "Compiler.h"
class SongFilter;
class Error;
gcc_nonnull(1,2)
bool
search_add_to_playlist(const char *uri, const char *path_utf8,
const SongFilter *filter,
Error &error);
#endif

156
src/DatabasePlugin.hxx Normal file
View File

@@ -0,0 +1,156 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/** \file
*
* This header declares the db_plugin class. It describes a
* plugin API for databases of song metadata.
*/
#ifndef MPD_DATABASE_PLUGIN_HXX
#define MPD_DATABASE_PLUGIN_HXX
#include "DatabaseVisitor.hxx"
#include "tag/TagType.h"
#include "Compiler.h"
#include <time.h>
struct config_param;
struct DatabaseSelection;
struct db_visitor;
struct Song;
class Error;
struct DatabaseStats {
/**
* Number of songs.
*/
unsigned song_count;
/**
* Total duration of all songs (in seconds).
*/
unsigned long total_duration;
/**
* Number of distinct artist names.
*/
unsigned artist_count;
/**
* Number of distinct album names.
*/
unsigned album_count;
void Clear() {
song_count = 0;
total_duration = 0;
artist_count = album_count = 0;
}
};
class Database {
public:
/**
* Free instance data.
*/
virtual ~Database() {}
/**
* Open the database. Read it into memory if applicable.
*/
virtual bool Open(gcc_unused Error &error) {
return true;
}
/**
* Close the database, free allocated memory.
*/
virtual void Close() {}
/**
* Look up a song (including tag data) in the database. When
* you don't need this anymore, call ReturnSong().
*
* @param uri_utf8 the URI of the song within the music
* directory (UTF-8)
*/
virtual Song *GetSong(const char *uri_utf8,
Error &error) const = 0;
/**
* Mark the song object as "unused". Call this on objects
* returned by GetSong().
*/
virtual void ReturnSong(Song *song) const = 0;
/**
* Visit the selected entities.
*/
virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,
VisitSong visit_song,
VisitPlaylist visit_playlist,
Error &error) const = 0;
bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,
VisitSong visit_song,
Error &error) const {
return Visit(selection, visit_directory, visit_song,
VisitPlaylist(), error);
}
bool Visit(const DatabaseSelection &selection, VisitSong visit_song,
Error &error) const {
return Visit(selection, VisitDirectory(), visit_song, error);
}
/**
* Visit all unique tag values.
*/
virtual bool VisitUniqueTags(const DatabaseSelection &selection,
TagType tag_type,
VisitString visit_string,
Error &error) const = 0;
virtual bool GetStats(const DatabaseSelection &selection,
DatabaseStats &stats,
Error &error) const = 0;
/**
* Returns the time stamp of the last database update.
* Returns 0 if that is not not known/available.
*/
gcc_pure
virtual time_t GetUpdateStamp() const = 0;
};
struct DatabasePlugin {
const char *name;
/**
* Allocates and configures a database.
*/
Database *(*create)(const config_param &param,
Error &error);
};
#endif

241
src/DatabasePrint.cxx Normal file
View File

@@ -0,0 +1,241 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "DatabasePrint.hxx"
#include "DatabaseSelection.hxx"
#include "SongFilter.hxx"
#include "PlaylistVector.hxx"
#include "SongPrint.hxx"
#include "TimePrint.hxx"
#include "Directory.hxx"
#include "Client.hxx"
#include "tag/Tag.hxx"
#include "Song.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
#include <functional>
static bool
PrintDirectoryBrief(Client &client, const Directory &directory)
{
if (!directory.IsRoot())
client_printf(client, "directory: %s\n", directory.GetPath());
return true;
}
static bool
PrintDirectoryFull(Client &client, const Directory &directory)
{
if (!directory.IsRoot()) {
client_printf(client, "directory: %s\n", directory.GetPath());
time_print(client, "Last-Modified", directory.mtime);
}
return true;
}
static void
print_playlist_in_directory(Client &client,
const Directory &directory,
const char *name_utf8)
{
if (directory.IsRoot())
client_printf(client, "playlist: %s\n", name_utf8);
else
client_printf(client, "playlist: %s/%s\n",
directory.GetPath(), name_utf8);
}
static bool
PrintSongBrief(Client &client, const Song &song)
{
assert(song.parent != nullptr);
song_print_uri(client, song);
if (song.tag != nullptr && song.tag->has_playlist)
/* this song file has an embedded CUE sheet */
print_playlist_in_directory(client, *song.parent, song.uri);
return true;
}
static bool
PrintSongFull(Client &client, const Song &song)
{
assert(song.parent != nullptr);
song_print_info(client, song);
if (song.tag != nullptr && song.tag->has_playlist)
/* this song file has an embedded CUE sheet */
print_playlist_in_directory(client, *song.parent, song.uri);
return true;
}
static bool
PrintPlaylistBrief(Client &client,
const PlaylistInfo &playlist,
const Directory &directory)
{
print_playlist_in_directory(client, directory, playlist.name.c_str());
return true;
}
static bool
PrintPlaylistFull(Client &client,
const PlaylistInfo &playlist,
const Directory &directory)
{
print_playlist_in_directory(client, directory, playlist.name.c_str());
if (playlist.mtime > 0)
time_print(client, "Last-Modified", playlist.mtime);
return true;
}
bool
db_selection_print(Client &client, const DatabaseSelection &selection,
bool full, Error &error)
{
const Database *db = GetDatabase(error);
if (db == nullptr)
return false;
using namespace std::placeholders;
const auto d = selection.filter == nullptr
? std::bind(full ? PrintDirectoryFull : PrintDirectoryBrief,
std::ref(client), _1)
: VisitDirectory();
const auto s = std::bind(full ? PrintSongFull : PrintSongBrief,
std::ref(client), _1);
const auto p = selection.filter == nullptr
? std::bind(full ? PrintPlaylistFull : PrintPlaylistBrief,
std::ref(client), _1, _2)
: VisitPlaylist();
return db->Visit(selection, d, s, p, error);
}
struct SearchStats {
int numberOfSongs;
unsigned long playTime;
};
static void printSearchStats(Client &client, SearchStats *stats)
{
client_printf(client, "songs: %i\n", stats->numberOfSongs);
client_printf(client, "playtime: %li\n", stats->playTime);
}
static bool
stats_visitor_song(SearchStats &stats, Song &song)
{
stats.numberOfSongs++;
stats.playTime += song.GetDuration();
return true;
}
bool
searchStatsForSongsIn(Client &client, const char *name,
const SongFilter *filter,
Error &error)
{
const Database *db = GetDatabase(error);
if (db == nullptr)
return false;
const DatabaseSelection selection(name, true, filter);
SearchStats stats;
stats.numberOfSongs = 0;
stats.playTime = 0;
using namespace std::placeholders;
const auto f = std::bind(stats_visitor_song, std::ref(stats),
_1);
if (!db->Visit(selection, f, error))
return false;
printSearchStats(client, &stats);
return true;
}
bool
printAllIn(Client &client, const char *uri_utf8, Error &error)
{
const DatabaseSelection selection(uri_utf8, true);
return db_selection_print(client, selection, false, error);
}
bool
printInfoForAllIn(Client &client, const char *uri_utf8,
Error &error)
{
const DatabaseSelection selection(uri_utf8, true);
return db_selection_print(client, selection, true, error);
}
static bool
PrintSongURIVisitor(Client &client, Song &song)
{
song_print_uri(client, song);
return true;
}
static bool
PrintUniqueTag(Client &client, TagType tag_type,
const char *value)
{
client_printf(client, "%s: %s\n", tag_item_names[tag_type], value);
return true;
}
bool
listAllUniqueTags(Client &client, int type,
const SongFilter *filter,
Error &error)
{
const Database *db = GetDatabase(error);
if (db == nullptr)
return false;
const DatabaseSelection selection("", true, filter);
if (type == LOCATE_TAG_FILE_TYPE) {
using namespace std::placeholders;
const auto f = std::bind(PrintSongURIVisitor,
std::ref(client), _1);
return db->Visit(selection, f, error);
} else {
using namespace std::placeholders;
const auto f = std::bind(PrintUniqueTag, std::ref(client),
(TagType)type, _1);
return db->VisitUniqueTags(selection, (TagType)type,
f, error);
}
}

55
src/DatabasePrint.hxx Normal file
View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_DB_PRINT_H
#define MPD_DB_PRINT_H
#include "Compiler.h"
class SongFilter;
struct DatabaseSelection;
struct db_visitor;
class Client;
class Error;
bool
db_selection_print(Client &client, const DatabaseSelection &selection,
bool full, Error &error);
gcc_nonnull(2)
bool
printAllIn(Client &client, const char *uri_utf8, Error &error);
gcc_nonnull(2)
bool
printInfoForAllIn(Client &client, const char *uri_utf8,
Error &error);
gcc_nonnull(2)
bool
searchStatsForSongsIn(Client &client, const char *name,
const SongFilter *filter,
Error &error);
bool
listAllUniqueTags(Client &client, int type,
const SongFilter *filter,
Error &error);
#endif

54
src/DatabaseQueue.cxx Normal file
View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "DatabaseQueue.hxx"
#include "DatabaseSelection.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
#include "Partition.hxx"
#include "util/Error.hxx"
#include <functional>
static bool
AddToQueue(Partition &partition, Song &song, Error &error)
{
PlaylistResult result =
partition.playlist.AppendSong(partition.pc, &song, nullptr);
if (result != PlaylistResult::SUCCESS) {
error.Set(playlist_domain, int(result), "Playlist error");
return false;
}
return true;
}
bool
AddFromDatabase(Partition &partition, const DatabaseSelection &selection,
Error &error)
{
const Database *db = GetDatabase(error);
if (db == nullptr)
return false;
using namespace std::placeholders;
const auto f = std::bind(AddToQueue, std::ref(partition), _1, _2);
return db->Visit(selection, f, error);
}

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