Compare commits

...

375 Commits

Author SHA1 Message Date
Max Kellermann
2b97b124bd release v0.19.18 2016-08-05 18:45:23 +02:00
Max Kellermann
d042ab87da decoder/Thread: delete the InputStream on error
Fixes memory leak after stream failure.  See
https://bugs.musicpd.org/view.php?id=4562
2016-08-05 18:15:30 +02:00
Max Kellermann
588303b78d lib/nfs/Manager: add Compare(ManagedConnection, ManagedConnection)
Required for Boost 1.61, which uses that overload in a BOOST_ASSERT().
2016-08-05 18:06:07 +02:00
Max Kellermann
36704c5e18 Makefile.am: fix "undefined reference" linker error 2016-08-05 17:48:53 +02:00
Max Kellermann
5834843b8a decoder/ffmpeg: fix the AVCodecParameters API check
Turns out the libavcodec version numbers are not linear;  the feature
was added in FFmpeg 3.1 commit 998e1b8, libavcodec 57.14.0; but FFmpeg
3.0 has version 57.48.101.  Ouch!
2016-08-02 19:15:23 +02:00
Max Kellermann
762f3afb9d decoder/sidplay: allow building with libsidplayfp instead of libsidplay2
https://bugs.musicpd.org/view.php?id=4558
2016-07-29 19:32:21 +02:00
Max Kellermann
7fb2f15a1a decoder/ffmpeg: check avformat_open_input() return value 2016-07-29 19:32:21 +02:00
Max Kellermann
7456dccd3a decoder/ffmpeg: FfmpegOpenInput() returns Error 2016-07-29 19:32:21 +02:00
Max Kellermann
245f41bb7e decoder/ffmpeg: fix endless recursion in FfmpegScanStream()
Was accidently added by commit cafc266e0
2016-07-29 19:32:21 +02:00
Max Kellermann
9bfb844cfa decoder/sidplay: read the "date" tag 2016-07-29 17:47:08 +02:00
Max Kellermann
d790d3ba3c decoder/sidplay: add GetInfoString() 2016-07-29 17:38:04 +02:00
Max Kellermann
c3dbc92766 decoder/sidplay: use SidTune::getStatus() 2016-07-29 17:31:34 +02:00
Max Kellermann
0bd25f1e17 decoder/sidplay: log detailed error message 2016-07-29 17:04:38 +02:00
Max Kellermann
a4cd7411e8 decoder/sidplay: remove unnecessary error check
The ReSIDBuilder constructor cannot fail.
2016-07-29 17:03:26 +02:00
Max Kellermann
bf276f6235 decoder/sidplay: use SidTune::getStatus() 2016-07-29 16:58:58 +02:00
Max Kellermann
d916890a8f configure.ac: detect libsidplay2 and related with pkg-config
The comment about requiring libtool from 7 years ago is obsolete these
days.
2016-07-29 15:21:38 +02:00
Max Kellermann
071cacc9a4 decoder/sidplay: pass SidTuneMod to get_song_length()
Eliminate duplicate SidTune construction.
2016-07-29 14:56:05 +02:00
Max Kellermann
33f33323af decoder/sidplay: simplify the SidDatabase::length() call 2016-07-29 14:55:58 +02:00
Max Kellermann
388fae2c47 decoder/sidplay: include cleanup 2016-07-29 14:55:28 +02:00
Max Kellermann
9f878b77e9 decoder/sidplay: use class SidDatabase
Remove our own songlength database parser.
2016-07-29 14:55:28 +02:00
Max Kellermann
a547d2aaba decoder/sidplay: use config_param::GetBlockPath() 2016-07-29 14:55:28 +02:00
Max Kellermann
c013026821 decoder/sidplay: make "songlength_file" local 2016-07-29 14:55:28 +02:00
Max Kellermann
96b48a2404 decoder/sidplay: pass parsed path to get_song_length()
Eliminates duplicate ParseContainerPath() call.
2016-07-29 14:55:28 +02:00
Max Kellermann
9612975c2c decoder/sidplay: merge get_container_name() and get_song_num() 2016-07-29 14:55:28 +02:00
Max Kellermann
41bfd45a2e fs/Path: make IsAbsolute() const 2016-07-29 14:55:28 +02:00
Max Kellermann
bbdcbd1f08 fs/Path: add methods GetBase() and GetDirectoryName() 2016-07-29 14:55:28 +02:00
Max Kellermann
6b3c525a9d db/update/ExcludeList: declare exclude_list_domain only if HAVE_GLIB 2016-07-29 14:55:28 +02:00
Max Kellermann
83aed7051c output/shout: rename "encoding" to "encoder"
The user manual specifies "encoder", which is consistent with other
output plugins.  "encoding" should be deprecated.
2016-07-29 10:52:03 +02:00
Max Kellermann
77c6e45e65 Compiler.h: require gcc 4.7 or newer
The ScopeExit library uses C++11 initializers, which gcc 4.6 does not
support.  Let's kill support for this ancient incomplete C++11
compiler, nobody should be using it anymore.
2016-07-29 09:52:23 +02:00
Max Kellermann
8825393660 decoder/ffmpeg: use avcodec_alloc_context3()
This commit suppresses the remaining deprecation warnings with FFmpeg 3.1.
2016-07-29 09:20:36 +02:00
Max Kellermann
2b9246c6ad decoder/ffmpeg: use avcodec_send_packet() and avcodec_receive_frame() on FFmpeg 3.1 2016-07-29 09:20:05 +02:00
Max Kellermann
a9edb4de28 decoder/ffmpeg: use AtScopeExit() for safe cleanup 2016-07-29 09:08:14 +02:00
Max Kellermann
a076ddf38c util/ScopeExit: new utility library
Similar to boost::scope_exit, but fewer include dependencies.
2016-07-29 09:07:58 +02:00
Max Kellermann
cafc266e0b decoder/ffmpeg: merge avformat_close_input() calls 2016-07-28 20:38:07 +02:00
Max Kellermann
a3d020eff9 decoder/ffmpeg: use AVCodecParameters on FFmpeg 3.1
The AVCodecContext attribute is deprecated.
2016-07-28 19:50:25 +02:00
Max Kellermann
8412d94d05 decoder/ffmpeg: add GetCodecParameters()
Preparing for FFmpeg 3.1 support.
2016-07-28 19:49:47 +02:00
Max Kellermann
d1c5bb956a decoder/ffmpeg: move code to IsAudio() 2016-07-28 19:49:45 +02:00
Max Kellermann
70986bc120 decoder/ffmpeg: move code to FfmpegSendFrame() 2016-07-28 19:49:18 +02:00
Max Kellermann
f31fe8b865 decoder/ffmpeg: include cleanup 2016-07-28 19:49:17 +02:00
Max Kellermann
142a9fe530 decoder/ffmpeg: move code to pcm/Interleave.cxx 2016-07-28 19:49:13 +02:00
Max Kellermann
4dd2ad9b27 decoder/ffmpeg: check for commands earlier
Improve initial seek by not reading/decoding the first frame before
checking for the seek command.
2016-07-28 19:48:27 +02:00
Max Kellermann
62f7375804 decoder/ffmpeg: simplify mpd_ffmpeg_open_input() 2016-07-28 19:48:25 +02:00
Max Kellermann
543296b5ba decoder/ffmpeg: move code to lib/ffmpeg/Init.cxx 2016-07-28 19:48:22 +02:00
Max Kellermann
5fee130d00 decoder/ffmpeg: move code to lib/ffmpeg/LogCallback.cxx 2016-07-28 19:47:49 +02:00
Max Kellermann
073facea70 decoder/ffmpeg: remove obsolete comment 2016-07-28 19:47:47 +02:00
Max Kellermann
dbe3b6eee4 decoder/ffmpeg: convert enums to constexpr 2016-07-28 19:47:36 +02:00
Max Kellermann
df97049647 decoder/ffmpeg: move struct AvioStream to FfmpegIo.hxx 2016-07-28 19:47:31 +02:00
Max Kellermann
42c5f68362 decoder/ffmpeg: use AVStream::duration
Use the duration of the stream we're actually decoding - not the
"global" attribute AVFormatContext::duration which may differ.
2016-07-28 19:47:24 +02:00
Max Kellermann
cc19e760cf decoder/ffmpeg: use more references 2016-07-28 19:45:22 +02:00
Max Kellermann
0ff22a16fa decoder/ffmpeg: move code to lib/ffmpeg/Time.hxx 2016-07-28 19:45:11 +02:00
Max Kellermann
47360ec906 decoder/ffmpeg: use av_free() instead of av_freep() 2016-07-28 19:45:07 +02:00
Max Kellermann
087a9938d2 decoder/ffmpeg: add API documentation 2016-07-28 19:45:05 +02:00
Max Kellermann
26d8e41a6b decoder/ffmpeg: copy_interleave_frame() returns ConstBuffer 2016-07-28 19:45:01 +02:00
Max Kellermann
750ae1d3f3 decoder/ffmpeg: copy_interleave_frame() returns Error 2016-07-28 19:44:42 +02:00
Max Kellermann
f8a9a7a108 decoder/ffmpeg: simplify ffmpeg_send_packet() 2016-07-28 19:44:39 +02:00
Max Kellermann
eb192137d6 decoder/ffmpeg: copy the AVPacket in ffmpeg_send_packet()
Revert commit 70495aad by rewriting it.  Turns out, in old FFmpeg
versions, copying the AVPacket is necessary.
2016-07-28 19:42:25 +02:00
Max Kellermann
c25b464f37 decoder/ffmpeg: move code to class FfmpegBuffer 2016-07-27 17:31:02 +02:00
Max Kellermann
710b48d410 decoder/ffmpeg: log detailed error message 2016-07-27 17:28:12 +02:00
Max Kellermann
5e77a8199d decoder/ffmpeg: remove obsolete comment 2016-07-27 17:28:12 +02:00
Max Kellermann
6637db086b decoder/ffmpeg: add "pure" attributes 2016-07-27 17:28:12 +02:00
Max Kellermann
a271a55da7 decoder/ffpmeg: make variables more local 2016-07-27 17:28:12 +02:00
Max Kellermann
6eeec6cbfa decoder/ffpmeg: simplify ffmpeg_send_packet() 2016-07-27 17:22:13 +02:00
Max Kellermann
5e3f3b0400 decoder/ffpmeg: rename functions to CamelCase 2016-07-27 17:18:58 +02:00
Max Kellermann
923c402f69 decoder/ffmpeg: optimize ffmpeg_scan_dictionary()
Don't scan tag items if the handler doesn't implement the tag()
method.
2016-07-27 17:17:14 +02:00
Max Kellermann
4fed0b991c configure.ac: prepare for 0.19.18 2016-07-27 15:07:15 +02:00
Max Kellermann
f28c746b6b release v0.19.17 2016-07-09 00:40:57 +02:00
Max Kellermann
ab95027fc6 decoder/flac: suppress warning at end of stream
This is required if a stream ands without another chained FLAC file.
2016-07-08 23:19:47 +02:00
Max Kellermann
ed3bc4ab63 decoder/flac: move code to FlacInitAndDecode() 2016-07-08 23:03:49 +02:00
Max Kellermann
68064f1aa6 decoder/flac: move duplicate code to flac_data::Initialize() 2016-07-08 22:44:23 +02:00
Max Kellermann
475ac76a5f decoder/flac: late "total_frames" initialization 2016-07-08 22:43:31 +02:00
Max Kellermann
79d4f8674c decoder/flac: remove "duration" parameter from flac_decoder_initialize()
It's always 0.
2016-07-08 22:41:19 +02:00
Max Kellermann
e42eed4d4c decoder/flac: remove pointless check 2016-07-08 22:41:19 +02:00
Max Kellermann
4a7042e847 decoder/flac: handle unknown duration correctly
If the duration is unknown, pass SignedSongTime::Negative(), as
documented for decoder_initialized().
2016-07-08 22:33:49 +02:00
Max Kellermann
7f36923eb4 decoder/flac: pass SignedSongTime to decoder_initialized() 2016-07-08 22:32:23 +02:00
Max Kellermann
2ca8d69126 decoder/flac: document flac_data::position 2016-07-08 22:20:16 +02:00
Max Kellermann
70367d70c8 decoder/flac: remove obsolete sub-song support
This is obsolete because it has been moved to the MPD core.
2016-07-08 21:59:30 +02:00
Max Kellermann
e6389ff5a1 client/ClientRead: call Break() before Close()
Referencing the attribute "partition" is illegal after Close(),
because Close() deletes "this".
2016-07-07 13:54:04 +02:00
Max Kellermann
b46cf57d98 event/BufferedSocket: OnSocketReady() returns true after close
Fixes use-after-free bug (https://bugs.musicpd.org/view.php?id=4548).
2016-07-07 13:52:20 +02:00
Max Kellermann
6f59d71e07 decoder/API: check initial_seek_running in _check_cancel_read()
The "seeking" flag is not set for the initial seek, and so
decoder_read() could be canceled when another SEEK was emitted during
initial seek.

This fixes several seek problems, for example the one reported for the
FLAC decoder plugin:

 https://bugs.musicpd.org/view.php?id=4552
2016-07-06 15:46:04 +02:00
Max Kellermann
f9130f42a2 decoder/flac: try to recover from seek error()
libFLAC API documentation suggests that FLAC__stream_decoder_flush()
should be called to recover from FLAC__STREAM_DECODER_SEEK_ERROR.
2016-07-05 19:29:56 +02:00
Max Kellermann
faf2eeaa99 decoder/flac: evaluate all possible FLAC__stream_decoder_get_state() values
Stop after all fatal errors.  This fixes assertion failures in
libFLAC.
2016-07-05 19:27:40 +02:00
Max Kellermann
1c7de0b4ac output/shout: remove pointless memset() call 2016-07-05 18:02:35 +02:00
Max Kellermann
58487e484f filter/route: use PcmSilence() 2016-07-05 18:01:29 +02:00
Max Kellermann
104075f3e0 PlayerThread: use PcmSilence() in SendSilence()
No change for regular PCM, but DSD uses 0x69 now.
2016-07-05 18:01:29 +02:00
Max Kellermann
b8097eaf2e pcm/Volume: move silence pattern to Silence.cxx 2016-07-05 17:52:53 +02:00
Max Kellermann
5eb0cbc887 PlayerThread: make chunk allocation error non-fatal in SendSilence()
Fixes abort after seeking on fast machines.
2016-07-05 17:44:45 +02:00
Max Kellermann
ba8e579e9b pcm/Volume: use 0x69 to generate DSD silence 2016-07-01 21:22:21 +02:00
Max Kellermann
072e39c9cf filter/ReplayGain: skip PcmVolume if a mixer is set
Previously, volume was applied twice: once by PcmVolume, and again by
the hardware mixer.
2016-07-01 21:17:52 +02:00
Max Kellermann
8dc3f3b21a configure.ac: prepare for 0.19.17 2016-07-01 21:16:14 +02:00
Max Kellermann
faf0c950fe release v0.19.16 2016-06-13 18:59:07 +02:00
Max Kellermann
4ecd325371 decoder/flac: log seek errors 2016-06-13 18:37:45 +02:00
Max Kellermann
5771d67202 player/Thread: cancel outputs before seeking
.. instead of doing it after seeking.  After seeking, the command had
no effect, because CheckDecoderStartup() waits for all outputs to
finish.  This caused a very long delay while seeking and switching
songs (https://bugs.musicpd.org/view.php?id=4534).
2016-06-13 09:13:56 +02:00
Max Kellermann
75c8aecffa NEWS: add missing lines 2016-05-11 17:09:46 +02:00
Max Kellermann
aa5d05eaa4 configure.ac: don't suppress GLib warnings by changing -I to -isystem
This is a kludge which may break system include path order, see
https://bugs.musicpd.org/view.php?id=4524
2016-05-02 22:05:21 +02:00
Max Kellermann
15735552f4 Makefile.am: include doc/include/tags.xml in tarball
See https://bugs.musicpd.org/view.php?id=4523
2016-05-02 09:03:54 +02:00
Max Kellermann
d6d9dc9d95 Makefile.am: include scripts/*.rb in tarball
Fix out-of-tree build by prepending $(srcdir)/, and change *.sh to
*.rb.
2016-05-02 08:58:17 +02:00
Max Kellermann
dc57966dc3 configure.ac: prepare for 0.19.16 2016-05-02 08:57:53 +02:00
Max Kellermann
04ed50fb0f release v0.19.15 2016-04-30 14:21:52 +02:00
Max Kellermann
c9553411bb encoder/wave: add constant WAVE_FORMAT_PCM 2016-04-30 13:57:09 +02:00
Max Kellermann
62221adf55 encoder/wave: fix indent 2016-04-30 13:45:52 +02:00
Max Kellermann
a6bf4746c6 test/test_byte_reverse: use gcc_alignas() for gcc<4.8 compatibility 2016-04-30 13:41:24 +02:00
Michael Cree
72637d00e8 Bug#822848: mpd FTBFS on Alpha; misaligned arrays in the test suite
Source: mpd
Version: 0.19.14-2
Severity: important
Justification: fails to build form source (but built in the past)
Tags: patch
User: debian-alpha@lists.debian.org
Usertags: alpha

mpd FTBFS on Alpha with a failure in the test suite [1]:

FAIL: test/test_byte_reverse
============================

.F...

!!!FAILURES!!!
Test Results:
Run:  4   Failures: 1   Errors: 0

1) test: ByteReverseTest::TestByteReverse2 (F) line: 58 test/test_byte_reverse.cxx
assertion failed
- Expression: strcmp(result, (const char *)dest) == 0

This occurs because the test suite (in test/test_byte_reversal.cxx)
allocates static char arrays and passes the char arrays to functions
whose respective arguments were declared to be uint16_t *, etc., in
the main code.

This is in the realm of undefined behaviour on architectures with
strict memory alignment requirements.  Although the test only fails
on Alpha (because Alpha has a particular CPU load instruction that
gcc likes to use to add bugs ..., ahem,  optimise the code on the
assumption of alignment) it is potentially a latent bug for other
architectures with strict alignment requirements.

Since the code is compiled with the c++11 standard I attach a patch
that modifies the test suite to align the non-compliant strings with
the alignas() attribute.  The test suite now passes on Alpha with
that patch.

Cheers
Michael

[1] https://buildd.debian.org/status/fetch.php?pkg=mpd&arch=alpha&ver=0.19.14-2&stamp=1461542099
2016-04-28 13:29:41 +02:00
Florian Schlichting
27d4b15925 DecoderBuffer: add missing include
> In file included from src/decoder/DecoderBuffer.cxx:21:0:
> src/decoder/DecoderBuffer.hxx:41:20: error: 'uint8_t' was not declared in this scope
>   DynamicFifoBuffer<uint8_t> buffer;
>                     ^
> src/decoder/DecoderBuffer.hxx:41:27: error: template argument 1 is invalid
>   DynamicFifoBuffer<uint8_t> buffer;
>                            ^
> src/decoder/DecoderBuffer.hxx: In member function 'void DecoderBuffer::Clear()':
> src/decoder/DecoderBuffer.hxx:61:10: error: request for member 'Clear' in '((DecoderBuffer*)this)->DecoderBuffer::buffer', which is of non-class type 'int'
>    buffer.Clear();
>           ^
> src/decoder/DecoderBuffer.hxx: In member function 'size_t DecoderBuffer::GetAvailable() const':
> src/decoder/DecoderBuffer.hxx:78:17: error: request for member 'GetAvailable' in '((const DecoderBuffer*)this)->DecoderBuffer::buffer', which is of non-class type 'const int'
>    return buffer.GetAvailable();
>                  ^
> src/decoder/DecoderBuffer.hxx: In member function 'ConstBuffer<void> DecoderBuffer::Read() const':
> src/decoder/DecoderBuffer.hxx:87:19: error: request for member 'Read' in '((const DecoderBuffer*)this)->DecoderBuffer::buffer', which is of non-class type 'const int'
>    auto r = buffer.Read();
>                    ^
> src/decoder/DecoderBuffer.hxx:88:27: error: could not convert '{<expression error>, <expression error>}' from '<brace-enclosed initializer list>' to 'ConstBuffer<void>'
>    return { r.data, r.size };
>                            ^
> src/decoder/DecoderBuffer.hxx: In member function 'void DecoderBuffer::Consume(size_t)':
> src/decoder/DecoderBuffer.hxx:105:10: error: request for member 'Consume' in '((DecoderBuffer*)this)->DecoderBuffer::buffer', which is of non-class type 'int'
>    buffer.Consume(nbytes);
>           ^

This seems to be caused by a lacking include, fixed by the below patch.

I'm unsure what made this appear now, though, compiler and toolchain
libraries seem to be the same upstream versions that built 0.19.14-1
just fine in late March.
2016-04-25 08:30:27 +02:00
Max Kellermann
7a77767e66 doc/mpd.conf.5: move metadata_to_use to the user manual 2016-04-22 10:48:12 +02:00
Max Kellermann
1b26621860 doc/{user,protocol}: add a list of supported tags
A complete list which replaces the incomplete list in the mpd.conf
manpage.
2016-04-22 10:48:12 +02:00
Max Kellermann
3db5f4d0aa doc/mpd.conf.5: remove obsolete metadata_to_use sentence 2016-04-22 10:38:24 +02:00
Max Kellermann
b2a6e327bf doc: migrate to DocBook 4.5 2016-04-22 10:04:29 +02:00
Florian Schlichting
9aec5fe907 doc/user: fix typo 2016-04-22 09:25:17 +02:00
Max Kellermann
c731a82b71 decoder/opus: limit the number of packets in _scan_stream() 2016-04-19 13:08:07 +02:00
Max Kellermann
e6fad97edc decoder/opus: support bigger OpusTags packets
Required for OpusTags packets which contain artwork.

See https://bugs.musicpd.org/view.php?id=4520
2016-04-19 13:05:42 +02:00
Max Kellermann
70495aada1 decoder/ffmpeg: don't copy the AVPacket in ffmpeg_send_packet()
Reduce some overhead.  It is not necessary to copy the object.
2016-04-13 09:04:51 +02:00
Max Kellermann
f243f615ef decoder/ffmpeg: convert pointers to references 2016-04-13 09:01:54 +02:00
Max Kellermann
807c72b2f1 decoder/ffmpeg: use av_packet_unref() instead of av_free_packet()
av_free_packet() was deprecated in FFmpeg 3.0.
2016-04-12 21:15:05 +02:00
Max Kellermann
74dbaade6f decoder/Thread: use "ffmpeg" as fallback instead of "mad"
Adds support for stream codecs which havn't been explicitly listed in
ffmpeg_mime_types.
2016-03-30 00:58:48 +02:00
Max Kellermann
53677172f2 notify: use "constexpr" only with glibc
The Mutex and Cond constructors are only "constexpr" with glibc, and
this is what this #ifdef is about.

Backport of commit 459a812a

See http://bugs.musicpd.org/view.php?id=4511
2016-03-30 00:31:01 +02:00
Max Kellermann
bef0ccf42a configure.ac: prepare for 0.19.15 2016-03-30 00:30:39 +02:00
Max Kellermann
ff35aa07dc release v0.19.14 2016-03-18 18:26:58 +01:00
Max Kellermann
a3afd5178c tag/TagPool: optimize _dup_item()
When a reference counter is at its limit, don't allocate a new
TagPoolSlot - that would result in many TagPoolSlot instances with
ref==1.  This in turn would make the linked list very very large,
which means quadratic runtime for many operations.
2016-03-14 13:08:04 +01:00
Max Kellermann
f1285a6dfd tag/TagPool: add constexpr MAX_REF 2016-03-14 08:07:22 +01:00
Max Kellermann
cf7c1afb93 tag/TagPool: use prime number for NUM_SLOTS 2016-03-14 08:04:51 +01:00
Max Kellermann
e140a28073 archive/iso9660: check path buffer bounds 2016-03-07 14:21:01 +01:00
Max Kellermann
de61c3b962 archive/iso9660: use a single path buffer for Visit()
Avoid wasting 4 kB stack per directory level.
2016-03-07 14:01:52 +01:00
Max Kellermann
c46fc4531b archive/iso9660: move the "." and ".." checks up 2016-03-07 14:01:40 +01:00
Max Kellermann
065a9ed10f archive/iso9660: add local variable "filename" 2016-03-07 13:57:07 +01:00
Max Kellermann
e44c0254f7 archive/iso9660: make variables more local 2016-03-07 13:15:07 +01:00
Max Kellermann
13f9f0315f util/HugeAllocator: fix division by zero due to inverted check
There were two ways this could fail:

1. division by zero when sysconf(_SC_PAGESIZE)==0

2. mmap() failure because the size parameter is not aligned to page
   size

Neither ever happened: sysconf() never fails, and the only caller
passes a size that is already aligned.  Phew.
2016-03-06 23:53:41 +01:00
Max Kellermann
1532ffe215 protocol/ArgParser: fix range check
The old check

 unsigned(value) > std::numeric_limits<unsigned>::max()

.. cannot ever fail.
2016-03-06 23:41:08 +01:00
Max Kellermann
b24cbc68ba decoder/dsdiff: fix off-by-one buffer overflow 2016-03-06 23:28:29 +01:00
Max Kellermann
976fdd76c1 decoder/opus: limit tag size to 64 kB 2016-03-06 23:26:48 +01:00
Max Kellermann
bbda335e02 mixer/pulse: fix integer division rounding 2016-03-06 23:23:30 +01:00
Max Kellermann
d2dd6f7c70 thread/Posix{Mutex,Cond}: use "constexpr" only with glibc
Apparently all other C libraries are not compatible with "constexpr".
Those which are not will get a performance penalty, but at least they
work at all.
2016-03-01 21:23:59 +01:00
Max Kellermann
e9a544fa98 configure.ac: prepare for 0.19.14 2016-03-01 21:22:42 +01:00
Max Kellermann
79f2f8cddc release v0.19.13 2016-02-23 22:06:13 +01:00
Max Kellermann
39fa949345 queue/Playlist: move only the tag items in TagModified()
Fixes disappearing duration of remote songs during playback.

See http://bugs.musicpd.org/view.php?id=4492
2016-02-23 21:01:55 +01:00
Max Kellermann
e1d7a5cbf5 DetachedSong: add method MoveTagItemsFrom() 2016-02-23 20:59:44 +01:00
Max Kellermann
f3cefaf043 tag/Tag: move code to MoveItemsFrom() 2016-02-23 20:57:56 +01:00
Max Kellermann
b3460f3f54 configure.ac, unix/Daemon: check for initgroups() at configure time
The initgroups() manpage says we need to check for _BSD_SOURCE.  The
thing is that glibc deprecated this macro, and doesn't define it
anymore, effectively breaking all MPD supplementary groups.

The real fix is to check for initgroups() availability at configure
time, instead of relying on the deprecated _BSD_SOURCE macro.
2016-02-23 20:13:34 +01:00
Chris Spiegel
1e0ad1f6bf Add TAK as a supported FFmpeg format. 2016-02-19 17:32:48 +01:00
Max Kellermann
4abcb08cc9 tag/{aiff,riff}: fix ID3 chunk padding
Apply padding only to the fseek(), not to the chunk size.  This fixes
bogus "failed to read riff chunk" messages when the last chunk has an
odd size.

See http://bugs.musicpd.org/view.php?id=4486
2016-02-19 17:31:20 +01:00
Max Kellermann
81e7833711 configure.ac: prepare for 0.19.13 2016-02-19 17:30:01 +01:00
Max Kellermann
82e261ad33 release v0.19.12 2015-12-15 21:54:42 +01:00
Benno Fünfstück
cae2811762 fix mpd crash on invalid utf8 stream title 2015-12-15 21:49:53 +01:00
Ben Boeckel
09112c6869 docs: add vlc and mpv to the list of example applications
These are other popular clients. In particular, VLC is available on
mobile devices.

Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
2015-12-15 21:30:26 +01:00
Christian Hesse
77aaf1baee fix LimitRTTIME in systemd unit file
systemd does not understand LimitRTTIME=-1. For no limit we have to use
the string 'infinity' (see systemd.exec(5)).

Signed-off-by: Christian Hesse <mail@eworm.de>
2015-12-15 21:17:04 +01:00
Jörg Krause
6626c2d00d Makefile.am: fix static build with alsa
Add ALSA_LIBS to MIXER_LIBS, otherwise building mpd in a static context fails
with lot of undefined references to alsa-lib (libasound) required by
src/mixer/plugins/AlsaMixerPlugin.cxx.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
2015-12-15 21:16:45 +01:00
Michael Paquier
315f9d98f6 Main: fix build failure on non-Linux systems 2015-11-10 08:38:53 +01:00
Max Kellermann
f087518e7a configure.ac: prepare for 0.19.12 2015-11-10 08:33:50 +01:00
Max Kellermann
db9997a106 release v0.19.11 2015-10-27 10:42:20 +01:00
Max Kellermann
0cbfb610f2 systemd: remove obsolete ControlGroup settings
This systemd feature has been removed a while ago without replacement,
and it turns out that systemd developers suggest not using control
groups at all to assign real-time privileges.  Therfore, a replacement
feature will not be implement in future systemd releases, and we can
really remove those lines completely.

See http://bugs.musicpd.org/view.php?id=4413
2015-10-27 10:36:23 +01:00
Max Kellermann
f901cd042b doc/user: section about real-time scheduling 2015-10-27 10:31:50 +01:00
Max Kellermann
5719207dfa gme: don't loop forever, fall back to GME's default play length
Fixes http://bugs.musicpd.org/view.php?id=4432
2015-10-26 17:16:20 +01:00
Max Kellermann
a84fbbe327 decoder/gme: free the gme_info_t as early as possible 2015-10-26 17:15:24 +01:00
Max Kellermann
93c97972b9 decoder/gme: call decoder_seek_error() on seek error 2015-10-26 16:32:39 +01:00
Max Kellermann
ac61d43720 output/Command: flush the mixer cache when enabling/disabling output
Fixes mixer lag (http://bugs.musicpd.org/view.php?id=4425).
2015-10-26 16:29:07 +01:00
Max Kellermann
1958f78cc1 decoder/ffmpeg: fix crash due to wrong avio_alloc_context() call
Allocate the buffer dynamically using av_malloc(), and free
AVIOContext.buffer in the destructor, as mandated by the libavformat
documentation.

Fixes http://bugs.musicpd.org/view.php?id=4446
2015-10-26 13:06:29 +01:00
Max Kellermann
a7ee64a25b decoder/mpcdec: use SampleTraits<SampleFormat::S24_P32>
Eliminates some duplicate code, and as a side effect, this works
around clang 3.8 compiler warning because a negative value was
shifted.
2015-10-16 18:12:32 +02:00
Max Kellermann
2a58f22649 decoder/mpcdec: use Clamp() 2015-10-16 18:11:42 +02:00
Max Kellermann
f066bb7716 unix/Daemon, playlist/...: remove unused Domain variables 2015-10-16 18:08:59 +02:00
Max Kellermann
4e3d182189 encoder/flac: fix crash with 32 bit playback
Copy to encoder->audio_format *after* adjusting the sample format to
S24_P32.

Fixes http://bugs.musicpd.org/view.php?id=4433
2015-10-16 18:05:34 +02:00
Max Kellermann
205fba74cf tag/ApeLoader: fix buffer overflow after unterminated key 2015-10-16 14:55:40 +02:00
Max Kellermann
a9bcf8d50d configure.ac: prepare for 0.19.11 2015-10-16 14:55:40 +02:00
Max Kellermann
b0ff3bc7a3 release v0.19.10 2015-06-21 15:51:50 +02:00
Max Kellermann
06301e279c PlayerThread: start the decoder on PlayerCommand::QUEUE
Fixes missing SongBorder() call, which causes "single" mode breakage.
2015-06-21 15:38:48 +02:00
Max Kellermann
6d6f274648 DecoderAPI: discard unused song tag early
If there's a stream tag, don't let the song tag override it in the
next update_stream_tag() call.
2015-06-21 15:10:55 +02:00
Max Kellermann
9acefcb256 DecoderThread: set Decoder::song_tag only for local files
If the song tag comes from a stream, and MPD playback restarts, MPD
would believe the tag should override the newly received tag.  This
makes the previous tag appear stuck.  This change passes the song tag
only if it's authoritative - i.e. if it's a song file.
2015-06-21 15:02:14 +02:00
Max Kellermann
e4d0293a31 DecoderAPI: "move" the Tag object
Reduce runtime overhead.
2015-06-20 16:06:09 +02:00
Romain Rollet
ae77542a11 OutputControl: fix fail_timer check right after booting
Right after booting, the monotonic clock starts with a very small
value, and AudioOutput::LockUpdate() may believe that the fail_timer
has not recovered yet.
2015-06-20 15:37:19 +02:00
Max Kellermann
980187f856 system/PeriodClock: make IsDefined() "constexpr" 2015-06-20 15:33:17 +02:00
Max Kellermann
327a8e6c59 decoder/ffmpeg: skip unwanted samples after seeking
When seeking to the beginning of a packet, skip the samples that come
before the desired time stamp.
2015-06-20 15:01:05 +02:00
Max Kellermann
d11e2724c4 decoder/ffmpeg: use AVSEEK_FLAG_BACKWARD for seeking
Ask FFmpeg to seek to the next packet boundary *before* the seek
position, so we don't miss audio data.  Now we get too much, but we'll
solve that in the next commit.
2015-06-20 14:29:42 +02:00
Max Kellermann
f768ca3a2d decoder/ffmpeg: move code to StreamRelativePts() 2015-06-19 18:56:29 +02:00
Max Kellermann
947e902288 input/curl: trigger the condition variable in RequestDone()
Fixes deadlock on small responses.
2015-06-19 16:45:38 +02:00
Thomas Guillem
3436a646b5 storage/nfs: fix deadlock when connecting
The Connect method can be called between Schedule and lock. In that case, when
locked, the state is already set to CONNECTING of READY and the condition won't
be signaled anymore.
2015-05-29 22:39:14 +02:00
jai
aed0af1e00 input/smbclient: fix DFF playback 2015-05-29 22:37:49 +02:00
Michal Nazarewicz
0d7ee2b014 OpusEncoderPlugin: initialise granulepos so we end up with sane values
Not initialising granulepos leads to it having arbitrary values in the
encoded stream including possibly negative values which are not valid
and confuse opusdec.  Explicitly initialise opus_encoder::granulepos
to avoid that problem.
2015-03-25 18:02:54 +01:00
Max Kellermann
2f5fd91bd8 configure.ac: prepare for 0.19.10 2015-03-25 18:02:54 +01:00
Max Kellermann
5761800197 release v0.19.9 2015-02-06 17:08:25 +01:00
Max Kellermann
0eebacc521 Merge tag 'v0.18.23' into v0.19.x 2015-02-06 17:07:47 +01:00
Max Kellermann
4a5528697d release v0.18.23 2015-02-06 17:04:14 +01:00
Max Kellermann
d38034bb5c fs/io/FileOutputStream: don't auto-delete file on WIN32
The file handle is never reset to INVALID_HANDLE_VALUE, and thus the
destructor will assume the operation shall be cancelled and will
delete the temporary file.

This was a major breakage for saving the database file and the state
file.
2015-02-06 14:36:55 +01:00
Max Kellermann
b3fe3e8b3d TagBuilder: allow adding duplicate tag types in Complement()
Build a table of pre-existing tag types before adding new items.  The
old way would check HasType() each time, which would return true after
the first instance of that tag type had been added, preventing
duplicate tag types to be merged.

This broke duplicate tag types loaded from the state file, because
this code path uses TagBuilder::Complement().
2015-02-06 12:25:34 +01:00
Max Kellermann
5489dec28d NEWS: fix v0.18.22 release date 2015-02-01 12:22:24 +01:00
Max Kellermann
8a6b4db19f Makefile.am: move org_musicpd_Bridge.h to BUILT_SOURCES 2015-01-31 00:05:30 +01:00
Max Kellermann
df43b6a05c Makefile.am: generate icon before compiling JNI classes
Apparently, Android's build.xml requires the icon to be available,
even when only running the Java compiler.
2015-01-31 00:05:30 +01:00
Max Kellermann
3adca3c2fa db/update/Walk: use std::unique_ptr instead of std::auto_ptr
std::auto_ptr is deprecated, and std::unique_ptr is much better
anyway.
2015-01-29 08:37:23 +01:00
PHO
39abd3ecb4 Avoid integer overflow in MonotonicClock{S,MS,US}
This is Darwin specific: the previous implementation was causing an integer
overflow when base.numer is very large. On PPC Darwin, the timebase info is 1000000000/33330116 and this is too large for integer arithmetic.
2015-01-29 08:34:37 +01:00
PHO
a4f4fc50b9 Avoid integer overflow in MonotonicClock{S,MS,US}
This is Darwin specific: the previous implementation was causing an integer
overflow when base.numer is very large. On PPC Darwin, the timebase info is 1000000000/33330116 and this is too large for integer arithmetic.
2015-01-29 08:33:48 +01:00
Max Kellermann
7bf638b0de decoder/DsdLib: use new[] to allocate the ID3 buffer
Don't abort the process if there's not enough memory.  This buffer is
not important and can be large.
2015-01-29 08:24:34 +01:00
Max Kellermann
56662a703c decoder/DsdLib: free ID3 buffer right after id3_tag_parse()
Merge two free() calls.
2015-01-29 08:24:34 +01:00
Max Kellermann
8b5f47d3a3 decoder/DsdLib: raise ID3 tag limit to 1 MB
A bug report was submitted with a 600 kB ID3 tag that could not be
read by MPD.
2015-01-29 08:20:14 +01:00
Max Kellermann
a289dcb9ee Merge branch 'v0.18.x' into v0.19.x 2015-01-26 20:48:19 +01:00
PHO
023b9c1e7e Test the existence of strndup(3) before using it.
This can eliminate the ad-hoc "#ifdef WIN32" and can also support other platforms lacking it as well (including Darwin 9).
2015-01-26 20:39:49 +01:00
Max Kellermann
4c61662644 test/read_mixer: add missing stdlib.h include 2015-01-26 20:39:49 +01:00
Max Kellermann
ad1b6ef0ac {playlist,input}/despotify: remove defunct plugin 2015-01-26 09:55:31 +01:00
Max Kellermann
ed5c6be2f1 util/list: disable gcc5 warning
This file has been removed in newer MPD versions, so don't care about
it now.
2015-01-23 16:50:31 +01:00
Max Kellermann
30cb082932 ClientProcess: cast enum to int before passing to printf()
Fixes gcc5 warning.
2015-01-23 16:50:31 +01:00
Max Kellermann
645554d12f configure.ac: prepare for 0.18.23 2015-01-23 16:47:13 +01:00
Max Kellermann
212b0faf0c android/build.py: use os.path.abspath() to build mpd_path
Fixes a bug that occurs when runing "build.py" from inside the
"android" directory.
2015-01-22 18:51:53 +01:00
Max Kellermann
276a0d9500 thread/Name: include stdio.h if HAVE_PRCTL
Caused a build failure with uClibc because snprintf() was not
available.
2015-01-21 20:40:56 +01:00
Max Kellermann
384b6c8288 doc/protocol: "playlistsearch" is case insensitive 2015-01-16 17:27:19 +01:00
Max Kellermann
a2af158fd3 configure.ac: prepare for 0.19.9 2015-01-16 17:26:50 +01:00
Max Kellermann
f33d2fb2e7 release v0.19.8 2015-01-14 23:12:24 +01:00
Max Kellermann
a9eec35aff Merge tag 'v0.18.22' into v0.19.x 2015-01-14 23:12:08 +01:00
Max Kellermann
8534f2d1e2 release v0.18.22 2015-01-14 23:04:49 +01:00
Max Kellermann
00740fb23b android/build.py: prepend "./" to "configure" if path is empty
Fixes in-tree build when the script is called as "android/build.py"
and not "./android/build.py".
2015-01-09 16:51:52 +01:00
Max Kellermann
37e9010887 input/async: reset the "open" flag after seeking successfully
Fixes a problem with the "curl" input plugin: IsEOF() always returns
true because the "open" flag was cleared by
CurlInputStream::RequestDone() when end-of-stream was reached.  This
flag stays false even when seeking to another position has succeeded.

This patch resets the "open" flag to true after seeking successfully.
2015-01-06 12:46:28 +01:00
Max Kellermann
4bd2c75056 thread/Name: disable pthread_setname_np() on NetBSD
NetBSD's pthread_setname_np() prototype is incompatible with the rest
of the world, and it requires to pass the string argument as a
non-const pointer.  Instead of working around this misdesign, I hereby
disable the feature on NetBSD.
2015-01-06 12:08:36 +01:00
Max Kellermann
b9ed850b98 thread/Name: enable FormatThreadName() with prctl()
Add macro HAVE_THREAD_NAME which is set when any method to set the
thread name is available.  Use that macro in FormatThreadName()
instead of just checking for HAVE_PTHREAD_SETNAME_NP.
2015-01-06 12:04:30 +01:00
Max Kellermann
11cea17496 thread/Name: indent preprocessor commands 2015-01-06 12:04:15 +01:00
Max Kellermann
163597ef69 db/simple: fix implicit nullptr/bool conversion
Return false on error, not nullptr.
2014-12-26 14:34:03 +01:00
Max Kellermann
95f84afd33 fs/Traits, ...: work around -Wtautological-pointer-compare
New in clang 3.6.
2014-12-26 14:34:03 +01:00
Max Kellermann
9f7fd1fbfb db/lazy, input/mms: add "override" keywords
Fixes -Winconsistent-missing-override (clang 3.6).
2014-12-26 14:29:29 +01:00
Max Kellermann
940cab8620 Merge branch 'v0.18.x' into v0.19.x 2014-12-26 14:28:52 +01:00
Max Kellermann
5b84c99d79 doc/user: remove autoconf/automake from Debian build dependencies 2014-12-26 14:00:50 +01:00
Max Kellermann
b295024574 doc/user: add more Debian build dependencies 2014-12-26 13:56:26 +01:00
Max Kellermann
34180f1745 doc/user: add libicu-dev to Debian build dependencies 2014-12-26 13:54:33 +01:00
Max Kellermann
665031467a db/proxy, output/shout: fix implicit nullptr/bool conversion
Return false on error, not nullptr.
2014-12-26 13:50:54 +01:00
Max Kellermann
df33171107 db/{simple,proxy}, ...: add "override" keywords
Fixes -Winconsistent-missing-override (clang 3.6).
2014-12-26 13:47:04 +01:00
Max Kellermann
53f4044890 util/{ASCII,UriUtil}, ...: work around -Wtautological-pointer-compare
New in clang 3.6.
2014-12-26 13:43:32 +01:00
Max Kellermann
a5049136ff DatabaseGlue: convert nullptr check to assertion 2014-12-26 13:43:32 +01:00
Max Kellermann
705b3c6b63 util/ASCII: fix indent 2014-12-26 13:37:38 +01:00
Max Kellermann
6b4ac66962 Compiler.h: add macro CLANG_CHECK_VERSION() 2014-12-26 13:31:03 +01:00
Max Kellermann
0964b06240 Compiler.h: add macro GCC_OLDER_THAN() 2014-12-26 13:30:44 +01:00
Max Kellermann
92eeca3ba7 util/Manual: reimplement GCC_CHECK_VERSION() using GCC_MAKE_VERSION() 2014-12-26 13:30:22 +01:00
Max Kellermann
2a86554ac4 Compiler.h: add macro GCC_MAKE_VERSION() 2014-12-26 13:30:11 +01:00
Max Kellermann
805caa30ce configure.ac: prepare for 0.18.22 2014-12-26 13:23:04 +01:00
Max Kellermann
a56949e9fa decoder/ffmpeg: support interleaved floating point 2014-12-23 20:51:08 +01:00
Max Kellermann
43da4c0eca input/mms: limit the mmsx_read() size 2014-12-23 20:34:45 +01:00
Max Kellermann
b9c7771830 decoder/DsdLib: add missing stdlib.h include 2014-12-23 10:08:46 +01:00
Jan Brittenson
35db88affe DSF ID3 tags hitting 4k size limit
Here's a change to dynamically allocate the DSD ID3 tag buffer.
Pretty much anything with cover art is going to exceed the existing,
static 4k limit...  Here's a change to dynamically allocate the buffer
and sanity check it at some upper limit.  I rather arbitrarily pulled
256k out of thin air just to keep a corrupt file from causing it to
trying to allocate a buffer larger than available memory.
2014-12-23 09:49:33 +01:00
Max Kellermann
e38faca455 configure.ac: prepare for 0.19.8 2014-12-23 09:48:31 +01:00
Max Kellermann
0255e8710c android: release v0.19.7 2014-12-23 09:42:52 +01:00
Max Kellermann
6d89020f80 release v0.19.7 2014-12-17 19:20:54 +01:00
Max Kellermann
9c56c49e73 Merge tag 'v0.18.21' into v0.19.x 2014-12-17 19:19:13 +01:00
Max Kellermann
acb798e544 release v0.18.21 2014-12-17 19:13:47 +01:00
Max Kellermann
c5720a15c7 LogBackend: force-flush stderr on WIN32
setvbuf() does not seem to have an effect on Windows.
2014-12-17 19:12:25 +01:00
Max Kellermann
90709b332a LogInit: make stderr line-buffered
Make sure everything gets logged right away.  No delays because
stdio's buffer is not yet full.
2014-12-17 19:12:01 +01:00
Max Kellermann
81f17d10c8 util/HugeAllocator: enable MEM_COMMIT on Windows
Without MEM_COMMIT, the reserved address space is not accessible, and
MPD crashes.
2014-12-17 19:10:58 +01:00
k44
773de38bd9 playlist/embcue: fix filename suffix detection
The definition of the playlist_plugin struct member of the embcue
plugin was incorrect.
2014-12-16 18:43:05 +01:00
Max Kellermann
a48704925d storage/nfs: add timeout 2014-12-15 00:45:13 +01:00
Max Kellermann
fa4beeee75 decoder/ffmpeg: detect and fix negative time stamps
Works around assertion failure due to something that appears to be a
(minor) FFmpeg bug.
2014-12-15 00:40:46 +01:00
Max Kellermann
d8351772d3 configure.ac: prepare for 0.18.21 2014-12-15 00:39:52 +01:00
Max Kellermann
68d1abdb85 storage/nfs: clear last_error in SetState()
Fixes bogus assertion failure.
2014-12-15 00:39:30 +01:00
Max Kellermann
7e8474a85a lib/nfs/Connection: unregister socket with SocketMonitor::Steal()
SocketMonitor::Cancel() does not actually unregister the socket; it
only disables the event.
2014-12-15 00:31:12 +01:00
Max Kellermann
82da364b8b lib/nfs/Connection: implement mount timeout 2014-12-15 00:05:53 +01:00
Max Kellermann
7fa91ec175 lib/nfs/Connection: add debug flag "in_destroy" 2014-12-15 00:03:30 +01:00
Max Kellermann
1d3a09d377 lib/nfs/Connection: add assertion 2014-12-14 22:51:37 +01:00
Max Kellermann
02563a35f0 lib/nfs/Connection: fix reconnect after mount failure
When mounting had not yet finished, SocketMonitor::IsDefined() was
always false, due to the workaround at the beginning of the function
that calls SocketMonitor::Steal().  This commit drops the IsDefined()
check because it was never necessary and breaks reconnect.
2014-12-14 22:49:16 +01:00
Max Kellermann
d653f35bb7 lib/nfs/Connection: fix typo in code comment 2014-12-14 22:49:09 +01:00
Max Kellermann
a543627abd lib/nfs/Connection: fix memory leak (and assertion failure)
nfs_destroy_context() will invoke all pending callbacks with
err==-EINTR.  In CancellableCallback::Callback(), this will invoke
NfsConnection::DeferClose(), which however is only designed to be
called from nfs_service().  In non-debug mode, this will leak memory
because nfs_close_async() is never called.

Workaround: before nfs_destroy_context(), invoke nfs_close_async() on
all pending file handles.
2014-12-14 16:02:47 +01:00
Max Kellermann
80f2ba7fca lib/nfs/Connection: move code to Service() 2014-12-14 15:45:10 +01:00
Max Kellermann
32bca64920 lib/nfs/Connection: add assertions 2014-12-14 15:40:29 +01:00
Max Kellermann
7fa1a84ec3 lib/nfs/Connection: move code to method InternalClose() 2014-12-14 15:38:09 +01:00
Max Kellermann
ab4bb26a0a lib/nfs/Connection: make in_service and in_event debug-only flags 2014-12-14 15:20:40 +01:00
Max Kellermann
4b8d258cff lib/nfs/Connection: fix crash while canceling a failing Open()
The method NfsConnection::CancellableCallback::Callback() will always
invoke NfsConnection::Close() on the file handle, even if the void
pointer is not a nfsfh.  This can happen if the Open() was not
successful, e.g. when the file does not exist.
2014-12-14 15:16:01 +01:00
Max Kellermann
3c29aa6271 event/Loop: read the "again" flag while holding mutex 2014-12-14 14:47:36 +01:00
Max Kellermann
51464b4317 lib/nfs/Connection: add assertions 2014-12-14 14:24:49 +01:00
Max Kellermann
2fec463542 util/HugeAllocator: disable MEM_LARGE_PAGES on Windows
MEM_LARGE_PAGES does not appear to work.  Instead, MEM_RESERVE appears
to be necessary.  Until I figure this out, this large pages are
disabled.
2014-12-12 13:20:58 +01:00
Max Kellermann
1affc641c4 input/Init: eliminate double colon from log message 2014-12-12 13:20:37 +01:00
Max Kellermann
0cfd4fff62 playlist/Print: don't skip non-existent songs in "listplaylist"
Skipping those songs silently will confuse the client, because
commands specifying the song index within a playlist
(e.g. playlistdelete) will be out of sync.

This copies spl_print()'s behavior to playlist_file_print().
2014-12-09 13:36:48 +01:00
Max Kellermann
8904127c10 configure.ac: prepare for 0.19.7 2014-12-09 13:09:03 +01:00
Max Kellermann
c46f48abec release v0.19.6 2014-12-08 15:12:41 +01:00
Max Kellermann
4acbf7b90d android/build.py: update FFmpeg to 2.5 2014-12-08 15:05:49 +01:00
Max Kellermann
cbc1a58e93 Merge tag 'v0.18.20' into v0.19.x 2014-12-08 15:03:09 +01:00
Max Kellermann
1b5f33a435 release v0.18.20 2014-12-08 14:57:17 +01:00
Max Kellermann
41b4a63f2b decoder/ffmpeg: support FFmpeg 2.5
Version 2.5 fixed an API oddity, however it broke API compatibility,
at least with C++.  Disable the workaround when a libavformat version
is detected that is recent enough.
2014-12-08 14:25:34 +01:00
Max Kellermann
d8fc2db910 thread/Id: drop "::" prefix before pthread function names
The "::" to explicitly refer to the global namespace appeared like a
good idea in C++, but it breaks with C libraries that implement
standard functions using macros (e.g. musl).
2014-12-08 14:17:17 +01:00
Max Kellermann
dc11dea7cc configure.ac: prepare for 0.18.20 2014-12-08 14:13:20 +01:00
Nix
811af02f56 Output: start with a null mixer.
There are code paths (mostly error cases) in which it is possible to
initialize an AudioOutput and then kill it without ever calling
audio_output_new().  In such a case, its destructor will attempt to
free a mixer that was never initialized, leading to an attempt to
take out a lock on a mutex that was similarly never initialized,
which hangs forever.

Fix by always initializing the mixer appropriately.
2014-12-01 22:14:09 +01:00
Max Kellermann
8780e23ed3 android/build.py: update ffmpeg 2.4.3, curl 7.39 2014-11-28 21:08:27 +01:00
Max Kellermann
be492ed108 android: update libFLAC to 1.3.1
Due to security vulnerabilities.
2014-11-28 21:08:27 +01:00
Max Kellermann
24da14f4f7 .gitignore: ignore /lib/ 2014-11-28 21:08:18 +01:00
Max Kellermann
03d2fb450f configure.ac: prepare for 0.19.6 2014-11-28 20:13:57 +01:00
Max Kellermann
67cba251c8 release v0.19.5 2014-11-26 20:11:42 +01:00
Max Kellermann
0bc511715b Makefile.am: distribute Android sources 2014-11-26 20:11:42 +01:00
Max Kellermann
27ce80544f Merge tag 'v0.18.19' into v0.19.x 2014-11-26 20:02:57 +01:00
Max Kellermann
04f627c2af release v0.18.19 2014-11-26 19:58:48 +01:00
Max Kellermann
e72eef421b lib/nfs/FileReader: clean up on disconnect
Avoids crash because Close() invokes a call on a destructed
NfsConnection.
2014-11-25 14:02:15 +01:00
Max Kellermann
016063c810 lib/nfs/FileReader: move code to CancelOrClose() 2014-11-25 14:00:32 +01:00
Max Kellermann
38f19981b2 lib/nfs/FileReader: reset state in OnNfsConnectionFailed()
Avoid calling NfsConnection::RemoveLease(), because the lease has been
removed already.
2014-11-25 13:51:09 +01:00
Max Kellermann
40dd968f13 lib/nfs/FileReader: update "state" in OnNfsError()
Clean up the "state" to indicate that there is no longer any
asynchronous operation.  Fixes another NFS-related crash due to
cleanup of a non-existing asynchronous operation.
2014-11-25 13:39:42 +01:00
Max Kellermann
3cef348f30 lib/nfs/Manager: defer NfsConnection destruction
Avoids a crash that occurs when NfsConnection::OnSocketReady()
dereferences itself before returning.
2014-11-25 13:31:18 +01:00
Max Kellermann
b293b16007 lib/nfs/Connection: broadcast error before closing connection
During the NfsLease::OnNfsConnectionFailed() call, the old (defunct)
nfs_context may be used to close file handles.  Such code does not yet
exist, but will be added soon to fix other bugs.
2014-11-25 13:27:06 +01:00
Max Kellermann
f5f43db2da lib/nfs/Connection: cancel DeferredMonitor on disconnect
Fixes potential second mount attempt after the old connection to the
NFS server was shut down.
2014-11-25 13:22:25 +01:00
Max Kellermann
029555d192 lib/nfs/FileReader: include Compiler.h for "final" fallback 2014-11-25 13:18:22 +01:00
Max Kellermann
fa4d202e71 decoder/mp4v2: remove because of incompatible license
libmp4v2 is licensed under MPL 1.1, which is incompatible with GPLv2.
Unfortunately, this means that we must remove the plugin.

More information can be found in the Debian bug report:

 http://bugs.debian.org/767504
2014-11-25 13:10:52 +01:00
Max Kellermann
a8ebfd7a92 event/DeferredMonitor: include cleanup 2014-11-25 10:44:06 +01:00
Max Kellermann
b19e5720cc test/run_input: make variables more local 2014-11-25 07:51:33 +01:00
Max Kellermann
a254f5a3a8 archive/zzip: fix inverted error handler
Set the Error when zzip_seek()==-1 and not on success.  Fixes a crash
after seeking.
2014-11-24 22:08:50 +01:00
Max Kellermann
143c735f96 configure.ac: prepare for 0.18.19 2014-11-24 22:08:50 +01:00
Max Kellermann
951bad46e0 decoder/{dsdiff,dsf,opus}: fix deadlock while seeking 2014-11-24 08:54:30 +01:00
Max Kellermann
716225cd2f doc/protocol: mention that "count" can have multiple filters 2014-11-24 08:09:58 +01:00
Max Kellermann
bbc618b8f9 configure.ac: prepare for 0.19.5 2014-11-24 08:09:44 +01:00
Max Kellermann
11ead56d6d android: release v0.19.4
Android releases were missing since 0.19.1.
2014-11-24 08:00:47 +01:00
Max Kellermann
e972ae4afa android: switch to gcc 4.9 / llvm 3.5 (NDK r10c) 2014-11-24 08:00:45 +01:00
Max Kellermann
0709065f50 Java/File: fix include guard 2014-11-24 07:51:25 +01:00
Max Kellermann
d6bc5c35a7 release v0.19.4 2014-11-18 21:40:52 +01:00
Max Kellermann
dc03f003ac Merge tag 'v0.18.18' into v0.19.x 2014-11-18 21:38:44 +01:00
Max Kellermann
7aa2104596 release v0.18.18 2014-11-18 21:34:03 +01:00
Max Kellermann
460cfba6ff QueueCommands: workaround for buggy clients that send "add /" 2014-11-18 21:31:54 +01:00
Max Kellermann
c8b93d6573 Client: assume uid==0 is local socket
A negative uid value means it's not a "local socket" (PF_LOCAL).
uid==0 means user "root" connected.
2014-11-18 20:56:27 +01:00
Max Kellermann
3f5f96ac91 event/ServerSocket: fix get_remote_uid() error value
Must return -1 on error, not 0.  0 is root.
2014-11-18 20:53:59 +01:00
Max Kellermann
7c6b991de7 decoder/opus: add MIME types audio/ogg and application/ogg 2014-11-12 15:16:34 +01:00
Max Kellermann
82460aa49f configure.ac: prepare for 0.19.4 2014-11-12 15:16:07 +01:00
Florent Le Coz
7e7b403043 Construct a Null AllocatedPath if the filename conversion into UTF8 failed 2014-11-11 17:15:19 +01:00
Max Kellermann
e5217e6ce9 release v0.19.3 2014-11-11 11:21:42 +01:00
Max Kellermann
c98cb1d6f9 decoder/opus: support chained streams 2014-11-11 11:20:18 +01:00
Max Kellermann
ba6f2b0467 decoder/opus: move code to HandleEOS() 2014-11-11 11:20:16 +01:00
Max Kellermann
23465ad985 decoder/opus: improved error logging 2014-11-11 11:20:03 +01:00
Max Kellermann
7886a14b74 decoder/opus: fix mistyped LoadEOSPacket() return value 2014-11-11 11:18:51 +01:00
Max Kellermann
466b6a23cd decoder/opus: eliminate flag "found_opus"
Check opus_decoder!=nullptr instead.
2014-11-11 08:30:11 +01:00
Max Kellermann
4a04f73434 decoder/opus: add constexpr output_buffer_frames 2014-11-11 07:45:31 +01:00
Misty De Meo
134cb6a017 Main: fix compilation on OS X using non-Apple compilers
Commit d42c0f1dc5 added an OS X-specific
method of calling mpd_main_after_fork(), which uses Grand Central
Dispatch. Since this uses a block literal, it breaks compilation on
compilers which don't support the block extension, e.g. non-Apple
compilers. This affects users on older OS X releases with GCD (which
depend on older Clang releases, or Apple GCCs, which don't support the
C++11 features MPD needs); or which don't support GCD at all (10.5 and
lower).

This patch changes the #ifdef so that the non-GCD code is used
as it was on OS X before this patch if blocks aren't available, via
checking __BLOCKS__ macro.
2014-11-11 06:22:24 +01:00
Max Kellermann
8d036c4b7c pcm/SoxrResampler: round output buffer size up
The old formula calculates the output buffer size with "regular"
rounding (to the nearest integer), however sometimes, that is
insufficient and the last sample cannot be resampled.  This causes
audible distortions.  By changing the formula to consider the worst
case (always round up), this problem is eliminated.
2014-11-10 22:52:17 +01:00
Max Kellermann
c64ad78c7b decoder/ffmpeg: support opus 2014-11-10 18:00:30 +01:00
Max Kellermann
4a043a915f configure.ac: prepare for 0.18.1 2014-11-10 17:59:06 +01:00
Max Kellermann
8ff0d99092 decoder/audiofile: fix bit rate calculation 2014-11-10 09:00:50 +01:00
Max Kellermann
2e47cb12c4 test/FakeDecoderAPI: dump bit rate 2014-11-10 09:00:38 +01:00
Max Kellermann
ff6f1655f0 input/curl: ignore ResponseBoundary() while seeking
While seeking, metadata must not be updated.  ResponseBoundary() was
added in MPD 0.19.1, but I forgot to add the IsSeeking() check there.
This caused the "seekable" flag to reset.
2014-11-10 08:45:19 +01:00
Max Kellermann
b5ba94f1de tag/Set: do AlbumArtist/Artist fallback only if AlbumArtist is not disabled
On "list albumartist", songs that have no AlbumArtist tag will use the
Artist tag.  However, if AlbumArtist is disabled via
"metadata_to_use", the TagBuilder::AddItem() call is ignored, and
PrintUniqueTag() attempts to print a nullptr string.

This commit fixes the problem by attempting the fallback only if
AlbumArtist is not disabled.
2014-11-08 19:25:01 +01:00
Max Kellermann
cbf79769d3 db/Count: include cleanup 2014-11-08 19:21:42 +01:00
Max Kellermann
125eb01e03 decoder/ffmpeg: support opus 2014-11-07 19:22:26 +01:00
Max Kellermann
ccb13205f4 db/upnp: fix valgrind warning 2014-11-07 19:12:43 +01:00
Max Kellermann
6f23e91e33 lib/upnp/ContentDirectoryService: swap uri_apply_base() parameters
When uri_apply_base() was moved from db/upnp/Util.cpp to
util/UriUtil.cpp, the parameter order was changed, however without
swapping the parameters in the ContentDirectoryService constructor.
2014-11-07 18:43:00 +01:00
Max Kellermann
1bd8a322f5 input/AsyncInputStream: set Error when seeking unseekable
Fixes crash in the "audiofile" decoder while logging the seek error.
2014-11-07 13:57:57 +01:00
Max Kellermann
362e73bea8 input/Open: expose input_domain 2014-11-07 13:57:57 +01:00
Max Kellermann
9f8c2b3b56 configure.ac: prepare for 0.19.3 2014-11-04 09:24:09 +01:00
Max Kellermann
6a7f6cdacd release v0.19.2 2014-11-02 13:46:32 +01:00
Max Kellermann
5715342fe0 Merge tag 'v0.18.17' into v0.19.x 2014-11-02 13:46:09 +01:00
Max Kellermann
38a0d15190 release v0.18.17 2014-11-02 13:06:20 +01:00
Max Kellermann
56f763a4a8 input/curl: forget Content-Length (and more) after redirect
Fixes playback of redirected streams.
2014-11-02 13:00:28 +01:00
Max Kellermann
a2eb14f3b3 AsyncInputStream: add method ClearTag() 2014-11-02 13:00:28 +01:00
Max Kellermann
05c63af7c4 InputStream: add method ClearMimeType() 2014-11-02 12:59:16 +01:00
Max Kellermann
1f59701c46 Merge branch 'v0.18.x' into v0.19.x 2014-11-02 12:27:46 +01:00
Max Kellermann
ec3191f502 input/curl: fix curl_easy_setopt() parameter types 2014-11-02 11:55:48 +01:00
Max Kellermann
32b5654a6e Decoder, Playlist: ignore URI query string for plugin detection
Use the new uri_get_suffix() overload that removes the query string.
2014-11-02 11:54:26 +01:00
Max Kellermann
674091424e util/UriUtil: add uri_get_suffix() overload that ignores query string 2014-11-02 11:53:31 +01:00
Max Kellermann
6ad336743d PlaylistFile: don't allow empty playlist name 2014-11-02 11:52:48 +01:00
Max Kellermann
c882568ccd playlist/m3u: recognize the file suffix ".m3u8" 2014-11-02 11:50:56 +01:00
Max Kellermann
f6b2899dd2 decoder/faad: remove workaround for ancient libfaad2 ABI bug
Many years ago, FAAD had a serious ABI bug: the NeAACDecInit()
prototype in its header declared the "samplerate" parameter to be
"unsigned long *", but internally, the function assumed it was
"uint32_t *" instead.  On 32 bit machines, that was no difference, but
on 64 bit, this left one portion of the return value uninitialized;
and worse, on big-endian, the wrong word was filled.  This bug had to
be worked around in MPD (commit 9c4e97a6).

A few months later, the bug was fixed in the FAAD CVS in commit 1.117
on file libfaad/decoder.c; the commit message was:

 "Use public headers internally to prevent duplicate declarations"

The commit message was too brief at best; the problem was not
duplicate declarations, but a prototype mismatch.  No mention of the
bug fix in the ChangeLog.

The MPD project never learned about this bug fix, and so MPD would
always pass a "uin32_t *" dressed up as a "unsigned long *".  Nearly 6
years later, it's about time to fix this second ABI problem.  Let's
kill the workaround!
2014-11-02 11:50:56 +01:00
Steven OBrien
bccd4ef2f7 decoder/ffmpeg: recognize MIME type audio/aacp 2014-11-02 11:50:56 +01:00
Max Kellermann
94c240a026 configure.ac: show DSD in result 2014-11-02 11:50:56 +01:00
Max Kellermann
c50a0cf7bf output/roar: remove unnecessary "volatile" keyword
A mutex acts as a memory barrier, and thus "volatile" is not
necessary.
2014-11-02 11:50:56 +01:00
Max Kellermann
c37f7abb79 TagString: use g_strndup() for unterminated string
Fixes buffer overflow bug.
2014-11-02 11:48:13 +01:00
Max Kellermann
432ce9b1de configure.ac: prepare for 0.18.17 2014-11-02 11:41:40 +01:00
Max Kellermann
054323c2bc lib/upnp/Discovery: add missing stdlib.h include 2014-11-02 11:04:13 +01:00
Max Kellermann
a8770aa606 input/curl: fix curl_easy_setopt() parameter types 2014-11-01 14:09:30 +01:00
Max Kellermann
7d5442e103 Decoder, Playlist: ignore URI query string for plugin detection
Use the new uri_get_suffix() overload that removes the query string.
2014-11-01 13:41:18 +01:00
Max Kellermann
eab32f2e5d util/UriUtil: add uri_get_suffix() overload that ignores query string 2014-11-01 12:45:47 +01:00
NanoTech
d42c0f1dc5 Main: run the OS X native event loop after forking 2014-10-31 15:03:53 +01:00
NanoTech
6ad1e4d99a Revert "Main: run the OS X native event loop"
This reverts commit f0be48ff90
(except for the NEWS entry).

If libdispatch (GCD) is used before forking, it
can't safely be used again after forking.
2014-10-31 15:03:46 +01:00
Max Kellermann
7350144ab3 PlaylistFile: don't allow empty playlist name 2014-10-31 14:59:27 +01:00
Max Kellermann
54c591bd9d decoder/mad: fix negative replay gain values
Negating an unsigned integer does not work.
2014-10-28 22:22:30 +01:00
Max Kellermann
217d88f21f TextInputStream: don't ignore unterminated last line 2014-10-28 22:10:47 +01:00
Max Kellermann
394e3be482 playlist/m3u: recognize the file suffix ".m3u8" 2014-10-26 08:14:16 +01:00
Max Kellermann
d7f024c510 OutputThread: fall back to PCM if given DSD sample rate is not supported
Works around the "PCM conversion from f to dsd is not implemented"
error message that prevents DSD playback.
2014-10-25 22:06:08 +02:00
Max Kellermann
bc5a53574c decoder/faad: remove workaround for ancient libfaad2 ABI bug
Many years ago, FAAD had a serious ABI bug: the NeAACDecInit()
prototype in its header declared the "samplerate" parameter to be
"unsigned long *", but internally, the function assumed it was
"uint32_t *" instead.  On 32 bit machines, that was no difference, but
on 64 bit, this left one portion of the return value uninitialized;
and worse, on big-endian, the wrong word was filled.  This bug had to
be worked around in MPD (commit 9c4e97a6).

A few months later, the bug was fixed in the FAAD CVS in commit 1.117
on file libfaad/decoder.c; the commit message was:

 "Use public headers internally to prevent duplicate declarations"

The commit message was too brief at best; the problem was not
duplicate declarations, but a prototype mismatch.  No mention of the
bug fix in the ChangeLog.

The MPD project never learned about this bug fix, and so MPD would
always pass a "uin32_t *" dressed up as a "unsigned long *".  Nearly 6
years later, it's about time to fix this second ABI problem.  Let's
kill the workaround!
2014-10-25 20:42:50 +02:00
Max Kellermann
30df709736 configure.ac: update VERSION_REVISION 2014-10-25 00:33:25 +02:00
Steven OBrien
8cd17ce045 decoder/ffmpeg: recognize MIME type audio/aacp 2014-10-25 00:26:58 +02:00
Max Kellermann
1bfbced258 configure.ac: add storage plugin section to result 2014-10-25 00:21:18 +02:00
Max Kellermann
6ac5980a17 configure.ac: show DSD in result 2014-10-25 00:19:01 +02:00
Max Kellermann
2e24adae89 configure.ac: require xmlto for --enable-documentation 2014-10-25 00:14:25 +02:00
Max Kellermann
188b94cb3e test/test_archive: don't use GLib 2014-10-25 00:08:04 +02:00
Max Kellermann
c48733e34f fs/Charset: work around clang's -Wunused-const-variable
MPD_PATH_MAX_UTF8 is only used by GLib-specific code currently.
2014-10-25 00:07:25 +02:00
Max Kellermann
f36db9bb04 configure.ac: auto-disable plugins that require GLib when --disable-glib is used 2014-10-24 23:46:20 +02:00
Max Kellermann
30dd29e251 configure.ac: improve database dependency checks
Abort if --enable-libmpdclient or --enable-upnp are used with
--disable-database, instead of ignoring the mismatch silently.
2014-10-24 23:43:21 +02:00
Max Kellermann
6cf1acfb48 test/DumpDatabase, ...: no g_thread_init() calls when GLib is disabled 2014-10-24 18:30:30 +02:00
Max Kellermann
a7b09d3d1c OutputThread: close the output plugin after filter failure
Fixes memory leak because ao_plugin_close() never gets called.
2014-10-24 00:35:16 +02:00
Max Kellermann
8fc3768166 OutputThread: unlock mutex for CloseFilter()
Be consistent.
2014-10-24 00:29:03 +02:00
Max Kellermann
b07bddf742 output/roar: remove unnecessary "volatile" keyword
A mutex acts as a memory barrier, and thus "volatile" is not
necessary.
2014-10-23 23:29:56 +02:00
Max Kellermann
220f957cd8 pcm/ChannelsConverter: fix variable used to generate error message
Use the "_format" parameter instead of the (uninitialized) "format"
attribute.
2014-10-23 22:44:53 +02:00
Max Kellermann
8ce48d83eb pcm/FormatConverter: move check to Open()
Report unsupported format while opening the filter, not later when the
first conversion takes place.
2014-10-23 22:42:08 +02:00
Max Kellermann
200cdb6b0a pcm/PcmConvert: assign {src,dest}_format at the end
Fixes assertion failure in destructor by not assigning
{src,dest}_format when an error occurs.
2014-10-23 22:39:51 +02:00
Max Kellermann
d9fb40203a pcm/PcmConvert: make AudioFormat parameters "const" 2014-10-23 22:39:51 +02:00
Max Kellermann
2d9e972195 configure.ac: prepare for 0.19.2 2014-10-23 21:57:04 +02:00
191 changed files with 3505 additions and 2448 deletions
.gitignoreINSTALLMakefile.amNEWS
android
configure.ac
doc
m4
src
Compiler.hDetachedSong.hxxIdle.cxxLogBackend.cxxLogInit.cxxMain.cxxMain.hxxPlayerThread.cxxPlaylistFile.cxxSongFilter.cxxSongLoader.cxxTagStream.cxx
archive
client
command
db
decoder
encoder
event
filter
fs
input
java
lib
ls.cxx
mixer
notify.hxx
output
pcm
playlist
protocol
queue
storage
system
tag
thread
unix
util
systemd
test

2
.gitignore vendored

@@ -77,6 +77,8 @@ tags
/test/test_vorbis_encoder
/test/DumpDatabase
/lib/
/*.tar.gz
/*.tar.bz2
/*.tar.xz

@@ -12,7 +12,7 @@ install MPD. If more information is desired, read the user manual:
Dependencies
------------
gcc 4.6 or later - http://gcc.gnu.org/
gcc 4.7 or later - http://gcc.gnu.org/
clang 3.2 or later - http://clang.llvm.org/
Any other C++11 compliant compiler should also work.
@@ -116,12 +116,6 @@ For WavPack playback.
libadplug - http://adplug.sourceforge.net/
For AdLib playback.
despotify - https://github.com/SimonKagstrom/despotify
For Spotify playback.
MP4v2 - https://code.google.com/p/mp4v2/
For MP4 playback. You will need FAAD2.
Optional Miscellaneous Dependencies
-----------------------------------

@@ -28,8 +28,6 @@ noinst_LIBRARIES = \
libmixer_plugins.a \
liboutput_plugins.a
libmpd_a_DEPENDENCIES =
libmpd_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(LIBMPDCLIENT_CFLAGS) \
$(AVAHI_CFLAGS) \
@@ -130,7 +128,6 @@ libmpd_a_SOURCES = \
src/IOThread.cxx src/IOThread.hxx \
src/Instance.cxx src/Instance.hxx \
src/win32/Win32Main.cxx \
src/osx/OSXMain.cxx \
src/GlobalEvents.cxx src/GlobalEvents.hxx \
src/MixRampInfo.hxx \
src/MusicBuffer.cxx src/MusicBuffer.hxx \
@@ -284,13 +281,13 @@ android/build/build.xml: android/AndroidManifest.xml
ln -s $(abs_srcdir)/android/res/values android/build/res
$(ANDROID_SDK)/tools/android update project --path android/build --target android-17
android/build/bin/classes/org/musicpd/Bridge.class: android/src/Bridge.java android/build/build.xml
android/build/bin/classes/org/musicpd/Bridge.class: android/src/Bridge.java android/build/build.xml android/build/res/drawable/icon.png
cd android/build && ant compile-jni-classes
android/build/include/org_musicpd_Bridge.h: android/build/bin/classes/org/musicpd/Bridge.class
javah -classpath $(ANDROID_SDK)/platforms/android-17/android.jar:android/build/bin/classes -d $(@D) org.musicpd.Bridge
libmpd_a_DEPENDENCIES += android/build/include/org_musicpd_Bridge.h
BUILT_SOURCES = android/build/include/org_musicpd_Bridge.h
android/build/libs/armeabi-v7a/libmpd.so: libmpd.so android/build/build.xml
mkdir -p $(@D)
@@ -362,6 +359,7 @@ libutil_a_SOURCES = \
src/util/Clamp.hxx \
src/util/Alloc.cxx src/util/Alloc.hxx \
src/util/VarSize.hxx \
src/util/ScopeExit.hxx \
src/util/Error.cxx src/util/Error.hxx \
src/util/Domain.hxx \
src/util/ReusableArray.hxx \
@@ -465,11 +463,13 @@ ICU_LDADD = libicu.a $(ICU_LIBS)
libpcm_a_SOURCES = \
src/pcm/Domain.cxx src/pcm/Domain.hxx \
src/pcm/Traits.hxx \
src/pcm/Interleave.cxx src/pcm/Interleave.hxx \
src/pcm/PcmBuffer.cxx src/pcm/PcmBuffer.hxx \
src/pcm/PcmExport.cxx src/pcm/PcmExport.hxx \
src/pcm/PcmConvert.cxx src/pcm/PcmConvert.hxx \
src/pcm/PcmDop.cxx src/pcm/PcmDop.hxx \
src/pcm/Volume.cxx src/pcm/Volume.hxx \
src/pcm/Silence.cxx src/pcm/Silence.hxx \
src/pcm/PcmMix.cxx src/pcm/PcmMix.hxx \
src/pcm/PcmChannels.cxx src/pcm/PcmChannels.hxx \
src/pcm/PcmPack.cxx src/pcm/PcmPack.hxx \
@@ -530,7 +530,7 @@ libfs_a_SOURCES = \
src/fs/Traits.cxx src/fs/Traits.hxx \
src/fs/Config.cxx src/fs/Config.hxx \
src/fs/Charset.cxx src/fs/Charset.hxx \
src/fs/Path.cxx src/fs/Path.hxx \
src/fs/Path.cxx src/fs/Path2.cxx src/fs/Path.hxx \
src/fs/AllocatedPath.cxx src/fs/AllocatedPath.hxx \
src/fs/FileSystem.cxx src/fs/FileSystem.hxx \
src/fs/StandardDirectory.cxx src/fs/StandardDirectory.hxx \
@@ -801,6 +801,11 @@ endif
if HAVE_FFMPEG
noinst_LIBRARIES += libffmpeg.a
libffmpeg_a_SOURCES = \
src/lib/ffmpeg/Init.cxx src/lib/ffmpeg/Init.hxx \
src/lib/ffmpeg/Time.hxx \
src/lib/ffmpeg/Buffer.hxx \
src/lib/ffmpeg/LogError.cxx src/lib/ffmpeg/LogError.hxx \
src/lib/ffmpeg/LogCallback.cxx src/lib/ffmpeg/LogCallback.hxx \
src/lib/ffmpeg/Error.cxx src/lib/ffmpeg/Error.hxx \
src/lib/ffmpeg/Domain.cxx src/lib/ffmpeg/Domain.hxx
libffmpeg_a_CPPFLAGS = $(AM_CPPFLAGS) \
@@ -829,7 +834,6 @@ libdecoder_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(WAVPACK_CFLAGS) \
$(MAD_CFLAGS) \
$(MPG123_CFLAGS) \
$(MP4V2_CFLAGS) \
$(OPUS_CFLAGS) \
$(FFMPEG_CFLAGS) \
$(MPCDEC_CFLAGS) \
@@ -849,7 +853,6 @@ DECODER_LIBS = \
$(WAVPACK_LIBS) \
$(MAD_LIBS) \
$(MPG123_LIBS) \
$(MP4V2_LIBS) \
$(OPUS_LIBS) \
$(FFMPEG_LIBS2) \
$(MPCDEC_LIBS) \
@@ -964,12 +967,6 @@ noinst_LIBRARIES += libmodplug_decoder_plugin.a
DECODER_LIBS += libmodplug_decoder_plugin.a $(MODPLUG_LIBS)
endif
if HAVE_MP4V2
libdecoder_a_SOURCES += \
src/decoder/plugins/Mp4v2DecoderPlugin.cxx \
src/decoder/plugins/Mp4v2DecoderPlugin.hxx
endif
if ENABLE_SIDPLAY
libdecoder_a_SOURCES += \
src/decoder/plugins/SidplayDecoderPlugin.cxx \
@@ -990,6 +987,8 @@ endif
if HAVE_FFMPEG
libdecoder_a_SOURCES += \
src/decoder/plugins/FfmpegIo.cxx \
src/decoder/plugins/FfmpegIo.hxx \
src/decoder/plugins/FfmpegMetaData.cxx \
src/decoder/plugins/FfmpegMetaData.hxx \
src/decoder/plugins/FfmpegDecoderPlugin.cxx \
@@ -1113,6 +1112,7 @@ endif
#
libinput_a_SOURCES = \
src/input/Domain.cxx src/input/Domain.hxx \
src/input/Init.cxx src/input/Init.hxx \
src/input/Registry.cxx src/input/Registry.hxx \
src/input/Open.cxx \
@@ -1133,7 +1133,6 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(NFS_CFLAGS) \
$(CDIO_PARANOIA_CFLAGS) \
$(FFMPEG_CFLAGS) \
$(DESPOTIFY_CFLAGS) \
$(MMS_CFLAGS)
INPUT_LIBS = \
@@ -1143,7 +1142,6 @@ INPUT_LIBS = \
$(NFS_LIBS) \
$(CDIO_PARANOIA_LIBS) \
$(FFMPEG_LIBS2) \
$(DESPOTIFY_LIBS) \
$(MMS_LIBS)
if HAVE_ALSA
@@ -1189,15 +1187,6 @@ libinput_a_SOURCES += \
src/input/plugins/MmsInputPlugin.cxx src/input/plugins/MmsInputPlugin.hxx
endif
if ENABLE_DESPOTIFY
libinput_a_SOURCES += \
src/lib/despotify/DespotifyUtils.cxx \
src/lib/despotify/DespotifyUtils.hxx \
src/input/plugins/DespotifyInputPlugin.cxx \
src/input/plugins/DespotifyInputPlugin.hxx
endif
liboutput_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(AO_CFLAGS) \
$(ALSA_CFLAGS) \
@@ -1240,6 +1229,7 @@ liboutput_plugins_a_SOURCES = \
MIXER_LIBS = \
libmixer_plugins.a \
$(ALSA_LIBS) \
$(PULSE_LIBS)
MIXER_API_SRC = \
@@ -1402,14 +1392,6 @@ PLAYLIST_LIBS = \
$(EXPAT_LIBS) \
$(FLAC_LIBS)
if ENABLE_DESPOTIFY
libplaylist_plugins_a_SOURCES += \
src/lib/despotify/DespotifyUtils.cxx \
src/lib/despotify/DespotifyUtils.hxx \
src/playlist/plugins/DespotifyPlaylistPlugin.cxx \
src/playlist/plugins/DespotifyPlaylistPlugin.hxx
endif
if ENABLE_SOUNDCLOUD
libplaylist_plugins_a_SOURCES += \
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx \
@@ -1646,12 +1628,6 @@ if HAVE_LIBUPNP
test_run_neighbor_explorer_SOURCES += src/lib/expat/ExpatParser.cxx
endif
if ENABLE_DESPOTIFY
test_run_neighbor_explorer_SOURCES += \
src/lib/despotify/DespotifyUtils.cxx \
src/lib/despotify/DespotifyUtils.hxx
endif
endif
if ENABLE_ARCHIVE
@@ -1900,6 +1876,7 @@ test_run_convert_SOURCES = test/run_convert.cxx \
src/AudioParser.cxx
test_run_convert_LDADD = \
$(PCM_LIBS) \
libconf.a \
libutil.a \
$(GLIB_LIBS)
@@ -2141,19 +2118,13 @@ user_DATA = $(wildcard doc/user/*.html)
developerdir = $(docdir)/developer
developer_DATA = $(wildcard doc/developer/*.html)
if HAVE_XMLTO
DOCBOOK_HTML = $(patsubst %.xml,%/index.html,$(DOCBOOK_FILES))
$(DOCBOOK_HTML): %/index.html: %.xml
DOCBOOK_INCLUDES = $(wildcard $(srcdir)/doc/include/*.xml)
$(DOCBOOK_HTML): %/index.html: %.xml $(DOCBOOK_INCLUDES)
$(XMLTO) -o $(@D) --stringparam chunker.output.encoding=utf-8 html --stringparam use.id.as.filename=1 $<
else
DOCBOOK_HTML =
endif
doc/api/html/index.html: doc/doxygen.conf
@$(MKDIR_P) $(@D)
$(DOXYGEN) $<
@@ -2192,7 +2163,15 @@ EXTRA_DIST = $(doc_DATA) autogen.sh \
test/test_archive_bzip2.sh \
test/test_archive_iso9660.sh \
test/test_archive_zzip.sh \
$(wildcard scripts/*.sh) \
$(wildcard $(srcdir)/scripts/*.rb) \
$(man_MANS) $(DOCBOOK_FILES) doc/mpdconf.example doc/doxygen.conf \
$(wildcard $(srcdir)/doc/include/*.xml) \
systemd/mpd.socket \
android/AndroidManifest.xml \
android/build.py \
android/custom_rules.xml \
android/res/values/strings.xml \
android/src/Bridge.java \
android/src/Loader.java \
android/src/Main.java \
src/win32/mpd_win32_rc.rc.in src/win32/mpd.ico

223
NEWS

@@ -1,3 +1,188 @@
ver 0.19.18 (2016/08/05)
* decoder
- ffmpeg: fix crash with older FFmpeg versions (< 3.0)
- ffmpeg: log detailed error message
- ffmpeg: support FFmpeg 3.1
- sidplay: detect libsidplay2 with pkg-config
- sidplay: log detailed error message
- sidplay: read the "date" tag
- sidplay: allow building with libsidplayfp instead of libsidplay2
* output
- shout: recognize setting "encoder" instead of "encoding"
* fix memory leak after stream failure
* fix build failure with Boost 1.61
* require gcc 4.7 or newer
ver 0.19.17 (2016/07/09)
* decoder
- flac: fix assertion failure while seeking
- flac: fix stream duration indicator
- fix seek problems in several plugins
* fix spurious seek error "Failed to allocate silence buffer"
* replay gain: fix "replay_gain_handler mixer" setting
* DSD: use 0x69 as silence pattern
* fix use-after-free bug on "close" and "kill"
ver 0.19.16 (2016/06/13)
* faster seeking
* fix system include path order
* add missing DocBook file to tarball
ver 0.19.15 (2016/04/30)
* decoder
- ffmpeg: support FFmpeg 3.0
- ffmpeg: use as fallback instead of "mad" if no plugin matches
- opus: support bigger OpusTags packets
* fix more build failures on non-glibc builds due to constexpr Mutex
* fix build failure due to missing include
* fix unit test on Alpha
ver 0.19.14 (2016/03/18)
* decoder
- dsdiff: fix off-by-one buffer overflow
- opus: limit tag size to 64 kB
* archive
- iso9660: fix buffer overflow
* fix quadratic runtime bug in the tag pool
* fix build failures on non-glibc builds due to constexpr Mutex
ver 0.19.13 (2016/02/23)
* tags
- aiff, riff: fix ID3 chunk padding
* decoder
- ffmpeg: support the TAK codec
* fix disappearing duration of remote songs during playback
* initialize supplementary groups with glibc 2.19+
ver 0.19.12 (2015/12/15)
* fix assertion failure on malformed UTF-8 tag
* fix build failure on non-Linux systems
* fix LimitRTTIME in systemd unit file
ver 0.19.11 (2015/10/27)
* tags
- ape: fix buffer overflow
* decoder
- ffmpeg: fix crash due to wrong avio_alloc_context() call
- gme: don't loop forever, fall back to GME's default play length
* encoder
- flac: fix crash with 32 bit playback
* mixer
- fix mixer lag after enabling/disabling output
ver 0.19.10 (2015/06/21)
* input
- curl: fix deadlock on small responses
- smbclient: fix DFF playback
* decoder
- ffmpeg: improve seeking accuracy
- fix stuck stream tags
* encoder
- opus: fix bogus granulepos
* output
- fix failure to open device right after booting
* neighbor
- nfs: fix deadlock when connecting
* fix "single" mode breakage due to queue edits
ver 0.19.9 (2015/02/06)
* decoder
- dsdiff, dsf: raise ID3 tag limit to 1 MB
* playlist: fix loading duplicate tag types from state file
* despotify: remove defunct plugin
* fix clock integer overflow on OS X
* fix gcc 5.0 warnings
* fix build failure with uClibc
* fix build failure on non-POSIX operating systems
* fix dependency issue on parallel Android build
* fix database/state file saving on Windows
ver 0.19.8 (2015/01/14)
* input
- curl: fix bug after rewinding from end-of-file
- mms: reduce delay at the beginning of playback
* decoder
- dsdiff, dsf: allow ID3 tags larger than 4 kB
- ffmpeg: support interleaved floating point
* fix clang 3.6 warnings
* fix build failure on NetBSD
ver 0.19.7 (2014/12/17)
* input
- nfs: fix crash while canceling a failing file open operation
- nfs: fix memory leak on connection failure
- nfs: fix reconnect after mount failure
- nfs: implement mount timeout (60 seconds)
* storage
- nfs: implement I/O timeout (60 seconds)
* playlist
- embcue: fix filename suffix detection
- don't skip non-existent songs in "listplaylist"
* decoder
- ffmpeg: fix time stamp underflow
* fix memory allocator bug on Windows
ver 0.19.6 (2014/12/08)
* decoder
- ffmpeg: support FFmpeg 2.5
* fix build failure with musl
* android
- update libFLAC to 1.3.1
- update FFmpeg to 2.5
ver 0.19.5 (2014/11/26)
* input
- nfs: fix crash on connection failure
* archive
- zzip: fix crash after seeking
* decoder
- dsdiff, dsf, opus: fix deadlock while seeking
- mp4v2: remove because of incompatible license
ver 0.19.4 (2014/11/18)
* protocol
- workaround for buggy clients that send "add /"
* decoder
- ffmpeg: support opus
- opus: add MIME types audio/ogg and application/ogg
* fix crash on failed filename charset conversion
* fix local socket detection from uid=0 (root)
ver 0.19.3 (2014/11/11)
* protocol
- fix "(null)" result string to "list" when AlbumArtist is disabled
* database
- upnp: fix breakage due to malformed URIs
* input
- curl: another fix for redirected streams
* decoder
- audiofile: fix crash while playing streams
- audiofile: fix bit rate calculation
- ffmpeg: support opus
- opus: fix bogus duration on streams
- opus: support chained streams
- opus: improved error logging
* fix distorted audio with soxr resampler
* fix build failure on Mac OS X with non-Apple compilers
ver 0.19.2 (2014/11/02)
* input
- curl: fix redirected streams
* playlist
- don't allow empty playlist name
- m3u: don't ignore unterminated last line
- m3u: recognize the file suffix ".m3u8"
* decoder
- ignore URI query string for plugin detection
- faad: remove workaround for ancient libfaad2 ABI bug
- ffmpeg: recognize MIME type audio/aacp
- mad: fix negative replay gain values
* output
- fix memory leak after filter initialization error
- fall back to PCM if given DSD sample rate is not supported
* fix assertion failure on unsupported PCM conversion
* auto-disable plugins that require GLib when --disable-glib is used
ver 0.19.1 (2014/10/19)
* input
- mms: fix deadlock bug
@@ -85,6 +270,44 @@ ver 0.19 (2014/10/10)
* install systemd unit for socket activation
* Android port
ver 0.18.23 (2015/02/06)
* despotify: remove defunct plugin
* fix clock integer overflow on OS X
* fix gcc 5.0 warnings
ver 0.18.22 (2015/01/14)
* fix clang 3.6 warnings
ver 0.18.21 (2014/12/17)
* playlist
- embcue: fix filename suffix detection
* decoder
- ffmpeg: fix time stamp underflow
ver 0.18.20 (2014/12/08)
* decoder
- ffmpeg: support FFmpeg 2.5
* fix build failure with musl
ver 0.18.19 (2014/11/26)
* archive
- zzip: fix crash after seeking
ver 0.18.18 (2014/11/18)
* decoder
- ffmpeg: support opus
* fix crash on failed filename charset conversion
* fix local socket detection from uid=0 (root)
ver 0.18.17 (2014/11/02)
* playlist
- don't allow empty playlist name
- m3u: recognize the file suffix ".m3u8"
* decoder
- ignore URI query string for plugin detection
- faad: remove workaround for ancient libfaad2 ABI bug
- ffmpeg: recognize MIME type audio/aacp
ver 0.18.16 (2014/09/26)
* fix DSD breakage due to typo in configure.ac

@@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.musicpd"
android:installLocation="auto"
android:versionCode="7"
android:versionName="0.19.1">
android:versionCode="13"
android:versionName="0.19.9">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>

@@ -23,7 +23,7 @@ if not os.path.isdir(ndk_path):
sys.exit(1)
# the path to the MPD sources
mpd_path = os.path.dirname(os.path.dirname(sys.argv[0]))
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
# output directories
lib_path = os.path.abspath('lib')
@@ -40,8 +40,8 @@ build_arch = 'linux-x86_64'
os.environ['PKG_CONFIG_LIBDIR'] = os.path.join(root_path, 'lib/pkgconfig')
# select the NDK compiler
gcc_version = '4.8'
llvm_version = '3.3'
gcc_version = '4.9'
llvm_version = '3.5'
# select the NDK target
ndk_arch = 'arm'
@@ -314,8 +314,8 @@ thirdparty_libs = [
),
AutotoolsProject(
'https://svn.xiph.org/releases/flac/flac-1.3.0.tar.xz',
'13b5c214cee8373464d3d65dee362cdd',
'http://downloads.xiph.org/releases/flac/flac-1.3.1.tar.xz',
'b9922c9a0378c88d3e901b234f852698',
'lib/libFLAC.a',
[
'--disable-shared', '--enable-static',
@@ -341,8 +341,8 @@ thirdparty_libs = [
),
FfmpegProject(
'http://www.ffmpeg.org/releases/ffmpeg-2.2.3.tar.bz2',
'dbb5b6b69bd010916f17df0ae596e0b1',
'http://ffmpeg.org/releases/ffmpeg-2.5.tar.bz2',
'4346fe710cc6bdd981f6534d2420d1ab',
'lib/libavcodec.a',
[
'--disable-shared', '--enable-static',
@@ -366,8 +366,8 @@ thirdparty_libs = [
),
AutotoolsProject(
'http://curl.haxx.se/download/curl-7.37.0.tar.lzma',
'54bfd1eb5214f604186d6f5ac61c7781',
'http://curl.haxx.se/download/curl-7.39.0.tar.lzma',
'e9aa6dec29920eba8ef706ea5823bad7',
'lib/libcurl.a',
[
'--disable-shared', '--enable-static',

@@ -1,10 +1,10 @@
AC_PREREQ(2.60)
AC_INIT(mpd, 0.19.1, musicpd-dev-team@lists.sourceforge.net)
AC_INIT(mpd, 0.19.18, musicpd-dev-team@lists.sourceforge.net)
VERSION_MAJOR=0
VERSION_MINOR=19
VERSION_REVISION=0
VERSION_REVISION=18
VERSION_EXTRA=0
AC_CONFIG_SRCDIR([src/Main.cxx])
@@ -206,6 +206,8 @@ if test x$host_is_linux = xyes; then
fi
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
AC_CHECK_FUNCS(initgroups)
AC_CHECK_FUNCS(strndup)
if test x$host_is_linux = xyes; then
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
@@ -293,7 +295,9 @@ fi
AC_ARG_ENABLE(libmpdclient,
AS_HELP_STRING([--enable-libmpdclient],
[enable support for the MPD client]),,
enable_libmpdclient=$database_auto)
enable_libmpdclient=auto)
MPD_DEPENDS([enable_libmpdclient], [enable_database],
[Cannot use --enable-libmpdclient with --disable-database])
AC_ARG_ENABLE(expat,
AS_HELP_STRING([--enable-expat],
@@ -303,7 +307,9 @@ AC_ARG_ENABLE(expat,
AC_ARG_ENABLE(upnp,
AS_HELP_STRING([--enable-upnp],
[enable UPnP client support (default: auto)]),,
enable_upnp=$database_auto)
enable_upnp=auto)
MPD_DEPENDS([enable_upnp], [enable_database],
[Cannot use --enable-upnp with --disable-database])
AC_ARG_ENABLE(adplug,
AS_HELP_STRING([--enable-adplug],
@@ -323,6 +329,8 @@ AC_ARG_ENABLE(ao,
AS_HELP_STRING([--enable-ao],
[enable support for libao]),,
enable_ao=auto)
MPD_DEPENDS([enable_ao], [enable_glib],
[Cannot use --enable-ao with --disable-glib])
AC_ARG_ENABLE(audiofile,
AS_HELP_STRING([--enable-audiofile],
@@ -343,6 +351,8 @@ AC_ARG_ENABLE(cdio-paranoia,
AS_HELP_STRING([--enable-cdio-paranoia],
[enable support for audio CD support]),,
enable_cdio_paranoia=auto)
MPD_DEPENDS([enable_cdio_paranoia], [enable_glib],
[Cannot use --enable-cdio-paranoia with --disable-glib])
AC_ARG_ENABLE(curl,
AS_HELP_STRING([--enable-curl],
@@ -398,11 +408,15 @@ AC_ARG_ENABLE(gme,
AS_HELP_STRING([--enable-gme],
[enable Blargg's game music emulator plugin]),,
enable_gme=auto)
MPD_DEPENDS([enable_gme], [enable_glib],
[Cannot use --enable-gme with --disable-glib])
AC_ARG_ENABLE(httpd-output,
AS_HELP_STRING([--enable-httpd-output],
[enables the HTTP server output]),,
[enable_httpd_output=auto])
MPD_DEPENDS([enable_httpd_output], [enable_glib],
[Cannot use --enable-httpd-output with --disable-glib])
AC_ARG_ENABLE(id3,
AS_HELP_STRING([--enable-id3],
@@ -428,18 +442,17 @@ AC_ARG_ENABLE(jack,
AS_HELP_STRING([--enable-jack],
[enable jack support]),,
enable_jack=auto)
MPD_DEPENDS([enable_jack], [enable_glib],
[Cannot use --enable-jack with --disable-glib])
AC_SYS_LARGEFILE
AC_ARG_ENABLE(despotify,
AS_HELP_STRING([--enable-despotify],
[enable support for despotify (default: disable)]),,
[enable_despotify=no])
AC_ARG_ENABLE(soundcloud,
AS_HELP_STRING([--enable-soundcloud],
[enable support for soundcloud.com]),,
[enable_soundcloud=auto])
MPD_DEPENDS([enable_soundcloud], [enable_glib],
[Cannot use --enable-soundcloud with --disable-glib])
AC_ARG_ENABLE(lame-encoder,
AS_HELP_STRING([--enable-lame-encoder],
@@ -480,11 +493,6 @@ AC_ARG_ENABLE(modplug,
[enable modplug decoder plugin]),,
enable_modplug=auto)
AC_ARG_ENABLE(mp4v2,
AS_HELP_STRING([--enable-mp4v2],
[enable libmp4v2 decoder plugin]),,
enable_mp4v2=auto)
AC_ARG_ENABLE(mpc,
AS_HELP_STRING([--enable-mpc],
[disable musepack (MPC) support (default: auto)]),,
@@ -559,6 +567,8 @@ AC_ARG_ENABLE(sqlite,
AS_HELP_STRING([--enable-sqlite],
[enable support for the SQLite database]),,
[enable_sqlite=$database_auto])
MPD_DEPENDS([enable_sqlite], [enable_glib],
[Cannot use --enable-sqlite with --disable-glib])
AC_ARG_ENABLE(systemd-daemon,
AS_HELP_STRING([--enable-systemd-daemon],
@@ -599,6 +609,8 @@ AC_ARG_ENABLE(vorbis-encoder,
AS_HELP_STRING([--enable-vorbis-encoder],
[enable the Ogg Vorbis encoder]),,
[enable_vorbis_encoder=auto])
MPD_DEPENDS([enable_vorbis_encoder], [enable_glib],
[Cannot use --enable-vorbis-encoder with --disable-glib])
AC_ARG_ENABLE(wave-encoder,
AS_HELP_STRING([--enable-wave-encoder],
@@ -609,6 +621,8 @@ AC_ARG_ENABLE(wavpack,
AS_HELP_STRING([--enable-wavpack],
[enable WavPack support]),,
enable_wavpack=auto)
MPD_DEPENDS([enable_wavpack], [enable_glib],
[Cannot use --enable-wavpack with --disable-glib])
AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror],
@@ -687,12 +701,6 @@ AC_ARG_ENABLE(glib,
if test x$enable_glib = xyes; then
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
GLIB_CFLAGS=`echo $GLIB_CFLAGS |sed -e 's,-I/,-isystem /,g'`
fi
AC_DEFINE(HAVE_GLIB, 1, [Define if GLib is used])
fi
AM_CONDITIONAL(HAVE_GLIB, test x$enable_glib = xyes)
@@ -960,14 +968,6 @@ if test x$enable_nfs = xyes; then
fi
AM_CONDITIONAL(ENABLE_NFS, test x$enable_nfs = xyes)
dnl --------------------------------- Despotify ---------------------------------
MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify],
[Despotify support], [despotify not found])
if test x$enable_despotify = xyes; then
AC_DEFINE(ENABLE_DESPOTIFY, 1, [Define when despotify is enabled])
fi
AM_CONDITIONAL(ENABLE_DESPOTIFY, test x$enable_despotify = xyes)
dnl --------------------------------- Soundcloud ------------------------------
if test x$enable_soundcloud != xno; then
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
@@ -1240,24 +1240,6 @@ if test x$enable_modplug = xyes; then
fi
AM_CONDITIONAL(HAVE_MODPLUG, test x$enable_modplug = xyes)
dnl -------------------------------- libmp4v2 ---------------------------------
if test x$enable_aac = xyes; then
MPD_AUTO_LIB(mp4v2, MP4V2, mp4v2, MP4Create, [-lmp4v2], [],
[mp4v2], [libmp4v2 not found])
if test x$enable_mp4v2 = xyes; then
AC_DEFINE(HAVE_MP4V2, 1, [Define to use libmp4v2 for MP4 decoding])
fi
else
if test x$enable_mp4v2 = xyes; then
AC_MSG_ERROR([MP4V2 requires AAC!])
fi
enable_mp4v2=no
fi
AM_CONDITIONAL(HAVE_MP4V2, test x$enable_mp4v2 = xyes)
dnl -------------------------------- libopus ----------------------------------
MPD_AUTO_PKG(opus, OPUS, [opus ogg],
[opus decoder plugin], [libopus not found])
@@ -1351,31 +1333,36 @@ AM_CONDITIONAL(ENABLE_VORBIS_DECODER, test x$enable_vorbis = xyes || test x$enab
dnl --------------------------------- sidplay ---------------------------------
if test x$enable_sidplay != xno; then
# we're not using pkg-config here
# because libsidplay2's .pc file requires libtool
AC_CHECK_LIB([sidplay2],[main],[found_sidplay=yes],[found_sidplay=no],[])
dnl Check for libsidplayfp first
PKG_CHECK_MODULES([SIDPLAY], [libsidplayfp libsidutils],
[found_sidplayfp=yes],
[found_sidplayfp=no])
found_sidplay=$found_sidplayfp
fi
if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
PKG_CHECK_MODULES([SIDPLAY], [libsidplay2 libsidutils],
[found_sidplay=yes],
[found_sidplay=no])
MPD_AUTO_PRE(sidplay, [sidplay decoder plugin],
[libsidplay2 not found])
fi
if test x$enable_sidplay != xno; then
if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
AC_CHECK_LIB([resid-builder], [main],
[found_sidplay=yes], [found_sidplay=no])
if test x$found_sidplay = xyes; then
AC_CHECK_LIB([sidutils],[main],[:],[found_sidplay=no],[])
fi
MPD_AUTO_RESULT(sidplay, [sidplay decoder plugin],
[libresid-builder or libsidutils not found])
[libresid-builder not found])
fi
if test x$enable_sidplay = xyes; then
AC_SUBST(SIDPLAY_LIBS,"-lsidplay2 -lresid-builder -lsidutils")
AC_SUBST(SIDPLAY_CFLAGS,)
SIDPLAY_LIBS="$SIDPLAY_LIBS -lresid-builder"
AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplay2 support])
if test x$found_sidplayfp = xyes; then
AC_DEFINE(HAVE_SIDPLAYFP, 1, [Define if libsidplayfp is used instead of libsidplay2])
fi
fi
AM_CONDITIONAL(ENABLE_SIDPLAY, test x$enable_sidplay = xyes)
@@ -1709,8 +1696,11 @@ dnl Documentation
dnl ---------------------------------------------------------------------------
if test x$enable_documentation = xyes; then
AC_PATH_PROG(XMLTO, xmlto)
if test x$XMLTO = x; then
AC_MSG_ERROR([xmlto not found])
fi
AC_SUBST(XMLTO)
AM_CONDITIONAL(HAVE_XMLTO, test x$XMLTO != x)
AC_PATH_PROG(DOXYGEN, doxygen)
if test x$DOXYGEN = x; then
@@ -1718,8 +1708,6 @@ if test x$enable_documentation = xyes; then
fi
AC_SUBST(DOXYGEN)
else
AM_CONDITIONAL(HAVE_XMLTO, false)
fi
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
@@ -1826,9 +1814,14 @@ results(ipv6, "IPv6")
results(tcp, "TCP")
results(un,[UNIX Domain Sockets])
printf '\nStorage support:\n\t'
results(nfs, [NFS])
results(smbclient, [SMB])
printf '\nFile format support:\n\t'
results(aac, [AAC])
results(adplug, [AdPlug])
results(dsd, [DSD])
results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG])
results(flac, [FLAC])
@@ -1838,7 +1831,6 @@ printf '\n\t'
results(sndfile, [libsndfile])
results(mikmod, [MikMod])
results(modplug, [MODPLUG])
results(mp4v2, [MP4V2])
results(mad, [MAD])
results(mpg123, [MPG123])
results(mpc, [Musepack])
@@ -1897,7 +1889,6 @@ printf '\nStreaming support:\n\t'
results(cdio_paranoia, [CDIO_PARANOIA])
results(curl,[CURL])
results(smbclient,[SMBCLIENT])
results(despotify,[Despotify])
results(soundcloud,[Soundcloud])
printf '\n\t'
results(mms,[MMS])

@@ -1,6 +1,7 @@
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"docbook/dtd/xml/4.2/docbookx.dtd">
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<title>The Music Player Daemon - Developer's Manual</title>
@@ -40,7 +41,7 @@
<listitem>
<para>
the code should be C++11 compliant, and must compile with
<application>GCC</application> 4.6 and
<application>GCC</application> 4.7 and
<application>clang</application> 3.2
</para>
</listitem>

154
doc/include/tags.xml Normal file

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

@@ -174,18 +174,6 @@ MP3 playback.
This specifies whether relative or absolute paths for song filenames are used
when saving playlists. The default is "no".
.TP
.B metadata_to_use <tags>
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, disc,
musicbrainz_artistid, musicbrainz_albumid, musicbrainz_albumartistid,
musicbrainz_releasetrackid, 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 whether to support automatic update of music database when
files are changed in music_directory. The default is to disable autoupdate
@@ -195,16 +183,6 @@ of database.
Limit the depth of the directories being watched, 0 means only watch
the music directory itself. There is no limit by default.
.TP
.B despotify_user <name>
This specifies the user to use when logging in to Spotify using the despotify plugins.
.TP
.B despotify_password <name>
This specifies the password to use when logging in to Spotify using the despotify plugins.
.TP
.B despotify_high_bitrate <yes or no>
This specifies if the requested bitrate for Spotify should be high or not. Higher sounds
better but requires more processing and higher bandwidth. Default is yes.
.TP
.SH REQUIRED AUDIO OUTPUT PARAMETERS
.TP
.B type <type>

@@ -115,7 +115,7 @@
#
# 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.
# found in the user manual.
#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
@@ -231,7 +231,7 @@ input {
#
#audio_output {
# type "shout"
# encoding "ogg" # optional
# encoder "vorbis" # optional
# name "My Shout Stream"
# host "localhost"
# port "8000"

@@ -1,6 +1,7 @@
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"docbook/dtd/xml/4.2/docbookx.dtd">
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<title>The Music Player Daemon protocol</title>
@@ -201,6 +202,25 @@
omitted, then the maximum possible value is assumed.
</para>
</section>
<section id="tags">
<title>Tags</title>
<para>
The following tags are supported by
<application>MPD</application>:
</para>
<xi:include href="include/tags.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
<para>
There can be multiple values for some of these tags. For
example, <application>MPD</application> may return multiple
lines with a <varname>performer</varname> tag. A tag value is
a UTF-8 string.
</para>
</section>
</chapter>
<chapter id="recipes">
@@ -1141,7 +1161,7 @@ OK
</term>
<listitem>
<para>
Searches case-sensitively for partial matches in the
Searches case-insensitively for partial matches in the
current playlist.
</para>
</listitem>
@@ -1533,6 +1553,7 @@ OK
<command>count</command>
<arg choice="req"><replaceable>TAG</replaceable></arg>
<arg choice="req"><replaceable>NEEDLE</replaceable></arg>
<arg choice="opt"><replaceable>...</replaceable></arg>
<arg choice="opt">group</arg>
<arg choice="opt"><replaceable>GROUPTYPE</replaceable></arg>
</cmdsynopsis>

@@ -1,6 +1,7 @@
<?xml version='1.0' encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"docbook/dtd/xml/4.2/docbookx.dtd">
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<title>The Music Player Daemon - User's Manual</title>
@@ -16,7 +17,7 @@
<application>MPD</application> (Music Player Daemon) is, as the
name suggests, a server software allowing you to remotely play
your music, handle playlists, deliver music (HTTP streams with
various sub-protocols) and organizze playlists.
various sub-protocols) and organize playlists.
</para>
<para>
@@ -89,7 +90,7 @@ cd mpd-version</programlisting>
</para>
<programlisting>
apt-get install g++ automake autoconf \
apt-get install g++ \
libmad0-dev libmpg123-dev libid3tag0-dev \
libflac-dev libvorbis-dev libopus-dev \
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
@@ -98,19 +99,21 @@ apt-get install g++ automake autoconf \
libsidplay2-dev libsidutils-dev libresid-builder-dev \
libavcodec-dev libavformat-dev \
libmp3lame-dev \
libsamplerate0-dev \
libsamplerate0-dev libsoxr-dev \
libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
libzzip-dev \
libcurl4-gnutls-dev libyajl-dev \
libcurl4-gnutls-dev libyajl-dev libexpat-dev \
libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
libpulse-dev libroar-dev libshout3-dev \
libmpdclient-dev \
libnfs-dev libsmbclient-dev \
libupnp-dev \
libavahi-client-dev \
libsqlite3-dev \
libsystemd-daemon-dev libwrap0-dev \
libcppunit-dev xmlto \
libboost-dev \
libglib2.0-dev
libglib2.0-dev libicu-dev
</programlisting>
<para>
@@ -313,9 +316,8 @@ systemctl start mpd.socket</programlisting>
</para>
<programlisting>input {
plugin "despotify"
user "foo"
password "bar"
plugin "curl"
proxy "proxy.local"
}
</programlisting>
@@ -943,6 +945,33 @@ systemctl start mpd.socket</programlisting>
<section id="config_other">
<title>Other Settings</title>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>metadata_to_use</varname>
<parameter>TAG1,TAG2,...</parameter>
</entry>
<entry>
Use only the specified tags, and ignore the others.
This setting can reduce the database size and
<application>MPD</application>'s memory usage by
omitting unused tags. By default, all tags but
<varname>comment</varname> are enabled. The special
value "none" disables all tags.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<section>
<title>The State File</title>
@@ -1189,6 +1218,58 @@ database {
plugin).
</para>
</section>
<section id="realtime">
<title>Real-Time Scheduling</title>
<para>
On Linux, <application>MPD</application> attempts to configure
<ulink
url="https://en.wikipedia.org/wiki/Real-time_computing">real-time
scheduling</ulink> for some threads that benefit from it.
</para>
<para>
This is only possible you allow <application>MPD</application>
to do it. This privilege is controlled by
<varname>RLIMIT_RTPRIO</varname>
<varname>RLIMIT_RTTIME</varname>. You can configure this
privilege with <command>ulimit</command> before launching
<application>MPD</application>:
</para>
<programlisting>ulimit -HS -r 50; mpd</programlisting>
<para>
Or you can use the <command>prlimit</command> program from the
<application>util-linux</application> package:
</para>
<programlisting>prlimit --rtprio=50 --rttime=unlimited mpd</programlisting>
<para>
The <application>systemd</application> service file shipped
with <application>MPD</application> comes with this setting.
</para>
<para>
This works only if the Linux kernel was compiled with
<varname>CONFIG_RT_GROUP_SCHED</varname> disabled. Use the
following command to check this option for your current
kernel:
</para>
<programlisting>zgrep ^CONFIG_RT_GROUP_SCHED /proc/config.gz</programlisting>
<note>
<para>
There is a rumor that real-time scheduling improves audio
quality. That is not true. All it does is reduce the
probability of skipping (audio buffer xruns) when the
computer is under heavy load.
</para>
</note>
</section>
</chapter>
<chapter id="use">
@@ -1244,6 +1325,19 @@ database {
</para>
</section>
<section id="tags">
<title>Metadata</title>
<para>
When scanning or playing a song,
<application>MPD</application> parses its metadata. The
following tags are supported:
</para>
<xi:include href="include/tags.xml"
xmlns:xi="http://www.w3.org/2001/XInclude"/>
</section>
<section id="queue">
<title>The queue</title>
@@ -1738,66 +1832,6 @@ buffer_size: 16384</programlisting>
</informaltable>
</section>
<section>
<title><varname>despotify</varname></title>
<para>
Plays <ulink url="http://www.spotify.com">Spotify</ulink> tracks using the despotify
library. The despotify plugin uses a <filename>spt://</filename> URI and a Spotify
URL. So for example, you can add a song with:
</para>
<para>
<filename>mpc add spt://spotify:track:5qENVY0YEdZ7fiuOax70x1</filename>
</para>
<para>
You need a Spotify premium account to use this plugin, and you need
to setup username and password in the configuration file. The
configuration settings are global since the despotify playlist plugin
use the same settings.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>despotify_user</varname>
</entry>
<entry>
Sets up the Spotify username (required)
</entry>
</row>
<row>
<entry>
<varname>despotify_password</varname>
</entry>
<entry>
Sets up the Spotify password (required)
</entry>
</row>
<row>
<entry>
<varname>despotify_high_bitrate</varname>
</entry>
<entry>
Set up if high bitrate should be used for Spotify tunes.
High bitrate sounds better but slow systems can have problems
with playback (default yes).
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
<section>
<title><varname>file</varname></title>
@@ -2654,7 +2688,8 @@ buffer_size: 16384</programlisting>
/ <ulink
url="http://icecast.org/"><application>IceCast</application></ulink>.
HTTP streaming clients like
<application>mplayer</application> can connect to it.
<application>mplayer</application>, <application>VLC</application>,
and <application>mpv</application> can connect to it.
</para>
<para>
@@ -3284,70 +3319,6 @@ buffer_size: 16384</programlisting>
playlist files.
</para>
</section>
<section>
<title><varname>despotify</varname></title>
<para>
Adds <ulink url="http://www.spotify.com/">Spotify</ulink>
playlists. Spotify playlists use the <filename>spt://</filename> URI,
and a Spotify playlist URL. So for example, you can load a playlist
with
</para>
<para>
<filename>mpc load spt://spotify:user:simon.kagstrom:playlist:3SUwkOe5VbVHysZcidEZtH</filename>
</para>
<para>
See the despotify input plugin for configuration options (username
and password needs to be setup)
</para>
</section>
<section>
<title><varname>soundcloud</varname></title>
<para>
Adds <ulink url="https://www.soundcloud.com/">Soundcloud</ulink>
playlists. SoundCloud playlists use the <filename>soundcloud://</filename> URI,
and with a number of arguments, you may load different playlists with
</para>
<programlisting>
mpc load soundcloud://track/TRACK_ID
mpc load soundcloud://playlist/PLAYLIST_ID
mpc load soundcloud://user/USERNAME
mpc load soundcloud://search/SEARCH_QUERY
mpc load soundcloud://url/https://soundcloud.com/ARTIST/TRACK-NAME
</programlisting>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>apikey</varname>
<parameter>client_id</parameter>
</entry>
<entry>
User apikey/client_id can override the
<application>MPD</application> token provided by
SoundCloud.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section>
</chapter>
</book>

@@ -62,36 +62,7 @@ int main() {
CPPFLAGS=$oldcppflags
fi
if test x$enable_aac = xyes; then
oldcflags=$CFLAGS
oldlibs=$LIBS
oldcppflags=$CPPFLAGS
CFLAGS="$CFLAGS $FAAD_CFLAGS -Werror"
LIBS="$LIBS $FAAD_LIBS"
CPPFLAGS=$CFLAGS
AC_MSG_CHECKING(for broken libfaad headers)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <faad.h>
#include <stddef.h>
#include <stdint.h>
int main() {
unsigned char channels;
uint32_t sample_rate;
NeAACDecInit2(NULL, NULL, 0, &sample_rate, &channels);
return 0;
}
])],
[AC_MSG_RESULT(correct)],
[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
else
if test x$enable_aac = xno; then
FAAD_LIBS=""
FAAD_CFLAGS=""
fi

9
m4/mpd_depends.m4 Normal file

@@ -0,0 +1,9 @@
AC_DEFUN([MPD_DEPENDS], [
if test x$$2 = xno; then
if test x$$1 = xauto; then
$1=no
elif test x$$1 = xyes; then
AC_MSG_ERROR([$3])
fi
fi
])

@@ -20,33 +20,45 @@
#ifndef COMPILER_H
#define COMPILER_H
#define GCC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && \
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
#define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0
#endif
#define GCC_CHECK_VERSION(major, minor) \
(defined(__GNUC__) && GCC_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
/**
* Are we building with gcc (not clang or any other compiler) and a
* version older than the specified one?
*/
#define GCC_OLDER_THAN(major, minor) \
(defined(__GNUC__) && !defined(__clang__) && \
GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0))
#ifdef __clang__
# define CLANG_VERSION (__clang_major__ * 10000 \
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)
# define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __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)
# if GCC_OLDER_THAN(4,7)
# 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
/**
* Are we building with the specified version of clang or newer?
*/
#define CLANG_CHECK_VERSION(major, minor) \
(defined(__clang__) && \
CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
#if GCC_CHECK_VERSION(4,0)
/* GCC 4.x */
@@ -141,7 +153,7 @@
#if defined(__cplusplus)
/* support for C++11 "override" was added in gcc 4.7 */
#if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
#if GCC_OLDER_THAN(4,7)
#define override
#define final
#endif

@@ -188,6 +188,14 @@ public:
tag = std::move(other.tag);
}
/**
* Similar to the MoveTagFrom(), but move only the #TagItem
* array.
*/
void MoveTagItemsFrom(DetachedSong &&other) {
tag.MoveItemsFrom(std::move(other.tag));
}
time_t GetLastModified() const {
return mtime;
}

@@ -76,7 +76,10 @@ idle_get_names(void)
unsigned
idle_parse_name(const char *name)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(name != nullptr);
#endif
for (unsigned i = 0; idle_names[i] != nullptr; ++i)
if (StringEqualsCaseASCII(name, idle_names[i]))

@@ -194,6 +194,12 @@ FileLog(const Domain &domain, const char *message)
domain.GetName(),
chomp_length(message), message);
#ifdef WIN32
/* force-flush the log file, because setvbuf() does not seem
to have an effect on WIN32 */
fflush(stderr);
#endif
#ifdef HAVE_GLIB
g_free(converted);
#endif

@@ -111,6 +111,9 @@ log_early_init(bool verbose)
#ifdef ANDROID
(void)verbose;
#else
/* force stderr to be line-buffered */
setvbuf(stderr, nullptr, _IOLBF, 0);
if (verbose)
SetLogThreshold(LogLevel::DEBUG);
#endif

@@ -54,7 +54,6 @@
#include "system/FatalError.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "thread/Id.hxx"
#include "thread/Slack.hxx"
#include "lib/icu/Init.hxx"
@@ -114,13 +113,15 @@
#include <ws2tcpip.h>
#endif
#ifdef __BLOCKS__
#include <dispatch/dispatch.h>
#endif
#include <limits.h>
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
static constexpr Domain main_domain("main");
#ifdef ANDROID
Context *context;
#endif
@@ -401,8 +402,6 @@ int main(int argc, char *argv[])
{
#ifdef WIN32
return win32_main(argc, argv);
#elif __APPLE__
return osx_main(argc, argv);
#else
return mpd_main(argc, argv);
#endif
@@ -410,6 +409,8 @@ int main(int argc, char *argv[])
#endif
static int mpd_main_after_fork(struct options);
#ifdef ANDROID
static inline
#endif
@@ -513,6 +514,27 @@ int mpd_main(int argc, char *argv[])
daemonize_begin(options.daemon);
#endif
#ifdef __BLOCKS__
/* Runs the OS X native event loop in the main thread, and runs
the rest of mpd_main on a new thread. This lets CoreAudio receive
route change notifications (e.g. plugging or unplugging headphones).
All hardware output on OS X ultimately uses CoreAudio internally.
This must be run after forking; if dispatch is called before forking,
the child process will have a broken internal dispatch state. */
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
exit(mpd_main_after_fork(options));
});
dispatch_main();
return EXIT_FAILURE; // unreachable, because dispatch_main never returns
#else
return mpd_main_after_fork(options);
#endif
}
static int mpd_main_after_fork(struct options options)
{
Error error;
GlobalEvents::Initialize(*instance->event_loop);
GlobalEvents::Register(GlobalEvents::IDLE, idle_event_emitted);
#ifdef WIN32
@@ -608,7 +630,7 @@ int mpd_main(int argc, char *argv[])
config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
INT_MAX));
#else
FormatWarning(main_domain,
FormatWarning(config_domain,
"inotify: auto_update was disabled. enable during compilation phase");
#endif
}

@@ -75,15 +75,4 @@ win32_app_stopping(void);
#endif
#ifdef __APPLE__
/* Runs the OS X native event loop in the main thread, and runs
* mpd_main on a new thread. This lets CoreAudio receive route
* change notifications (e.g. plugging or unplugging headphones).
* All hardware output on OS X ultimately uses CoreAudio internally.
*/
int osx_main(int argc, char *argv[]);
#endif
#endif

@@ -25,6 +25,7 @@
#include "MusicPipe.hxx"
#include "MusicBuffer.hxx"
#include "MusicChunk.hxx"
#include "pcm/Silence.hxx"
#include "DetachedSong.hxx"
#include "system/FatalError.hxx"
#include "CrossFade.hxx"
@@ -486,8 +487,12 @@ Player::SendSilence()
MusicChunk *chunk = buffer.Allocate();
if (chunk == nullptr) {
LogError(player_domain, "Failed to allocate silence buffer");
return false;
/* this is non-fatal, because this means that the
decoder has filled to buffer completely meanwhile;
by ignoring the error, we work around this race
condition */
LogDebug(player_domain, "Failed to allocate silence buffer");
return true;
}
#ifndef NDEBUG
@@ -501,7 +506,7 @@ Player::SendSilence()
chunk->time = SignedSongTime::Negative(); /* undefined time stamp */
chunk->length = num_frames * frame_size;
memset(chunk->data, 0, chunk->length);
PcmSilence({chunk->data, chunk->length}, play_audio_format.format);
Error error;
if (!pc.outputs.Play(chunk, error)) {
@@ -518,6 +523,8 @@ Player::SeekDecoder()
{
assert(pc.next_song != nullptr);
pc.outputs.Cancel();
const SongTime start_time = pc.next_song->GetStartTime();
if (!dc.LockIsCurrentSong(*pc.next_song)) {
@@ -583,8 +590,6 @@ Player::SeekDecoder()
/* re-fill the buffer after seeking */
buffering = true;
pc.outputs.Cancel();
return true;
}
@@ -612,6 +617,12 @@ Player::ProcessCommand()
queued = true;
pc.CommandFinished();
pc.Unlock();
if (dc.LockIsIdle())
StartDecoder(*new MusicPipe());
pc.Lock();
break;
case PlayerCommand::PAUSE:

@@ -64,6 +64,10 @@ spl_global_init(void)
bool
spl_valid_name(const char *name_utf8)
{
if (*name_utf8 == 0)
/* empty name not allowed */
return false;
/*
* Not supporting '/' was done out of laziness, and we should
* really strive to support it in the future.

@@ -77,7 +77,10 @@ SongFilter::Item::Item(unsigned _tag, time_t _time)
bool
SongFilter::Item::StringMatch(const char *s) const
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(s != nullptr);
#endif
if (fold_case) {
const std::string folded = IcuCaseFold(s);

@@ -77,7 +77,10 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const
DetachedSong *
SongLoader::LoadSong(const char *uri_utf8, Error &error) const
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(uri_utf8 != nullptr);
#endif
if (memcmp(uri_utf8, "file:///", 8) == 0)
/* absolute path */

@@ -46,7 +46,8 @@ tag_stream_scan(InputStream &is, const tag_handler &handler, void *ctx)
{
assert(is.IsReady());
const char *const suffix = uri_get_suffix(is.GetURI());
UriSuffixBuffer suffix_buffer;
const char *const suffix = uri_get_suffix(is.GetURI(), suffix_buffer);
const char *const mime = is.GetMimeType();
if (suffix == nullptr && mime == nullptr)

@@ -53,7 +53,7 @@ public:
Bzip2ArchiveFile(Path path, InputStream *_is)
:ArchiveFile(bz2_archive_plugin),
name(PathTraitsFS::GetBase(path.c_str())),
name(path.GetBase().c_str()),
istream(_is) {
// remove .bz2 suffix
const size_t len = name.length();

@@ -66,7 +66,11 @@ public:
return iso9660_iso_seek_read(iso, ptr, start, i_size);
}
void Visit(const char *path, ArchiveVisitor &visitor);
/**
* @param capacity the path buffer size
*/
void Visit(char *path, size_t length, size_t capacity,
ArchiveVisitor &visitor);
virtual void Close() override {
Unref();
@@ -84,32 +88,36 @@ static constexpr Domain iso9660_domain("iso9660");
/* archive open && listing routine */
inline void
Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
ArchiveVisitor &visitor)
{
CdioList_t *entlist;
CdioListNode_t *entnode;
iso9660_stat_t *statbuf;
char pathname[4096];
entlist = iso9660_ifs_readdir (iso, psz_path);
auto *entlist = iso9660_ifs_readdir(iso, path);
if (!entlist) {
return;
}
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
CdioListNode_t *entnode;
_CDIO_LIST_FOREACH (entnode, entlist) {
statbuf = (iso9660_stat_t *) _cdio_list_node_data (entnode);
auto *statbuf = (iso9660_stat_t *)
_cdio_list_node_data(entnode);
const char *filename = statbuf->filename;
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0)
continue;
strcpy(pathname, psz_path);
strcat(pathname, statbuf->filename);
size_t filename_length = strlen(filename);
if (length + filename_length + 1 >= capacity)
/* file name is too long */
continue;
memcpy(path + length, filename, filename_length + 1);
size_t new_length = length + filename_length;
if (iso9660_stat_s::_STAT_DIR == statbuf->type ) {
if (strcmp(statbuf->filename, ".") && strcmp(statbuf->filename, "..")) {
strcat(pathname, "/");
Visit(pathname, visitor);
}
memcpy(path + new_length, "/", 2);
Visit(path, new_length + 1, capacity, visitor);
} else {
//remove leading /
visitor.VisitArchiveEntry(pathname + 1);
visitor.VisitArchiveEntry(path + 1);
}
}
_cdio_list_free (entlist, true);
@@ -133,7 +141,8 @@ iso9660_archive_open(Path pathname, Error &error)
void
Iso9660ArchiveFile::Visit(ArchiveVisitor &visitor)
{
Visit("/", visitor);
char path[4096] = "/";
Visit(path, 1, sizeof(path), visitor);
}
/* single archive handling */

@@ -168,12 +168,13 @@ bool
ZzipInputStream::Seek(offset_type new_offset, Error &error)
{
zzip_off_t ofs = zzip_seek(file, new_offset, SEEK_SET);
if (ofs != -1) {
if (ofs < 0) {
error.Set(zzip_domain, "zzip_seek() has failed");
offset = ofs;
return true;
return false;
}
return false;
offset = ofs;
return true;
}
/* exported structures */

@@ -127,7 +127,7 @@ public:
* a local (UNIX domain) socket?
*/
bool IsLocal() const {
return uid > 0;
return uid >= 0;
}
unsigned GetPermission() const {

@@ -41,7 +41,7 @@ Client::AllowFile(Path path_fs, Error &error) const
instance */
return true;
if (uid <= 0) {
if (uid < 0) {
/* unauthenticated client */
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
return false;

@@ -41,7 +41,7 @@ client_process_command_list(Client &client, bool list_ok,
FormatDebug(client_domain, "process command \"%s\"", cmd);
ret = command_process(client, num++, cmd);
FormatDebug(client_domain, "command returned %i", ret);
FormatDebug(client_domain, "command returned %i", int(ret));
if (ret != CommandResult::OK || client.IsExpired())
break;
else if (list_ok)
@@ -90,7 +90,7 @@ client_process_line(Client &client, char *line)
std::move(cmd_list));
FormatDebug(client_domain,
"[%u] process command "
"list returned %i", client.num, ret);
"list returned %i", client.num, int(ret));
if (ret == CommandResult::CLOSE ||
client.IsExpired())
@@ -126,7 +126,7 @@ client_process_line(Client &client, char *line)
ret = command_process(client, 0, line);
FormatDebug(client_domain,
"[%u] command returned %i",
client.num, ret);
client.num, int(ret));
if (ret == CommandResult::CLOSE ||
client.IsExpired())

@@ -52,8 +52,8 @@ Client::OnSocketInput(void *data, size_t length)
break;
case CommandResult::KILL:
Close();
partition.instance.event_loop->Break();
Close();
return InputResult::CLOSED;
case CommandResult::FINISH:

@@ -61,7 +61,16 @@ translate_uri(Client &client, const char *uri)
CommandResult
handle_add(Client &client, gcc_unused unsigned argc, char *argv[])
{
const char *const uri = translate_uri(client, argv[1]);
const char *uri = argv[1];
if (memcmp(uri, "/", 2) == 0)
/* this URI is malformed, but some clients are buggy
and use "add /" to add the whole database, which
was never intended to work, but once did; in order
to retain backwards compatibility, work around this
here */
uri = "";
uri = translate_uri(client, uri);
if (uri == nullptr)
return CommandResult::ERROR;

@@ -23,7 +23,7 @@
#include "Interface.hxx"
#include "client/Client.hxx"
#include "LightSong.hxx"
#include "tag/Set.hxx"
#include "tag/Tag.hxx"
#include <functional>
#include <map>

@@ -43,7 +43,7 @@ public:
virtual const LightSong *GetSong(const char *uri_utf8,
Error &error) const override;
virtual void ReturnSong(const LightSong *song) const;
void ReturnSong(const LightSong *song) const override;
virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,

@@ -103,7 +103,7 @@ public:
virtual void Close() override;
virtual const LightSong *GetSong(const char *uri_utf8,
Error &error) const override;
virtual void ReturnSong(const LightSong *song) const;
void ReturnSong(const LightSong *song) const override;
virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,
@@ -731,7 +731,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
{
// TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr;
return false;
if (!visit_directory && !visit_playlist && selection.recursive &&
(ServerSupportsSearchBase(connection)
@@ -757,7 +757,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
{
// TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr;
return false;
enum mpd_tag_type tag_type2 = Convert(tag_type);
if (tag_type2 == MPD_TAG_COUNT) {
@@ -810,7 +810,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
// TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr;
return false;
struct mpd_stats *stats2 =
mpd_run_stats(connection);

@@ -435,9 +435,12 @@ SimpleDatabase::Save(Error &error)
bool
SimpleDatabase::Mount(const char *uri, Database *db, Error &error)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(uri != nullptr);
assert(*uri != 0);
assert(db != nullptr);
#endif
assert(*uri != 0);
ScopeDatabaseLock protect;
@@ -445,13 +448,13 @@ SimpleDatabase::Mount(const char *uri, Database *db, Error &error)
if (r.uri == nullptr) {
error.Format(db_domain, DB_CONFLICT,
"Already exists: %s", uri);
return nullptr;
return false;
}
if (strchr(r.uri, '/') != nullptr) {
error.Format(db_domain, DB_NOT_FOUND,
"Parent not found: %s", uri);
return nullptr;
return false;
}
Directory *mnt = r.directory->CreateChild(r.uri);
@@ -478,7 +481,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
if (cache_path.IsNull()) {
error.Format(db_domain, DB_NOT_FOUND,
"No 'cache_directory' configured");
return nullptr;
return false;
}
std::string name(storage_uri);

@@ -110,9 +110,9 @@ public:
virtual bool Open(Error &error) override;
virtual void Close() override;
virtual const LightSong *GetSong(const char *uri_utf8,
Error &error) const override;
virtual void ReturnSong(const LightSong *song) const;
const LightSong *GetSong(const char *uri_utf8,
Error &error) const override;
void ReturnSong(const LightSong *song) const override;
virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,

@@ -129,6 +129,7 @@ public:
state(NONE),
tag_type(TAG_NUM_OF_ITEM_TYPES)
{
m_tobj.clear();
}
protected:

@@ -85,7 +85,7 @@ public:
virtual void Close() override;
virtual const LightSong *GetSong(const char *uri_utf8,
Error &error) const override;
virtual void ReturnSong(const LightSong *song) const;
void ReturnSong(const LightSong *song) const override;
virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory,
@@ -101,7 +101,9 @@ public:
virtual bool GetStats(const DatabaseSelection &selection,
DatabaseStats &stats,
Error &error) const override;
virtual time_t GetUpdateStamp() const {return 0;}
time_t GetUpdateStamp() const override {
return 0;
}
protected:
bool Configure(const config_param &param, Error &error);

@@ -34,7 +34,9 @@
#include <string.h>
#include <errno.h>
#ifdef HAVE_GLIB
static constexpr Domain exclude_list_domain("exclude_list");
#endif
bool
ExcludeList::LoadFile(Path path_fs)

@@ -334,7 +334,7 @@ UpdateWalk::UpdateDirectory(Directory &directory, const FileInfo &info)
directory_set_stat(directory, info);
Error error;
const std::auto_ptr<StorageDirectoryReader> reader(storage.OpenDirectory(directory.GetPath(), error));
const std::unique_ptr<StorageDirectoryReader> reader(storage.OpenDirectory(directory.GetPath(), error));
if (reader.get() == nullptr) {
LogError(error);
return false;

@@ -301,7 +301,8 @@ decoder_check_cancel_read(const Decoder *decoder)
/* ignore the SEEK command during initialization, the plugin
should handle that after it has initialized successfully */
if (dc.command == DecoderCommand::SEEK &&
(dc.state == DecoderState::START || decoder->seeking))
(dc.state == DecoderState::START || decoder->seeking ||
decoder->initial_seek_running))
return false;
return true;
@@ -433,8 +434,11 @@ update_stream_tag(Decoder &decoder, InputStream *is)
/* no stream tag present - submit the song tag
instead */
decoder.song_tag = nullptr;
}
} else
/* discard the song tag; we don't need it */
delete decoder.song_tag;
decoder.song_tag = nullptr;
delete decoder.stream_tag;
decoder.stream_tag = tag;
@@ -566,7 +570,7 @@ decoder_tag(Decoder &decoder, InputStream *is,
/* save the tag */
delete decoder.decoder_tag;
decoder.decoder_tag = new Tag(tag);
decoder.decoder_tag = new Tag(std::move(tag));
/* check for a new stream tag */

@@ -25,6 +25,7 @@
#include "util/ConstBuffer.hxx"
#include <stddef.h>
#include <stdint.h>
struct Decoder;
class InputStream;

@@ -37,7 +37,6 @@
#include "plugins/MadDecoderPlugin.hxx"
#include "plugins/SndfileDecoderPlugin.hxx"
#include "plugins/Mpg123DecoderPlugin.hxx"
#include "plugins/Mp4v2DecoderPlugin.hxx"
#include "plugins/WildmidiDecoderPlugin.hxx"
#include "plugins/MikmodDecoderPlugin.hxx"
#include "plugins/ModplugDecoderPlugin.hxx"
@@ -55,9 +54,6 @@ const struct DecoderPlugin *const decoder_plugins[] = {
#ifdef HAVE_MPG123
&mpg123_decoder_plugin,
#endif
#ifdef HAVE_MP4V2
&mp4v2_decoder_plugin,
#endif
#ifdef ENABLE_VORBIS_DECODER
&vorbis_decoder_plugin,
#endif

@@ -26,7 +26,10 @@
bool
DecoderPlugin::SupportsSuffix(const char *suffix) const
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(suffix != nullptr);
#endif
return suffixes != nullptr && string_array_contains(suffixes, suffix);
@@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
bool
DecoderPlugin::SupportsMimeType(const char *mime_type) const
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(mime_type != nullptr);
#endif
return mime_types != nullptr &&
string_array_contains(mime_types, mime_type);

@@ -98,6 +98,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri)
if (!is->Check(error)) {
dc.Unlock();
delete is;
LogError(error);
return nullptr;
@@ -237,7 +238,8 @@ static bool
decoder_run_stream_locked(Decoder &decoder, InputStream &is,
const char *uri, bool &tried_r)
{
const char *const suffix = uri_get_suffix(uri);
UriSuffixBuffer suffix_buffer;
const char *const suffix = uri_get_suffix(uri, suffix_buffer);
using namespace std::placeholders;
const auto f = std::bind(decoder_run_stream_plugin,
@@ -254,7 +256,11 @@ decoder_run_stream_fallback(Decoder &decoder, InputStream &is)
{
const struct DecoderPlugin *plugin;
#ifdef HAVE_FFMPEG
plugin = decoder_plugin_from_name("ffmpeg");
#else
plugin = decoder_plugin_from_name("mad");
#endif
return plugin != nullptr && plugin->stream_decode != nullptr &&
decoder_stream_decode(*plugin, decoder, is);
}
@@ -379,7 +385,11 @@ decoder_run_song(DecoderControl &dc,
const DetachedSong &song, const char *uri, Path path_fs)
{
Decoder decoder(dc, dc.start_time.IsPositive(),
new Tag(song.GetTag()));
/* pass the song tag only if it's
authoritative, i.e. if it's a local file -
tags on "stream" songs are just remembered
from the last time we played it*/
song.IsFile() ? new Tag(song.GetTag()) : nullptr);
int ret;
dc.state = DecoderState::START;

@@ -209,7 +209,7 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
const auto total_time = audiofile_get_duration(fh);
const uint16_t kbit_rate = (uint16_t)
(is.GetSize() * uint64_t(8000) / total_time.ToMS());
(is.GetSize() * uint64_t(8) / total_time.ToMS());
const unsigned frame_size = (unsigned)
afGetVirtualFrameSize(fh, AF_DEFAULT_TRACK, true);

@@ -29,8 +29,10 @@
#include "input/InputStream.hxx"
#include "tag/TagId3.hxx"
#include "util/Error.hxx"
#include "util/Alloc.hxx"
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_ID3TAG
#include <id3tag.h>
@@ -53,7 +55,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
offset_type offset)
{
if (is.IsSeekable())
return is.Seek(offset, IgnoreError());
return is.LockSeek(offset, IgnoreError());
if (is.GetOffset() > offset)
return false;
@@ -72,7 +74,7 @@ dsdlib_skip(Decoder *decoder, InputStream &is,
return true;
if (is.IsSeekable())
return is.Seek(is.GetOffset() + delta, IgnoreError());
return is.LockSeek(is.GetOffset() + delta, IgnoreError());
if (delta > 1024 * 1024)
/* don't skip more than one megabyte; it would be too
@@ -123,22 +125,26 @@ dsdlib_tag_id3(InputStream &is,
const id3_length_t count = size - offset;
/* Check and limit id3 tag size to prevent a stack overflow */
id3_byte_t dsdid3[4096];
if (count == 0 || count > sizeof(dsdid3))
if (count < 10 || count > 1024 * 1024)
return;
if (!decoder_read_full(nullptr, is, dsdid3, count))
id3_byte_t *const id3_buf = new id3_byte_t[count];
if (id3_buf == nullptr)
return;
struct id3_tag *id3_tag = id3_tag_parse(dsdid3, count);
if (!decoder_read_full(nullptr, is, id3_buf, count)) {
delete[] id3_buf;
return;
}
struct id3_tag *id3_tag = id3_tag_parse(id3_buf, count);
delete[] id3_buf;
if (id3_tag == nullptr)
return;
scan_id3_tag(id3_tag, handler, handler_ctx);
id3_tag_delete(id3_tag);
return;
}
#endif

@@ -205,7 +205,7 @@ dsdiff_handle_native_tag(InputStream &is,
if (length == 0 || length > 60)
return;
char string[length];
char string[length + 1];
char *label;
label = string;

@@ -255,20 +255,12 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
}
uint8_t channels;
uint32_t sample_rate;
#ifdef HAVE_FAAD_LONG
/* neaacdec.h declares all arguments as "unsigned long", but
internally expects uint32_t pointers. To avoid gcc
warnings, use this workaround. */
unsigned long *sample_rate_p = (unsigned long *)(void *)&sample_rate;
#else
uint32_t *sample_rate_p = &sample_rate;
#endif
unsigned long sample_rate;
long nbytes = NeAACDecInit(decoder,
/* deconst hack, libfaad requires this */
const_cast<unsigned char *>(data.data),
data.size,
sample_rate_p, &channels);
&sample_rate, &channels);
if (nbytes < 0) {
error.Set(faad_decoder_domain, "Not an AAC stream");
return false;

File diff suppressed because it is too large Load Diff

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2003-2016 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.
*/
/* necessary because libavutil/common.h uses UINT64_C */
#define __STDC_CONSTANT_MACROS
#include "config.h"
#include "FfmpegIo.hxx"
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "util/Error.hxx"
AvioStream::~AvioStream()
{
if (io != nullptr) {
av_free(io->buffer);
av_free(io);
}
}
static int
mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
{
AvioStream *stream = (AvioStream *)opaque;
return decoder_read(stream->decoder, stream->input,
(void *)buf, size);
}
static int64_t
mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
{
AvioStream *stream = (AvioStream *)opaque;
switch (whence) {
case SEEK_SET:
break;
case SEEK_CUR:
pos += stream->input.GetOffset();
break;
case SEEK_END:
if (!stream->input.KnownSize())
return -1;
pos += stream->input.GetSize();
break;
case AVSEEK_SIZE:
if (!stream->input.KnownSize())
return -1;
return stream->input.GetSize();
default:
return -1;
}
if (!stream->input.LockSeek(pos, IgnoreError()))
return -1;
return stream->input.GetOffset();
}
bool
AvioStream::Open()
{
constexpr size_t BUFFER_SIZE = 8192;
auto buffer = (unsigned char *)av_malloc(BUFFER_SIZE);
if (buffer == nullptr)
return false;
io = avio_alloc_context(buffer, BUFFER_SIZE,
false, this,
mpd_ffmpeg_stream_read, nullptr,
input.IsSeekable()
? mpd_ffmpeg_stream_seek : nullptr);
/* If avio_alloc_context() fails, who frees the buffer? The
libavformat API documentation does not specify this, it
only says that AVIOContext.buffer must be freed in the end,
however no AVIOContext exists in that failure code path. */
return io != nullptr;
}

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2003-2016 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_FFMPEG_IO_HXX
#define MPD_FFMPEG_IO_HXX
#include "check.h"
extern "C" {
#include "libavformat/avio.h"
}
#include <stdint.h>
class InputStream;
struct Decoder;
struct AvioStream {
Decoder *const decoder;
InputStream &input;
AVIOContext *io;
AvioStream(Decoder *_decoder, InputStream &_input)
:decoder(_decoder), input(_input), io(nullptr) {}
~AvioStream();
bool Open();
};
#endif

@@ -36,9 +36,9 @@ static const struct tag_table ffmpeg_tags[] = {
};
static void
ffmpeg_copy_metadata(TagType type,
AVDictionary *m, const char *name,
const struct tag_handler *handler, void *handler_ctx)
FfmpegScanTag(TagType type,
AVDictionary *m, const char *name,
const struct tag_handler *handler, void *handler_ctx)
{
AVDictionaryEntry *mt = nullptr;
@@ -48,8 +48,8 @@ ffmpeg_copy_metadata(TagType type,
}
static void
ffmpeg_scan_pairs(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
FfmpegScanPairs(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
{
AVDictionaryEntry *i = nullptr;
@@ -59,18 +59,20 @@ ffmpeg_scan_pairs(AVDictionary *dict,
}
void
ffmpeg_scan_dictionary(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
FfmpegScanDictionary(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
{
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
ffmpeg_copy_metadata(TagType(i), dict, tag_item_names[i],
handler, handler_ctx);
if (handler->tag != nullptr) {
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
FfmpegScanTag(TagType(i), dict, tag_item_names[i],
handler, handler_ctx);
for (const struct tag_table *i = ffmpeg_tags;
i->name != nullptr; ++i)
ffmpeg_copy_metadata(i->type, dict, i->name,
handler, handler_ctx);
for (const struct tag_table *i = ffmpeg_tags;
i->name != nullptr; ++i)
FfmpegScanTag(i->type, dict, i->name,
handler, handler_ctx);
}
if (handler->pair != nullptr)
ffmpeg_scan_pairs(dict, handler, handler_ctx);
FfmpegScanPairs(dict, handler, handler_ctx);
}

@@ -32,7 +32,7 @@ extern "C" {
struct tag_handler;
void
ffmpeg_scan_dictionary(AVDictionary *dict,
const tag_handler *handler, void *handler_ctx);
FfmpegScanDictionary(AVDictionary *dict,
const tag_handler *handler, void *handler_ctx);
#endif

@@ -33,7 +33,7 @@ flac_data::flac_data(Decoder &_decoder,
InputStream &_input_stream)
:FlacInput(_input_stream, &_decoder),
initialized(false), unsupported(false),
total_frames(0), first_frame(0), next_frame(0), position(0),
position(0),
decoder(_decoder), input_stream(_input_stream)
{
}
@@ -59,6 +59,38 @@ flac_sample_format(unsigned bits_per_sample)
}
}
bool
flac_data::Initialize(unsigned sample_rate, unsigned bits_per_sample,
unsigned channels, FLAC__uint64 total_frames)
{
assert(!initialized);
assert(!unsupported);
::Error error;
if (!audio_format_init_checked(audio_format,
sample_rate,
flac_sample_format(bits_per_sample),
channels, error)) {
LogError(error);
unsupported = true;
return false;
}
frame_size = audio_format.GetFrameSize();
const auto duration = total_frames > 0
? SignedSongTime::FromScale<uint64_t>(total_frames,
audio_format.sample_rate)
: SignedSongTime::Negative();
decoder_initialized(decoder, audio_format,
input_stream.IsSeekable(),
duration);
initialized = true;
return true;
}
static void
flac_got_stream_info(struct flac_data *data,
const FLAC__StreamMetadata_StreamInfo *stream_info)
@@ -66,22 +98,10 @@ flac_got_stream_info(struct flac_data *data,
if (data->initialized || data->unsupported)
return;
Error error;
if (!audio_format_init_checked(data->audio_format,
stream_info->sample_rate,
flac_sample_format(stream_info->bits_per_sample),
stream_info->channels, error)) {
LogError(error);
data->unsupported = true;
return;
}
data->frame_size = data->audio_format.GetFrameSize();
if (data->total_frames == 0)
data->total_frames = stream_info->total_samples;
data->initialized = true;
data->Initialize(stream_info->sample_rate,
stream_info->bits_per_sample,
stream_info->channels,
stream_info->total_samples);
}
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
@@ -125,28 +145,11 @@ flac_got_first_frame(struct flac_data *data, const FLAC__FrameHeader *header)
if (data->unsupported)
return false;
Error error;
if (!audio_format_init_checked(data->audio_format,
header->sample_rate,
flac_sample_format(header->bits_per_sample),
header->channels, error)) {
LogError(error);
data->unsupported = true;
return false;
}
data->frame_size = data->audio_format.GetFrameSize();
const auto duration = SongTime::FromScale<uint64_t>(data->total_frames,
data->audio_format.sample_rate);
decoder_initialized(data->decoder, data->audio_format,
data->input_stream.IsSeekable(),
duration);
data->initialized = true;
return true;
return data->Initialize(header->sample_rate,
header->bits_per_sample,
header->channels,
/* unknown duration */
0);
}
FLAC__StreamDecoderWriteStatus
@@ -155,7 +158,6 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
FLAC__uint64 nbytes)
{
void *buffer;
unsigned bit_rate;
if (!data->initialized && !flac_got_first_frame(data, &frame->header))
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
@@ -167,16 +169,12 @@ flac_common_write(struct flac_data *data, const FLAC__Frame * frame,
data->audio_format.format, buf,
0, frame->header.blocksize);
if (nbytes > 0)
bit_rate = nbytes * 8 * frame->header.sample_rate /
(1000 * frame->header.blocksize);
else
bit_rate = 0;
unsigned bit_rate = nbytes * 8 * frame->header.sample_rate /
(1000 * frame->header.blocksize);
auto cmd = decoder_data(data->decoder, data->input_stream,
buffer, buffer_size,
bit_rate);
data->next_frame += frame->header.blocksize;
switch (cmd) {
case DecoderCommand::NONE:
case DecoderCommand::START:

@@ -55,23 +55,9 @@ struct flac_data : public FlacInput {
AudioFormat audio_format;
/**
* The total number of frames in this song. The decoder
* plugin may initialize this attribute to override the value
* provided by libFLAC (e.g. for sub songs from a CUE sheet).
* End of last frame's position within the stream. This is
* used for bit rate calculations.
*/
FLAC__uint64 total_frames;
/**
* The number of the first frame in this song. This is only
* non-zero if playing sub songs from a CUE sheet.
*/
FLAC__uint64 first_frame;
/**
* The number of the next frame which is going to be decoded.
*/
FLAC__uint64 next_frame;
FLAC__uint64 position;
Decoder &decoder;
@@ -80,6 +66,12 @@ struct flac_data : public FlacInput {
Tag tag;
flac_data(Decoder &decoder, InputStream &input_stream);
/**
* Wrapper for decoder_initialized().
*/
bool Initialize(unsigned sample_rate, unsigned bits_per_sample,
unsigned channels, FLAC__uint64 total_frames);
};
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,

@@ -132,26 +132,16 @@ flac_decoder_new(void)
}
static bool
flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd,
FLAC__uint64 duration)
flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd)
{
data->total_frames = duration;
if (!FLAC__stream_decoder_process_until_end_of_metadata(sd)) {
LogWarning(flac_domain, "problem reading metadata");
if (FLAC__stream_decoder_get_state(sd) != FLAC__STREAM_DECODER_END_OF_STREAM)
LogWarning(flac_domain, "problem reading metadata");
return false;
}
if (data->initialized) {
/* done */
const auto duration2 =
SongTime::FromScale<uint64_t>(data->total_frames,
data->audio_format.sample_rate);
decoder_initialized(data->decoder, data->audio_format,
data->input_stream.IsSeekable(),
duration2);
return true;
}
@@ -167,13 +157,10 @@ flac_decoder_initialize(struct flac_data *data, FLAC__StreamDecoder *sd,
}
static void
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
FLAC__uint64 t_start, FLAC__uint64 t_end)
flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec)
{
Decoder &decoder = data->decoder;
data->first_frame = t_start;
while (true) {
DecoderCommand cmd;
if (!data->tag.IsEmpty()) {
@@ -184,24 +171,49 @@ flac_decoder_loop(struct flac_data *data, FLAC__StreamDecoder *flac_dec,
cmd = decoder_get_command(decoder);
if (cmd == DecoderCommand::SEEK) {
FLAC__uint64 seek_sample = t_start +
FLAC__uint64 seek_sample =
decoder_seek_where_frame(decoder);
if (seek_sample >= t_start &&
(t_end == 0 || seek_sample <= t_end) &&
FLAC__stream_decoder_seek_absolute(flac_dec, seek_sample)) {
data->next_frame = seek_sample;
if (FLAC__stream_decoder_seek_absolute(flac_dec, seek_sample)) {
data->position = 0;
decoder_command_finished(decoder);
} else
decoder_seek_error(decoder);
} else if (cmd == DecoderCommand::STOP ||
FLAC__stream_decoder_get_state(flac_dec) == FLAC__STREAM_DECODER_END_OF_STREAM)
} else if (cmd == DecoderCommand::STOP)
break;
if (t_end != 0 && data->next_frame >= t_end)
/* end of this sub track */
switch (FLAC__stream_decoder_get_state(flac_dec)) {
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
case FLAC__STREAM_DECODER_READ_METADATA:
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
case FLAC__STREAM_DECODER_READ_FRAME:
/* continue decoding */
break;
case FLAC__STREAM_DECODER_END_OF_STREAM:
/* regular end of stream */
return;
case FLAC__STREAM_DECODER_SEEK_ERROR:
/* try to recover from seek error */
if (!FLAC__stream_decoder_flush(flac_dec)) {
LogError(flac_domain, "FLAC__stream_decoder_flush() failed");
return;
}
break;
case FLAC__STREAM_DECODER_OGG_ERROR:
case FLAC__STREAM_DECODER_ABORTED:
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
/* an error, fatal enough for us to abort the
decoder */
return;
case FLAC__STREAM_DECODER_UNINITIALIZED:
/* we shouldn't see this, ever - bail out */
return;
}
if (!FLAC__stream_decoder_process_single(flac_dec) &&
decoder_get_command(decoder) == DecoderCommand::NONE) {
/* a failure that was not triggered by a
@@ -250,6 +262,24 @@ stream_init(FLAC__StreamDecoder *flac_dec, struct flac_data *data, bool is_ogg)
: stream_init_flac(flac_dec, data);
}
static bool
FlacInitAndDecode(struct flac_data &data, FLAC__StreamDecoder *sd, bool is_ogg)
{
auto init_status = stream_init(sd, &data, is_ogg);
if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
LogWarning(flac_domain,
FLAC__StreamDecoderInitStatusString[init_status]);
return false;
}
bool result = flac_decoder_initialize(&data, sd);
if (result)
flac_decoder_loop(&data, sd);
FLAC__stream_decoder_finish(sd);
return result;
}
static void
flac_decode_internal(Decoder &decoder,
InputStream &input_stream,
@@ -263,24 +293,8 @@ flac_decode_internal(Decoder &decoder,
struct flac_data data(decoder, input_stream);
FLAC__StreamDecoderInitStatus status =
stream_init(flac_dec, &data, is_ogg);
if (status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
FLAC__stream_decoder_delete(flac_dec);
LogWarning(flac_domain,
FLAC__StreamDecoderInitStatusString[status]);
return;
}
FlacInitAndDecode(data, flac_dec, is_ogg);
if (!flac_decoder_initialize(&data, flac_dec, 0)) {
FLAC__stream_decoder_finish(flac_dec);
FLAC__stream_decoder_delete(flac_dec);
return;
}
flac_decoder_loop(&data, flac_dec, 0, 0);
FLAC__stream_decoder_finish(flac_dec);
FLAC__stream_decoder_delete(flac_dec);
}

@@ -20,6 +20,7 @@
#include "config.h"
#include "FlacIOHandle.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "Compiler.h"
#include <errno.h>
@@ -87,7 +88,13 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 _offset, int whence)
return -1;
}
return is->LockSeek(offset, IgnoreError()) ? 0 : -1;
Error error;
if (!is->LockSeek(offset, error)) {
LogError(error);
return -1;
}
return 0;
}
static FLAC__int64

@@ -156,8 +156,11 @@ gme_file_decode(Decoder &decoder, Path path_fs)
return;
}
const SignedSongTime song_len = ti->length > 0
? SignedSongTime::FromMS(ti->length)
const int length = ti->play_length;
gme_free_info(ti);
const SignedSongTime song_len = length > 0
? SignedSongTime::FromMS(length)
: SignedSongTime::Negative();
/* initialize the MPD decoder */
@@ -168,7 +171,6 @@ gme_file_decode(Decoder &decoder, Path path_fs)
SampleFormat::S16, GME_CHANNELS,
error)) {
LogError(error);
gme_free_info(ti);
gme_delete(emu);
return;
}
@@ -179,8 +181,8 @@ gme_file_decode(Decoder &decoder, Path path_fs)
if (gme_err != nullptr)
LogWarning(gme_domain, gme_err);
if (ti->length > 0)
gme_set_fade(emu, ti->length);
if (length > 0)
gme_set_fade(emu, length);
/* play */
DecoderCommand cmd;
@@ -196,16 +198,17 @@ gme_file_decode(Decoder &decoder, Path path_fs)
if (cmd == DecoderCommand::SEEK) {
unsigned where = decoder_seek_time(decoder).ToMS();
gme_err = gme_seek(emu, where);
if (gme_err != nullptr)
if (gme_err != nullptr) {
LogWarning(gme_domain, gme_err);
decoder_command_finished(decoder);
decoder_seek_error(decoder);
} else
decoder_command_finished(decoder);
}
if (gme_track_ended(emu))
break;
} while (cmd != DecoderCommand::STOP);
gme_free_info(ti);
gme_delete(emu);
}
@@ -236,9 +239,9 @@ gme_scan_file(Path path_fs,
assert(ti != nullptr);
if (ti->length > 0)
if (ti->play_length > 0)
tag_handler_invoke_duration(handler, handler_ctx,
SongTime::FromMS(ti->length));
SongTime::FromMS(ti->play_length));
if (ti->song != nullptr) {
if (gme_track_count(emu) > 1) {

@@ -657,7 +657,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
unsigned name = mad_bit_read(ptr, 3); /* gain name */
unsigned orig = mad_bit_read(ptr, 3); /* gain originator */
unsigned sign = mad_bit_read(ptr, 1); /* sign bit */
unsigned gain = mad_bit_read(ptr, 9); /* gain*10 */
int gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 1 && orig != 0) {
lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj;
FormatDebug(mad_domain, "LAME track gain found: %f",

@@ -1,338 +0,0 @@
/*
* Copyright (C) 2003-2014 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 "Mp4v2DecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "CheckAudioFormat.hxx"
#include "tag/TagHandler.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <mp4v2/mp4v2.h>
#include <neaacdec.h>
#include <cstdio>
#include <cstdlib>
static constexpr Domain mp4v2_decoder_domain("mp4v2");
static MP4TrackId
mp4_get_aac_track(MP4FileHandle handle, NeAACDecHandle decoder,
AudioFormat &audio_format, Error &error)
{
uint32_t sample_rate;
#ifdef HAVE_FAAD_LONG
/* neaacdec.h declares all arguments as "unsigned long", but
internally expects uint32_t pointers. To avoid gcc
warnings, use this workaround. */
unsigned long *sample_rate_r = (unsigned long*)&sample_rate;
#else
uint32_t *sample_rate_r = sample_rate;
#endif
const MP4TrackId tracks = MP4GetNumberOfTracks(handle);
for (MP4TrackId id = 1; id <= tracks; id++) {
const char* track_type = MP4GetTrackType(handle, id);
if (track_type == 0)
continue;
const auto obj_type = MP4GetTrackEsdsObjectTypeId(handle, id);
if (obj_type == MP4_INVALID_AUDIO_TYPE)
continue;
if (obj_type == MP4_MPEG4_AUDIO_TYPE) {
const auto mpeg_type = MP4GetTrackAudioMpeg4Type(handle, id);
if (!MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg_type))
continue;
} else if (!MP4_IS_AAC_AUDIO_TYPE(obj_type))
continue;
if (decoder == nullptr)
/* found audio track, no decoder */
return id;
unsigned char *buff = nullptr;
unsigned buff_size = 0;
if (!MP4GetTrackESConfiguration(handle, id, &buff, &buff_size))
continue;
uint8_t channels;
int32_t nbytes = NeAACDecInit(decoder, buff, buff_size,
sample_rate_r, &channels);
free(buff);
if (nbytes < 0)
/* invalid stream */
continue;
if (!audio_format_init_checked(audio_format, sample_rate,
SampleFormat::S16,
channels,
error))
continue;
return id;
}
error.Set(mp4v2_decoder_domain, "no valid aac track found");
return MP4_INVALID_TRACK_ID;
}
static NeAACDecHandle
mp4_faad_new(MP4FileHandle handle, AudioFormat &audio_format, Error &error)
{
const NeAACDecHandle decoder = NeAACDecOpen();
const NeAACDecConfigurationPtr config =
NeAACDecGetCurrentConfiguration(decoder);
config->outputFormat = FAAD_FMT_16BIT;
config->downMatrix = 1;
config->dontUpSampleImplicitSBR = 0;
NeAACDecSetConfiguration(decoder, config);
const auto track = mp4_get_aac_track(handle, decoder, audio_format, error);
if (track == MP4_INVALID_TRACK_ID) {
NeAACDecClose(decoder);
return nullptr;
}
return decoder;
}
static void
mp4_file_decode(Decoder &mpd_decoder, Path path_fs)
{
const MP4FileHandle handle = MP4Read(path_fs.c_str());
if (handle == MP4_INVALID_FILE_HANDLE) {
FormatError(mp4v2_decoder_domain,
"unable to open file");
return;
}
AudioFormat audio_format;
Error error;
const NeAACDecHandle decoder = mp4_faad_new(handle, audio_format, error);
if (decoder == nullptr) {
LogError(error);
MP4Close(handle);
return;
}
const MP4TrackId track = mp4_get_aac_track(handle, nullptr, audio_format, error);
/* initialize the MPD core */
const MP4Timestamp scale = MP4GetTrackTimeScale(handle, track);
const SongTime duration = SongTime::FromScale<uint64_t>(MP4GetTrackDuration(handle, track),
scale);
const MP4SampleId num_samples = MP4GetTrackNumberOfSamples(handle, track);
decoder_initialized(mpd_decoder, audio_format, true, duration);
/* the decoder loop */
DecoderCommand cmd = DecoderCommand::NONE;
for (MP4SampleId sample = 1;
sample < num_samples && cmd != DecoderCommand::STOP;
sample++) {
unsigned char *data = nullptr;
unsigned int data_length = 0;
if (cmd == DecoderCommand::SEEK) {
const MP4Timestamp offset =
decoder_seek_time(mpd_decoder).ToScale(scale);
sample = MP4GetSampleIdFromTime(handle, track, offset,
false);
decoder_command_finished(mpd_decoder);
}
/* read */
if (MP4ReadSample(handle, track, sample, &data, &data_length) == 0) {
FormatError(mp4v2_decoder_domain, "unable to read sample");
break;
}
/* decode it */
NeAACDecFrameInfo frame_info;
const void *const decoded = NeAACDecDecode(decoder, &frame_info, data, data_length);
if (frame_info.error > 0) {
FormatWarning(mp4v2_decoder_domain,
"error decoding AAC stream: %s",
NeAACDecGetErrorMessage(frame_info.error));
break;
}
if (frame_info.channels != audio_format.channels) {
FormatDefault(mp4v2_decoder_domain,
"channel count changed from %u to %u",
audio_format.channels, frame_info.channels);
break;
}
if (frame_info.samplerate != audio_format.sample_rate) {
FormatDefault(mp4v2_decoder_domain,
"sample rate changed from %u to %lu",
audio_format.sample_rate,
(unsigned long)frame_info.samplerate);
break;
}
/* update bit rate and position */
unsigned bit_rate = 0;
if (frame_info.samples > 0) {
bit_rate = frame_info.bytesconsumed * 8.0 *
frame_info.channels * audio_format.sample_rate /
frame_info.samples / 1000 + 0.5;
}
/* send PCM samples to MPD */
cmd = decoder_data(mpd_decoder, nullptr, decoded,
(size_t)frame_info.samples * 2,
bit_rate);
free(data);
}
/* cleanup */
NeAACDecClose(decoder);
MP4Close(handle);
}
static inline void
mp4_safe_invoke_tag(const struct tag_handler *handler, void *handler_ctx,
TagType tag, const char *value)
{
if (value != nullptr)
tag_handler_invoke_tag(handler, handler_ctx, tag, value);
}
static bool
mp4_scan_file(Path path_fs,
const struct tag_handler *handler, void *handler_ctx)
{
const MP4FileHandle handle = MP4Read(path_fs.c_str());
if (handle == MP4_INVALID_FILE_HANDLE)
return false;
AudioFormat tmp_audio_format;
Error error;
const MP4TrackId id = mp4_get_aac_track(handle, nullptr, tmp_audio_format, error);
if (id == MP4_INVALID_TRACK_ID) {
LogError(error);
MP4Close(handle);
return false;
}
const MP4Timestamp scale = MP4GetTrackTimeScale(handle, id);
const SongTime dur =
SongTime::FromScale<uint64_t>(MP4GetTrackDuration(handle, id),
scale);
tag_handler_invoke_duration(handler, handler_ctx, dur);
const MP4Tags* tags = MP4TagsAlloc();
MP4TagsFetch(tags, handle);
static constexpr struct {
const char *MP4Tags::*p;
TagType tag_type;
} mp4v2_tags[] = {
{ &MP4Tags::name, TAG_NAME },
{ &MP4Tags::artist, TAG_ARTIST },
{ &MP4Tags::albumArtist, TAG_ALBUM_ARTIST },
{ &MP4Tags::album, TAG_ALBUM },
{ &MP4Tags::composer, TAG_COMPOSER },
{ &MP4Tags::comments, TAG_COMMENT },
{ &MP4Tags::genre, TAG_GENRE },
{ &MP4Tags::releaseDate, TAG_DATE },
{ &MP4Tags::sortArtist, TAG_ARTIST_SORT },
{ &MP4Tags::sortAlbumArtist, TAG_ALBUM_ARTIST_SORT },
};
for (const auto &i : mp4v2_tags)
mp4_safe_invoke_tag(handler, handler_ctx,
i.tag_type, tags->*i.p);
char buff[8]; /* tmp buffer for index to string. */
if (tags->track != nullptr) {
sprintf(buff, "%d", tags->track->index);
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, buff);
}
if (tags->disk != nullptr) {
sprintf(buff, "%d", tags->disk->index);
tag_handler_invoke_tag(handler, handler_ctx, TAG_DISC, buff);
}
MP4TagsFree(tags);
MP4Close(handle);
return true;
}
static const char *const mp4_suffixes[] = {
"mp4",
"m4a",
/* "m4p", encrypted */
/* "m4b", audio book */
/* "m4r", ring tones */
/* "m4v", video */
nullptr
};
static const char *const mp4_mime_types[] = {
"application/mp4",
"application/m4a",
"audio/mp4",
"audio/m4a",
/* "audio/m4p", */
/* "audio/m4b", */
/* "audio/m4r", */
/* "audio/m4v", */
nullptr
};
const struct DecoderPlugin mp4v2_decoder_plugin = {
"mp4v2",
nullptr,
nullptr,
nullptr,
mp4_file_decode,
mp4_scan_file,
nullptr,
nullptr,
mp4_suffixes,
mp4_mime_types
};

@@ -22,10 +22,12 @@
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "pcm/Traits.hxx"
#include "tag/TagHandler.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/Macros.hxx"
#include "util/Clamp.hxx"
#include "Log.hxx"
#include <mpc/mpcdec.h>
@@ -42,6 +44,9 @@ struct mpc_decoder_data {
static constexpr Domain mpcdec_domain("mpcdec");
static constexpr SampleFormat mpcdec_sample_format = SampleFormat::S24_P32;
typedef SampleTraits<mpcdec_sample_format> MpcdecSampleTraits;
static mpc_int32_t
mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
{
@@ -91,18 +96,15 @@ mpc_getsize_cb(mpc_reader *reader)
}
/* this _looks_ performance-critical, don't de-inline -- eric */
static inline int32_t
static inline MpcdecSampleTraits::value_type
mpc_to_mpd_sample(MPC_SAMPLE_FORMAT sample)
{
/* only doing 16-bit audio for now */
int32_t val;
MpcdecSampleTraits::value_type val;
enum {
bits = 24,
};
const int clip_min = -1 << (bits - 1);
const int clip_max = (1 << (bits - 1)) - 1;
constexpr int bits = MpcdecSampleTraits::BITS;
constexpr auto clip_min = MpcdecSampleTraits::MIN;
constexpr auto clip_max = MpcdecSampleTraits::MAX;
#ifdef MPC_FIXED_POINT
const int shift = bits - MPC_FIXED_POINT_SCALE_SHIFT;
@@ -117,16 +119,12 @@ mpc_to_mpd_sample(MPC_SAMPLE_FORMAT sample)
val = sample * float_scale;
#endif
if (val < clip_min)
val = clip_min;
else if (val > clip_max)
val = clip_max;
return val;
return Clamp(val, clip_min, clip_max);
}
static void
mpc_to_mpd_buffer(int32_t *dest, const MPC_SAMPLE_FORMAT *src,
mpc_to_mpd_buffer(MpcdecSampleTraits::pointer_type dest,
const MPC_SAMPLE_FORMAT *src,
unsigned num_samples)
{
while (num_samples-- > 0)
@@ -162,7 +160,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
Error error;
AudioFormat audio_format;
if (!audio_format_init_checked(audio_format, info.sample_freq,
SampleFormat::S24_P32,
mpcdec_sample_format,
info.channels, error)) {
LogError(error);
mpc_demux_exit(demux);
@@ -214,7 +212,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
mpc_uint32_t ret = frame.samples;
ret *= info.channels;
int32_t chunk[ARRAY_SIZE(sample_buffer)];
MpcdecSampleTraits::value_type chunk[ARRAY_SIZE(sample_buffer)];
mpc_to_mpd_buffer(chunk, sample_buffer, ret);
long bit_rate = vbr_update_bits * audio_format.sample_rate

@@ -40,6 +40,12 @@
static constexpr opus_int32 opus_sample_rate = 48000;
/**
* Allocate an output buffer for 16 bit PCM samples big enough to hold
* a quarter second, larger than 120ms required by libopus.
*/
static constexpr unsigned opus_output_buffer_frames = opus_sample_rate / 4;
gcc_pure
static bool
IsOpusHead(const ogg_packet &packet)
@@ -70,10 +76,16 @@ class MPDOpusDecoder {
OpusDecoder *opus_decoder;
opus_int16 *output_buffer;
unsigned output_size;
/**
* If non-zero, then a previous Opus stream has been found
* already with this number of channels. If opus_decoder is
* nullptr, then its end-of-stream packet has been found
* already.
*/
unsigned previous_channels;
bool os_initialized;
bool found_opus;
int opus_serialno;
@@ -86,8 +98,9 @@ public:
InputStream &_input_stream)
:decoder(_decoder), input_stream(_input_stream),
opus_decoder(nullptr),
output_buffer(nullptr), output_size(0),
os_initialized(false), found_opus(false) {}
output_buffer(nullptr),
previous_channels(0),
os_initialized(false) {}
~MPDOpusDecoder();
bool ReadFirstPage(OggSyncState &oy);
@@ -96,6 +109,7 @@ public:
DecoderCommand HandlePackets();
DecoderCommand HandlePacket(const ogg_packet &packet);
DecoderCommand HandleBOS(const ogg_packet &packet);
DecoderCommand HandleEOS();
DecoderCommand HandleTags(const ogg_packet &packet);
DecoderCommand HandleAudio(const ogg_packet &packet);
@@ -159,12 +173,14 @@ inline DecoderCommand
MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
{
if (packet.e_o_s)
return DecoderCommand::STOP;
return HandleEOS();
if (packet.b_o_s)
return HandleBOS(packet);
else if (!found_opus)
else if (opus_decoder == nullptr) {
LogDebug(opus_domain, "BOS packet expected");
return DecoderCommand::STOP;
}
if (IsOpusTags(packet))
return HandleTags(packet);
@@ -184,7 +200,7 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno,
/* we do this for local files only, because seeking
around remote files is expensive and not worth the
troubl */
return -1;
return false;
const auto old_offset = is.GetOffset();
@@ -198,7 +214,7 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno,
ogg_stream_clear(&os);
/* restore the previous file position */
is.Seek(old_offset, IgnoreError());
is.LockSeek(old_offset, IgnoreError());
return result;
}
@@ -225,19 +241,29 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
{
assert(packet.b_o_s);
if (found_opus || !IsOpusHead(packet))
if (opus_decoder != nullptr || !IsOpusHead(packet)) {
LogDebug(opus_domain, "BOS packet must be OpusHead");
return DecoderCommand::STOP;
}
unsigned channels;
if (!ScanOpusHeader(packet.packet, packet.bytes, channels) ||
!audio_valid_channel_count(channels))
!audio_valid_channel_count(channels)) {
LogDebug(opus_domain, "Malformed BOS packet");
return DecoderCommand::STOP;
}
assert(opus_decoder == nullptr);
assert(output_buffer == nullptr);
assert((previous_channels == 0) == (output_buffer == nullptr));
if (previous_channels != 0 && channels != previous_channels) {
FormatWarning(opus_domain,
"Next stream has different channels (%u -> %u)",
previous_channels, channels);
return DecoderCommand::STOP;
}
opus_serialno = os.serialno;
found_opus = true;
/* TODO: parse attributes from the OpusHead (sample rate,
channels, ...) */
@@ -251,6 +277,13 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
return DecoderCommand::STOP;
}
if (previous_channels != 0) {
/* decoder was already initialized by the previous
stream; skip the rest of this method */
LogDebug(opus_domain, "Found another stream");
return decoder_get_command(decoder);
}
eos_granulepos = LoadEOSGranulePos(input_stream, &decoder,
opus_serialno);
const auto duration = eos_granulepos >= 0
@@ -258,21 +291,36 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
opus_sample_rate)
: SignedSongTime::Negative();
previous_channels = channels;
const AudioFormat audio_format(opus_sample_rate,
SampleFormat::S16, channels);
decoder_initialized(decoder, audio_format,
eos_granulepos > 0, duration);
frame_size = audio_format.GetFrameSize();
/* allocate an output buffer for 16 bit PCM samples big enough
to hold a quarter second, larger than 120ms required by
libopus */
output_size = audio_format.sample_rate / 4;
output_buffer = new opus_int16[output_size * audio_format.channels];
output_buffer = new opus_int16[opus_output_buffer_frames
* audio_format.channels];
return decoder_get_command(decoder);
}
inline DecoderCommand
MPDOpusDecoder::HandleEOS()
{
if (eos_granulepos < 0 && previous_channels != 0) {
/* allow chaining of (unseekable) streams */
assert(opus_decoder != nullptr);
assert(output_buffer != nullptr);
opus_decoder_destroy(opus_decoder);
opus_decoder = nullptr;
return decoder_get_command(decoder);
}
return DecoderCommand::STOP;
}
inline DecoderCommand
MPDOpusDecoder::HandleTags(const ogg_packet &packet)
{
@@ -304,10 +352,11 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
int nframes = opus_decode(opus_decoder,
(const unsigned char*)packet.packet,
packet.bytes,
output_buffer, output_size,
output_buffer, opus_output_buffer_frames,
0);
if (nframes < 0) {
LogError(opus_domain, opus_strerror(nframes));
FormatError(opus_domain, "libopus error: %s",
opus_strerror(nframes));
return DecoderCommand::STOP;
}
@@ -392,13 +441,15 @@ mpd_opus_scan_stream(InputStream &is,
if (!oy.ExpectFirstPage(os))
return false;
/* read at most two more pages */
unsigned remaining_pages = 2;
/* read at most 64 more pages */
unsigned remaining_pages = 64;
unsigned remaining_packets = 4;
bool result = false;
ogg_packet packet;
while (true) {
while (remaining_packets > 0) {
int r = ogg_stream_packetout(&os, &packet);
if (r < 0) {
result = false;
@@ -417,6 +468,8 @@ mpd_opus_scan_stream(InputStream &is,
continue;
}
--remaining_packets;
if (packet.b_o_s) {
if (!IsOpusHead(packet))
break;
@@ -461,6 +514,13 @@ static const char *const opus_suffixes[] = {
};
static const char *const opus_mime_types[] = {
/* the official MIME type (RFC 5334) */
"audio/ogg",
/* deprecated (RFC 5334) */
"application/ogg",
/* deprecated; from an early draft */
"audio/opus",
nullptr
};

@@ -85,7 +85,7 @@ public:
char *ReadString() {
uint32_t length;
if (!ReadWord(length))
if (!ReadWord(length) || length >= 65536)
return nullptr;
const char *src = (const char *)Read(length);

@@ -22,67 +22,61 @@
#include "../DecoderAPI.hxx"
#include "tag/TagHandler.hxx"
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/Macros.hxx"
#include "util/FormatString.hxx"
#include "util/Domain.hxx"
#include "util/Error.hxx"
#include "system/ByteOrder.hxx"
#include "system/FatalError.hxx"
#include "Log.hxx"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#ifdef HAVE_SIDPLAYFP
#include <sidplayfp/sidplayfp.h>
#include <sidplayfp/SidInfo.h>
#include <sidplayfp/SidConfig.h>
#include <sidplayfp/SidTune.h>
#include <sidplayfp/SidTuneInfo.h>
#include <sidplayfp/builders/resid.h>
#include <sidplayfp/builders/residfp.h>
#include <sidplayfp/SidDatabase.h>
#else
#include <sidplay/sidplay2.h>
#include <sidplay/builders/resid.h>
#include <sidplay/utils/SidTuneMod.h>
#include <sidplay/utils/SidDatabase.h>
#endif
#define SUBTUNE_PREFIX "tune_"
static constexpr Domain sidplay_domain("sidplay");
static GPatternSpec *path_with_subtune;
static const char *songlength_file;
static GKeyFile *songlength_database;
static SidDatabase *songlength_database;
static bool all_files_are_containers;
static unsigned default_songlength;
static bool filter_setting;
static GKeyFile *
sidplay_load_songlength_db(const char *path)
static SidDatabase *
sidplay_load_songlength_db(const Path path)
{
GError *error = nullptr;
gchar *data;
gsize size;
if (!g_file_get_contents(path, &data, &size, &error)) {
SidDatabase *db = new SidDatabase();
#ifdef HAVE_SIDPLAYFP
bool error = !db->open(path.c_str());
#else
bool error = db->open(path.c_str()) < 0;
#endif
if (error) {
FormatError(sidplay_domain,
"unable to read songlengths file %s: %s",
path, error->message);
g_error_free(error);
path.c_str(), db->error());
delete db;
return nullptr;
}
/* replace any ; comment characters with # */
for (gsize i = 0; i < size; i++)
if (data[i] == ';')
data[i] = '#';
GKeyFile *db = g_key_file_new();
bool success = g_key_file_load_from_data(db, data, size,
G_KEY_FILE_NONE, &error);
g_free(data);
if (!success) {
FormatError(sidplay_domain,
"unable to parse songlengths file %s: %s",
path, error->message);
g_error_free(error);
g_key_file_free(db);
return nullptr;
}
g_key_file_set_list_separator(db, ' ');
return db;
}
@@ -90,18 +84,18 @@ static bool
sidplay_init(const config_param &param)
{
/* read the songlengths database file */
songlength_file = param.GetBlockValue("songlength_database");
if (songlength_file != nullptr)
songlength_database = sidplay_load_songlength_db(songlength_file);
Error error;
const auto database_path = param.GetBlockPath("songlength_database", error);
if (!database_path.IsNull())
songlength_database = sidplay_load_songlength_db(database_path);
else if (error.IsDefined())
FatalError(error);
default_songlength = param.GetBlockValue("default_songlength", 0u);
all_files_are_containers =
param.GetBlockValue("all_files_are_containers", true);
path_with_subtune=g_pattern_spec_new(
"*/" SUBTUNE_PREFIX "???.sid");
filter_setting = param.GetBlockValue("filter", true);
return true;
@@ -110,98 +104,81 @@ sidplay_init(const config_param &param)
static void
sidplay_finish()
{
g_pattern_spec_free(path_with_subtune);
if(songlength_database)
g_key_file_free(songlength_database);
delete songlength_database;
}
/**
* returns the file path stripped of any /tune_xxx.sid subtune
* suffix
*/
static char *
get_container_name(Path path_fs)
{
char *path_container = strdup(path_fs.c_str());
struct SidplayContainerPath {
AllocatedPath path;
unsigned track;
};
if(!g_pattern_match(path_with_subtune,
strlen(path_container), path_container, nullptr))
return path_container;
char *ptr=g_strrstr(path_container, "/" SUBTUNE_PREFIX);
if(ptr) *ptr='\0';
return path_container;
}
/**
* returns tune number from file.sid/tune_xxx.sid style path or 1 if
* no subtune is appended
*/
gcc_pure
static unsigned
get_song_num(const char *path_fs)
ParseSubtuneName(const char *base)
{
if(g_pattern_match(path_with_subtune,
strlen(path_fs), path_fs, nullptr)) {
char *sub=g_strrstr(path_fs, "/" SUBTUNE_PREFIX);
if(!sub) return 1;
if (memcmp(base, SUBTUNE_PREFIX, sizeof(SUBTUNE_PREFIX) - 1) != 0)
return 0;
sub+=strlen("/" SUBTUNE_PREFIX);
int song_num=strtol(sub, nullptr, 10);
base += sizeof(SUBTUNE_PREFIX) - 1;
if (errno == EINVAL)
return 1;
else
return song_num;
} else
return 1;
char *endptr;
auto track = strtoul(base, &endptr, 10);
if (endptr == base || *endptr != '.')
return 0;
return track;
}
/* get the song length in seconds */
/**
* returns the file path stripped of any /tune_xxx.* subtune suffix
* and the track number (or 1 if no "tune_xxx" suffix is present).
*/
static SidplayContainerPath
ParseContainerPath(Path path_fs)
{
const Path base = path_fs.GetBase();
unsigned track;
if (base.IsNull() ||
(track = ParseSubtuneName(base.c_str())) < 1)
return { AllocatedPath(path_fs), 1 };
return { path_fs.GetDirectoryName(), track };
}
#ifdef HAVE_SIDPLAYFP
static SignedSongTime
get_song_length(Path path_fs)
get_song_length(SidTune &tune)
{
if (songlength_database == nullptr)
return SignedSongTime::Negative();
char *sid_file = get_container_name(path_fs);
SidTuneMod tune(sid_file);
free(sid_file);
if(!tune) {
LogWarning(sidplay_domain,
"failed to load file for calculating md5 sum");
const auto length = songlength_database->length(tune);
if (length < 0)
return SignedSongTime::Negative();
}
char md5sum[SIDTUNE_MD5_LENGTH+1];
tune.createMD5(md5sum);
const unsigned song_num = get_song_num(path_fs.c_str());
gsize num_items;
gchar **values=g_key_file_get_string_list(songlength_database,
"Database", md5sum, &num_items, nullptr);
if(!values || song_num>num_items) {
g_strfreev(values);
return SignedSongTime::Negative();
}
int minutes=strtol(values[song_num-1], nullptr, 10);
if(errno==EINVAL) minutes=0;
int seconds;
char *ptr=strchr(values[song_num-1], ':');
if(ptr) {
seconds=strtol(ptr+1, nullptr, 10);
if(errno==EINVAL) seconds=0;
} else
seconds=0;
g_strfreev(values);
return SignedSongTime::FromS((minutes * 60) + seconds);
return SignedSongTime::FromS(length);
}
#else
static SignedSongTime
get_song_length(SidTuneMod &tune)
{
assert(tune);
if (songlength_database == nullptr)
return SignedSongTime::Negative();
const auto length = songlength_database->length(tune);
if (length < 0)
return SignedSongTime::Negative();
return SignedSongTime::FromS(length);
}
#endif
static void
sidplay_file_decode(Decoder &decoder, Path path_fs)
{
@@ -209,26 +186,43 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
/* load the tune */
char *path_container=get_container_name(path_fs);
SidTune tune(path_container, nullptr, true);
free(path_container);
if (!tune) {
LogWarning(sidplay_domain, "failed to load file");
const auto container = ParseContainerPath(path_fs);
#ifdef HAVE_SIDPLAYFP
SidTune tune(container.path.c_str());
#else
SidTuneMod tune(container.path.c_str());
#endif
if (!tune.getStatus()) {
#ifdef HAVE_SIDPLAYFP
const char *error = tune.statusString();
#else
const char *error = tune.getInfo().statusString;
#endif
FormatWarning(sidplay_domain, "failed to load file: %s",
error);
return;
}
const int song_num = get_song_num(path_fs.c_str());
const int song_num = container.track;
tune.selectSong(song_num);
auto duration = get_song_length(path_fs);
auto duration = get_song_length(tune);
if (duration.IsNegative() && default_songlength > 0)
duration = SongTime::FromS(default_songlength);
/* initialize the player */
#ifdef HAVE_SIDPLAYFP
sidplayfp player;
#else
sidplay2 player;
int iret = player.load(&tune);
if (iret != 0) {
#endif
#ifdef HAVE_SIDPLAYFP
bool error = !player.load(&tune);
#else
bool error = player.load(&tune) < 0;
#endif
if (error) {
FormatWarning(sidplay_domain,
"sidplay2.load() failed: %s", player.error());
return;
@@ -236,53 +230,104 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
/* initialize the builder */
ReSIDBuilder builder("ReSID");
if (!builder) {
LogWarning(sidplay_domain,
"failed to initialize ReSIDBuilder");
#ifdef HAVE_SIDPLAYFP
ReSIDfpBuilder builder("ReSID");
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"failed to initialize ReSIDfpBuilder: %s",
builder.error());
return;
}
builder.create(player.info().maxsids());
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"ReSIDfpBuilder.create() failed: %s",
builder.error());
return;
}
#else
ReSIDBuilder builder("ReSID");
builder.create(player.info().maxsids);
if (!builder) {
LogWarning(sidplay_domain, "ReSIDBuilder.create() failed");
FormatWarning(sidplay_domain, "ReSIDBuilder.create() failed: %s",
builder.error());
return;
}
#endif
builder.filter(filter_setting);
if (!builder) {
LogWarning(sidplay_domain, "ReSIDBuilder.filter() failed");
#ifdef HAVE_SIDPLAYFP
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"ReSIDfpBuilder.filter() failed: %s",
builder.error());
return;
}
#else
if (!builder) {
FormatWarning(sidplay_domain, "ReSIDBuilder.filter() failed: %s",
builder.error());
return;
}
#endif
/* configure the player */
sid2_config_t config = player.config();
auto config = player.config();
#ifndef HAVE_SIDPLAYFP
config.clockDefault = SID2_CLOCK_PAL;
config.clockForced = true;
config.clockSpeed = SID2_CLOCK_CORRECT;
#endif
config.frequency = 48000;
#ifndef HAVE_SIDPLAYFP
config.optimisation = SID2_DEFAULT_OPTIMISATION;
config.precision = 16;
config.sidDefault = SID2_MOS6581;
#endif
config.sidEmulation = &builder;
#ifdef HAVE_SIDPLAYFP
config.samplingMethod = SidConfig::INTERPOLATE;
config.fastSampling = false;
#else
config.sidModel = SID2_MODEL_CORRECT;
config.sidSamples = true;
config.sampleFormat = IsLittleEndian()
? SID2_LITTLE_SIGNED
: SID2_BIG_SIGNED;
if (tune.isStereo()) {
#endif
#ifdef HAVE_SIDPLAYFP
const bool stereo = tune.getInfo()->sidChips() >= 2;
#else
const bool stereo = tune.isStereo();
#endif
if (stereo) {
#ifdef HAVE_SIDPLAYFP
config.playback = SidConfig::STEREO;
#else
config.playback = sid2_stereo;
#endif
channels = 2;
} else {
#ifdef HAVE_SIDPLAYFP
config.playback = SidConfig::MONO;
#else
config.playback = sid2_mono;
#endif
channels = 1;
}
iret = player.config(config);
if (iret != 0) {
#ifdef HAVE_SIDPLAYFP
error = !player.config(config);
#else
error = player.config(config) < 0;
#endif
if (error) {
FormatWarning(sidplay_domain,
"sidplay2.config() failed: %s", player.error());
return;
@@ -297,17 +342,21 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
/* .. and play */
#ifdef HAVE_SIDPLAYFP
constexpr unsigned timebase = 1;
#else
const unsigned timebase = player.timebase();
#endif
const unsigned end = duration.IsNegative()
? 0u
: duration.ToScale<uint64_t>(timebase);
DecoderCommand cmd;
do {
char buffer[4096];
short buffer[4096];
size_t nbytes;
nbytes = player.play(buffer, sizeof(buffer));
nbytes = player.play(buffer, ARRAY_SIZE(buffer));
if (nbytes == 0)
break;
@@ -328,7 +377,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
/* ignore data until target time is reached */
while(data_time<target_time) {
nbytes=player.play(buffer, sizeof(buffer));
nbytes=player.play(buffer, ARRAY_SIZE(buffer));
if(nbytes==0)
break;
data_time = player.time();
@@ -343,41 +392,72 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
} while (cmd != DecoderCommand::STOP);
}
gcc_pure
static const char *
GetInfoString(const SidTuneInfo &info, unsigned i)
{
#ifdef HAVE_SIDPLAYFP
return info.numberOfInfoStrings() > i
? info.infoString(i)
: nullptr;
#else
return info.numberOfInfoStrings > i
? info.infoString[i]
: nullptr;
#endif
}
static bool
sidplay_scan_file(Path path_fs,
const struct tag_handler *handler, void *handler_ctx)
{
const int song_num = get_song_num(path_fs.c_str());
char *path_container=get_container_name(path_fs);
const auto container = ParseContainerPath(path_fs);
const unsigned song_num = container.track;
SidTune tune(path_container, nullptr, true);
free(path_container);
if (!tune)
#ifdef HAVE_SIDPLAYFP
SidTune tune(container.path.c_str());
#else
SidTuneMod tune(container.path.c_str());
#endif
if (!tune.getStatus())
return false;
tune.selectSong(song_num);
#ifdef HAVE_SIDPLAYFP
const SidTuneInfo &info = *tune.getInfo();
const unsigned n_tracks = info.songs();
#else
const SidTuneInfo &info = tune.getInfo();
const unsigned n_tracks = info.songs;
#endif
/* title */
const char *title;
if (info.numberOfInfoStrings > 0 && info.infoString[0] != nullptr)
title=info.infoString[0];
else
title="";
const char *title = GetInfoString(info, 0);
if (title == nullptr)
title = "";
if(info.songs>1) {
if (n_tracks > 1) {
char tag_title[1024];
snprintf(tag_title, sizeof(tag_title),
"%s (%d/%d)",
title, song_num, info.songs);
"%s (%d/%u)",
title, song_num, n_tracks);
tag_handler_invoke_tag(handler, handler_ctx,
TAG_TITLE, tag_title);
} else
tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title);
/* artist */
if (info.numberOfInfoStrings > 1 && info.infoString[1] != nullptr)
const char *artist = GetInfoString(info, 1);
if (artist != nullptr)
tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST,
info.infoString[1]);
artist);
/* date */
const char *date = GetInfoString(info, 2);
if (date != nullptr)
tag_handler_invoke_tag(handler, handler_ctx, TAG_DATE,
date);
/* track */
char track[16];
@@ -385,7 +465,7 @@ sidplay_scan_file(Path path_fs,
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track);
/* time */
const auto duration = get_song_length(path_fs);
const auto duration = get_song_length(tune);
if (!duration.IsNegative())
tag_handler_invoke_duration(handler, handler_ctx,
SongTime(duration));
@@ -397,19 +477,25 @@ static char *
sidplay_container_scan(Path path_fs, const unsigned int tnum)
{
SidTune tune(path_fs.c_str(), nullptr, true);
if (!tune)
if (!tune.getStatus())
return nullptr;
const SidTuneInfo &info=tune.getInfo();
#ifdef HAVE_SIDPLAYFP
const SidTuneInfo &info = *tune.getInfo();
const unsigned n_tracks = info.songs();
#else
const SidTuneInfo &info = tune.getInfo();
const unsigned n_tracks = info.songs;
#endif
/* Don't treat sids containing a single tune
as containers */
if(!all_files_are_containers && info.songs<2)
if(!all_files_are_containers && n_tracks < 2)
return nullptr;
/* Construct container/tune path names, eg.
Delta.sid/tune_001.sid */
if(tnum<=info.songs) {
if (tnum <= n_tracks) {
return FormatNew(SUBTUNE_PREFIX "%03u.sid", tnum);
} else
return nullptr;

@@ -157,8 +157,6 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
unsigned bits_per_sample;
encoder->audio_format = audio_format;
/* FIXME: flac should support 32bit as well */
switch (audio_format.format) {
case SampleFormat::S8:
@@ -178,6 +176,8 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
audio_format.format = SampleFormat::S24_P32;
}
encoder->audio_format = audio_format;
/* allocate the encoder */
encoder->fse = FLAC__stream_encoder_new();
if (encoder->fse == nullptr) {

@@ -66,7 +66,7 @@ struct opus_encoder {
ogg_int64_t granulepos;
opus_encoder():encoder(opus_encoder_plugin) {}
opus_encoder():encoder(opus_encoder_plugin), granulepos(0) {}
};
static constexpr Domain opus_encoder_domain("opus_encoder");

@@ -26,7 +26,6 @@
#include "util/NumberParser.hxx"
#include "util/DynamicFifoBuffer.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
extern "C"
{
@@ -60,8 +59,6 @@ struct ShineEncoder {
bool WriteChunk(bool flush);
};
static constexpr Domain shine_encoder_domain("shine_encoder");
inline bool
ShineEncoder::Configure(const config_param &param,
gcc_unused Error &error)

@@ -27,6 +27,8 @@
#include <assert.h>
#include <string.h>
static constexpr uint16_t WAVE_FORMAT_PCM = 1;
struct WaveEncoder {
Encoder encoder;
unsigned bits;
@@ -64,15 +66,15 @@ fill_wave_header(struct wave_header *header, int channels, int bits,
header->id_fmt = ToLE32(0x20746d66);
header->id_data = ToLE32(0x61746164);
/* wave format */
header->format = ToLE16(1); // PCM_FORMAT
/* wave format */
header->format = ToLE16(WAVE_FORMAT_PCM);
header->channels = ToLE16(channels);
header->bits = ToLE16(bits);
header->freq = ToLE32(freq);
header->blocksize = ToLE16(block_size);
header->byterate = ToLE32(freq * block_size);
/* chunk sizes (fake data length) */
/* chunk sizes (fake data length) */
header->fmt_size = ToLE32(16);
header->data_size = ToLE32(data_size);
header->riff_size = ToLE32(4 + (8 + 16) + (8 + data_size));

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

@@ -21,9 +21,6 @@
#define MPD_SOCKET_DEFERRED_MONITOR_HXX
#include "check.h"
#include "Compiler.h"
#include <atomic>
class EventLoop;

@@ -179,9 +179,10 @@ EventLoop::Run()
mutex.lock();
HandleDeferred();
busy = false;
const bool _again = again;
mutex.unlock();
if (again)
if (_again)
/* re-evaluate timers because one of the
IdleMonitors may have added a new
timeout */

@@ -130,7 +130,7 @@ get_remote_uid(int fd)
socklen_t len = sizeof (cred);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0)
return 0;
return -1;
return cred.uid;
#else

@@ -53,10 +53,11 @@ public:
children.emplace_back(name, filter);
}
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error);
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
void Close() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
private:
/**

@@ -34,10 +34,11 @@ class NormalizeFilter final : public Filter {
PcmBuffer buffer;
public:
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
void Close() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
};
static Filter *

@@ -112,10 +112,11 @@ public:
*/
void Update();
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
void Close() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
};
void
@@ -133,8 +134,6 @@ ReplayGainFilter::Update()
volume = pcm_float_to_volume(scale);
}
pv.SetVolume(volume);
if (mixer != nullptr) {
/* update the hardware mixer volume */
@@ -145,7 +144,8 @@ ReplayGainFilter::Update()
Error error;
if (!mixer_set_volume(mixer, _volume, error))
LogError(error, "Failed to update hardware mixer");
}
} else
pv.SetVolume(volume);
}
static Filter *
@@ -173,7 +173,9 @@ ReplayGainFilter::Close()
ConstBuffer<void>
ReplayGainFilter::FilterPCM(ConstBuffer<void> src, gcc_unused Error &error)
{
return pv.Apply(src);
return mixer != nullptr
? src
: pv.Apply(src);
}
const struct filter_plugin replay_gain_filter_plugin = {

@@ -47,9 +47,11 @@
#include "filter/FilterInternal.hxx"
#include "filter/FilterRegistry.hxx"
#include "pcm/PcmBuffer.hxx"
#include "pcm/Silence.hxx"
#include "util/StringUtil.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "util/WritableBuffer.hxx"
#include <algorithm>
@@ -120,10 +122,11 @@ public:
*/
bool Configure(const config_param &param, Error &error);
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
void Close() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
};
bool
@@ -265,9 +268,8 @@ RouteFilter::FilterPCM(ConstBuffer<void> src, gcc_unused Error &error)
(unsigned)sources[c] >= input_format.channels) {
// No source for this destination output,
// give it zeroes as input
memset(chan_destination,
0x00,
bytes_per_frame_per_channel);
PcmSilence({chan_destination, bytes_per_frame_per_channel},
input_format.format);
} else {
// Get the data from channel sources[c]
// and copy it to the output

@@ -26,7 +26,6 @@
#include "AudioFormat.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <assert.h>
#include <string.h>
@@ -43,14 +42,13 @@ public:
pv.SetVolume(_volume);
}
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
/* virtual methods from class Filter */
AudioFormat Open(AudioFormat &af, Error &error) override;
void Close() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
Error &error) override;
};
static constexpr Domain volume_domain("pcm_volume");
static Filter *
volume_filter_init(gcc_unused const config_param &param,
gcc_unused Error &error)

@@ -46,7 +46,11 @@ AllocatedPath
AllocatedPath::FromUTF8(const char *path_utf8)
{
#ifdef HAVE_GLIB
return AllocatedPath(Donate(), ::PathFromUTF8(path_utf8));
char *path = ::PathFromUTF8(path_utf8);
if (path == nullptr)
return AllocatedPath::Null();
return AllocatedPath(Donate(), path);
#else
return FromFS(path_utf8);
#endif

@@ -252,7 +252,7 @@ public:
void ChopSeparators();
gcc_pure
bool IsAbsolute() {
bool IsAbsolute() const {
return PathTraitsFS::IsAbsolute(c_str());
}
};

@@ -34,6 +34,8 @@
#include <assert.h>
#include <string.h>
#ifdef HAVE_GLIB
/**
* Maximal number of bytes required to represent path name in UTF-8
* (including nul-terminator).
@@ -44,7 +46,6 @@
*/
static constexpr size_t MPD_PATH_MAX_UTF8 = (MPD_PATH_MAX - 1) * 4 + 1;
#ifdef HAVE_GLIB
static std::string fs_charset;
gcc_pure
@@ -102,7 +103,10 @@ static inline void FixSeparators(std::string &s)
std::string
PathToUTF8(const char *path_fs)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_fs != nullptr);
#endif
#ifdef HAVE_GLIB
if (fs_charset.empty()) {
@@ -143,7 +147,10 @@ PathToUTF8(const char *path_fs)
char *
PathFromUTF8(const char *path_utf8)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_utf8 != nullptr);
#endif
if (fs_charset.empty())
return g_strdup(path_utf8);

@@ -29,6 +29,8 @@
#include <assert.h>
#include <string.h>
class AllocatedPath;
/**
* A path name in the native file system character set.
*
@@ -128,6 +130,22 @@ public:
gcc_pure
std::string ToUTF8() const;
/**
* Determine the "base" file name.
* The return value points inside this object.
*/
gcc_pure
Path GetBase() const {
return FromFS(PathTraitsFS::GetBase(value));
}
/**
* Gets directory name of this path.
* Returns a "nulled" instance on error.
*/
gcc_pure
AllocatedPath GetDirectoryName() const;
/**
* Determine the relative part of the given path to this
* object, not including the directory separator. Returns an
@@ -140,7 +158,7 @@ public:
}
gcc_pure
bool IsAbsolute() {
bool IsAbsolute() const {
return PathTraitsFS::IsAbsolute(c_str());
}
};

28
src/fs/Path2.cxx Normal file

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2003-2014 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 "Path.hxx"
#include "AllocatedPath.hxx"
AllocatedPath
Path::GetDirectoryName() const
{
return AllocatedPath::FromFS(PathTraitsFS::GetParent(c_str()));
}

@@ -52,7 +52,10 @@ template<typename Traits>
typename Traits::const_pointer
GetBasePathImpl(typename Traits::const_pointer p)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
typename Traits::const_pointer sep = Traits::FindLastSeparator(p);
return sep != nullptr
@@ -64,7 +67,10 @@ template<typename Traits>
typename Traits::string
GetParentPathImpl(typename Traits::const_pointer p)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
typename Traits::const_pointer sep = Traits::FindLastSeparator(p);
if (sep == nullptr)

@@ -57,7 +57,11 @@ struct PathTraitsFS {
gcc_pure gcc_nonnull_all
static const_pointer FindLastSeparator(const_pointer p) {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
#ifdef WIN32
const_pointer pos = p + GetLength(p);
while (p != pos && !IsSeparator(*pos))
@@ -77,7 +81,11 @@ struct PathTraitsFS {
gcc_pure gcc_nonnull_all
static bool IsAbsolute(const_pointer p) {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
#ifdef WIN32
if (IsDrive(p) && IsSeparator(p[2]))
return true;
@@ -147,7 +155,11 @@ struct PathTraitsUTF8 {
gcc_pure gcc_nonnull_all
static const_pointer FindLastSeparator(const_pointer p) {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
return strrchr(p, SEPARATOR);
}
@@ -160,7 +172,11 @@ struct PathTraitsUTF8 {
gcc_pure gcc_nonnull_all
static bool IsAbsolute(const_pointer p) {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr);
#endif
#ifdef WIN32
if (IsDrive(p) && IsSeparator(p[2]))
return true;

@@ -62,6 +62,7 @@ FileOutputStream::Commit(gcc_unused Error &error)
assert(IsDefined());
CloseHandle(handle);
handle = INVALID_HANDLE_VALUE;
return true;
}
@@ -71,6 +72,7 @@ FileOutputStream::Cancel()
assert(IsDefined());
CloseHandle(handle);
handle = INVALID_HANDLE_VALUE;
RemoveFile(path);
}

@@ -19,6 +19,7 @@
#include "config.h"
#include "AsyncInputStream.hxx"
#include "Domain.hxx"
#include "tag/Tag.hxx"
#include "event/Call.hxx"
#include "thread/Cond.hxx"
@@ -113,8 +114,10 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error)
/* no-op */
return true;
if (!IsSeekable())
if (!IsSeekable()) {
error.Set(input_domain, "Not seekable");
return false;
}
/* check if we can fast-forward the buffer */
@@ -157,6 +160,11 @@ AsyncInputStream::SeekDone()
assert(io_thread_inside());
assert(IsSeekPending());
/* we may have reached end-of-file previously, and the
connection may have been closed already; however after
seeking successfully, the connection must be alive again */
open = true;
seek_state = SeekState::NONE;
cond.broadcast();
}

@@ -83,6 +83,10 @@ protected:
*/
void SetTag(Tag *_tag);
void ClearTag() {
SetTag(nullptr);
}
void Pause();
bool IsPaused() const {

24
src/input/Domain.cxx Normal file

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2003-2014 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 "Domain.hxx"
#include "util/Domain.hxx"
const Domain input_domain("input");

@@ -17,9 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef INPUT_DESPOTIFY_HXX
#define INPUT_DESPOTIFY_HXX
#ifndef MPD_INPUT_DOMAIN_HXX
#define MPD_INPUT_DOMAIN_HXX
extern const struct InputPlugin input_plugin_despotify;
class Domain;
extern const Domain input_domain;
#endif

@@ -67,7 +67,7 @@ input_stream_global_init(Error &error)
case InputPlugin::InitResult::UNAVAILABLE:
if (error.IsDefined()) {
FormatError(error,
"Input plugin '%s' is unavailable: ",
"Input plugin '%s' is unavailable",
plugin->name);
error.Clear();
}

@@ -122,7 +122,10 @@ InputStream::IsAvailable()
size_t
InputStream::LockRead(void *ptr, size_t _size, Error &error)
{
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(ptr != nullptr);
#endif
assert(_size > 0);
const ScopeLock protect(mutex);

@@ -200,6 +200,10 @@ public:
return mime.empty() ? nullptr : mime.c_str();
}
void ClearMimeType() {
mime.clear();
}
gcc_nonnull_all
void SetMimeType(const char *_mime) {
assert(!ready);

@@ -22,14 +22,13 @@
#include "Registry.hxx"
#include "InputPlugin.hxx"
#include "LocalOpen.hxx"
#include "Domain.hxx"
#include "plugins/RewindInputPlugin.hxx"
#include "fs/Traits.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
static constexpr Domain input_domain("input");
InputStream *
InputStream::Open(const char *url,
Mutex &mutex, Cond &cond,

@@ -54,10 +54,6 @@
#include "plugins/CdioParanoiaInputPlugin.hxx"
#endif
#ifdef ENABLE_DESPOTIFY
#include "plugins/DespotifyInputPlugin.hxx"
#endif
const InputPlugin *const input_plugins[] = {
&input_plugin_file,
#ifdef HAVE_ALSA
@@ -83,9 +79,6 @@ const InputPlugin *const input_plugins[] = {
#endif
#ifdef ENABLE_CDIO_PARANOIA
&input_plugin_cdio_paranoia,
#endif
#ifdef ENABLE_DESPOTIFY
&input_plugin_despotify,
#endif
nullptr
};

@@ -38,8 +38,8 @@ TextInputStream::ReadLine()
while (true) {
auto dest = buffer.Write();
if (dest.size < 2) {
/* end of file (or line too long): terminate
the current line */
/* line too long: terminate the current
line */
assert(!dest.IsEmpty());
dest[0] = 0;
@@ -66,7 +66,19 @@ TextInputStream::ReadLine()
if (line != nullptr)
return line;
if (nbytes == 0)
return nullptr;
if (nbytes == 0) {
/* end of file: see if there's an unterminated
line */
dest = buffer.Write();
assert(!dest.IsEmpty());
dest[0] = 0;
auto r = buffer.Read();
buffer.Clear();
return r.IsEmpty()
? nullptr
: r.data;
}
}
}

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