Added the "fd_util" library, which attempts to use the new thread-safe
Linux system calls pipe2(), accept4() and the options O_CLOEXEC,
SOCK_CLOEXEC. Without these, it falls back to FD_CLOEXEC, which is
not thread safe.
This is particularly important for the "pipe" output plugin (and
others, such as JACK/PulseAudio), because we were heavily leaking file
descriptors to child processes.
When an output's enable() method has failed, and playback starts,
retry to enable it. Without this, the user may be confused, because
he sees the device is "enabled" but cannot use it, and currently there
is no error message in the log.
Moved the global input stream opener to decoder_run_stream().
decoder_run_file() now opens the input stream each time a plugin
provides a stream decoder method.
Same as the previous patch: create up to 16 configured source ports.
The plugin tries to do its best at guessing the right combination for
the given input file, the number of source and destination ports.
This patch allows the client to load a playlist file from the playlist
directory with a plugin. This can be used with the "load" command,
but the client has to pass the file name including the suffix. We
will probably use the music directory in the future, to support
playlist files inside the music directory.
If one plugin has failed to open the playlist, it may have consumed a
part of the stream already. This may lead to a failure in all
following plugins. Fix: rewind the stream before each open() call.
Implement the methods enable() and disable(). Bind the HTTP port in
the enable() method, but reject all incoming connections until the
output is opened.
After playback has stopped, the ring buffers may still contain
samples. These will be played when playback is started the next
time. We should clear the buffers each time.
jack_client_new() is deprecated. This requires libjack 0.100
(released nearly 5 years ago). We havn't been testing older libjack
versions anyway.
As a side effect, there is the new option "autostart".
When a song's tags could not be loaded during database update, log
this as a debug message. Same for a song being removed because its
updated tag could not be read.
Store a list of supported tag items in the database. When loading a
database which does not have a matching list, we must rescan in order
to get the missing information.
When the decoder finishes the "queued" song very quickly (before the
"current" song finishes playing), an assertion in do_play() fails
because it thinks that it should start decoding the queued song,
although that has in fact just finished.
This is only a slight change to the previous locking behaviour: keep
the decoder unlocked during the loop, and lock it only while checking
decoder_control.command.
Reintroduce a fix from commit 52a0653 (Warren Dukes): "don't call
snd_pcm_drain unless we're already in the RUNNING state". This prevents
ALSA with dmix from sometimes hanging when snd_pcm_drain is called, e.g.
when moving from one song to the next (as in mantis issue 2634).
While paused, the player thread re-locks its mutex and waits for a
signal. This is racy: when the command is set while the thread is
waiting for the lock, it may wait forever. This patch adds another
command check before player_wait().
After CANCEL, the output thread waits for another signal before it
continues playback, to synchronize with the caller. There were some
situations where this signal wasn't sent properly. This patch adds an
explicit g_cond_signal() at two code positions.
These parameters must be protected with a mutex, too. Wrap everything
inside player_lock()/player_unlock(), and use player_command_locked()
instead of player_command().
After CANCEL, call g_cond_wait() only if the new command is still
NONE. Problem is that ao_command_finished() has to unlock the
audio_output object, and in the meantime, the player thread might have
submitted a new command.
Use a single GString buffer object in all functions loading the
database. Enlarge it automatically for long lines. This eliminates
the maximum line length for tag values. There is still an upper limit
of 512 kB to prevent denial of service, but that's reasonable I guess.
Allocate the directory object after the "directory:" line. Assign the
mtime from the input file to this new object, instead of to the parent
directory.
The line buffer had a fixed size of 5 kB, and was allocated on the
stack. This was too small for some users. As a hotfix, we're
increasing the buffer size to 32 kB now, allocated on the heap. In
MPD 0.16, we'll switch to dynamic allocation.
Use GMutex/GCond instead of the notify library. Manually lock the
player_control object before accessing the protected attributes. Use
the GCond object to notify the player thread and the main thread.
Right after seeking and song change, the elapsed_time shows old
information, because the output thread didn't finish a full chunk
yet. This patch re-adds a second elapsed_time variable, and keeps
track of a fallback value, in case the output thread can't provide a
reliable value.
Return false when there was no chunk in the pipe. If the function
returns true, then audio_output_task() will not wait for a notify from
the player thread. This fixes a race condition.
Don't set the error in play_chunk(); do all the error handling in the
caller. The errored_song attribute isn't set anymore; it doesn't make
sense for PLAYER_ERROR_AUDIO.
drain() is the opposite of cancel(): it waits until all data in the
buffer has finished playing. Instead of implicitly draining in the
close() method like the ALSA plugin has been doing it forever, let the
output thread decide whether to drain or to cancel.
Convert the metadata with the libavformat function av_metadata_conv().
This ensures that canonical tag names are provided by libavformat, and
we can remove the "artist" vs "author" workaround.
When you disable the "follow_outside_symlinks" or the
"follow_inside_symlinks" setting, the next update should remove the
now-ignored files from the database.
With these methods, an output plugin can allocate some global
resources only if it is actually enabled. The method enable() is
called after daemonization, which allows for more sophisticated
resource allocation during that method.
Don't let the mixer plugin "override" the libpulse callbacks.
Instead, add a "mixer" attribute to the pulse_output struct, and call
the mixer on all interesting events.
If the method get_volume() returns -1 and no error object is set, then
the volume is currently unavailable, but the mixer should not be
closed immediately.
This is a complete rewrite of the PulseAudio output plugin. It uses
the asynchronous API, which gives us more control over everything.
Additionally, it connects to the PulseAudio server on startup, and
keeps this connection up while MPD runs. During pause, instead of
closing the stream, it enables "cork".
I'm not sure about the advantages of calling g_set_application_name(),
because I don't use a task manager (except for ps and kill), but it
sure doesn't hurt.
svn r13289 of libvorbis introduced static callbacks (like OV_CALLBACKS_DEFAULT)
defined in "vorbisfile.h" header. First released version with this change is libvorbis-1.2.2.
In libversion-1.2.3 OV_EXCLUDE_STATIC_CALLBACKS define was added to avoid
warnings about unused static callbacks. Information on the OV_EXCLUDE_STATIC_CALLBACKS
can be found in http://svn.xiph.org/trunk/vorbis/CHANGES.
It will be possible to enable replay gain at runtime even when it is
disabled in the configuration file. This patch enables the preamp
settings in this case.
Don't initialize "vc" and "cs" with FLAC__metadata_object_new(); that
value is overwritten by FLAC__metadata_get_tags() and
FLAC__metadata_get_cuesheet().
When the player thread unpauses, it sends CANCEL to the output thread,
after having checked that the output is still open. Problem is when
the output thread closes the device before it can process the CANCEL
command - race condition. This patch adds another "open" check inside
the output thread.
When the audio output fails to open, MPD pauses playback, but doesn't
reset player.play_audio_format. This leads to an assertion failure in
audio_output_all_check() on the next REFRESH command, because no audio
output is open.
This has been replaced by the last.fm playlist plugin. The input
plugin has never worked well, and was just a playground to experiment
with the last.fm radio protocol.
When the connection is lost while buffering, the CURL input plugin may
enter an endless loop, because it does not check the EOF condition.
This patch makes fill_buffer() return success only if there's at least
one buffer, which is enough of a check.x
Accidently, MPD has been using several GLib 2.16 functions for a
while, and nobody noticed yet. To simplify the code base, let's bump
the minimum GLib version for MPD to 2.16. That version is old enough,
and it's reasonable to expect users to have it.
Based on this API, we will add parsers for EXTM3U, PLS, ASX, last.fm
radio and others.
There is no integration into the MPD core yet. Right now, we have a
command line test program. This is work in progress.
The "off_t" type may change when you enable or disable large file
support on 32 bit platforms. This caused severe ABI problems within
MPD when we enabled LFS for the first time: two sources included
config.h and sys/types.h in different order, and had different off_t
sizes - leading to memory corruption because of ABI incompatibility.
This patch attempts to get rid of all public "off_t" uses: it removes
"off_t" from the input_stream ABI/API, and switches to GLib's 64 bit
"goffset" type. This may hurt 32 bit embedded platforms a tiny bit,
but that's not even measurable.
On 32 bit systems with large file support enabled (i.e. "sizeof(off_t)
> sizeof(size_t)") gcc emits a warning because a size_t cast to off_t
can never become negative.
When there is no Content-Type response header, try the "mad" decoder
plugin. It uesd to be named "mp3", and we forgot to change the
fallback name in decoder_thread.c.
When a received chunk of data has only icy-metadata, there was no
usable data left for input_curl_read() to return, and thus it returned
0 bytes. "0" however is a special value for "end of file" or
"error". This patch makes input_curl_read() read more data from the
socket, until the read request can be fulfilled (or until there's
really EOF).
Tracking the "elapsed" time from the chunks which we have sent to the
output pipe is very imprecise: since we have implemented the music
pipe, we're sending large number of chunks at once, giving the
"elapsed" time stamp a resolution of usually more than a second.
This patch changes the source of this information to the outputs. If
a chunk has been played by all outputs, the "elapsed" time stamp is
updated.
The new command PLAYER_COMMAND_REFRESH makes the player thread update
its status information: it tells the outputs to update the chunk time
stamp. After that, player_control.elapsed_time is current.
The new player_status struct replaces a bunch of playerGetX()
functions. When we add proper locking to the player_control struct,
we will only need to lock once for the "status" command.
No more CD player emulation. The current behaviour of "previous" is
difficult for a client to predict, because it does not definitely know
the current position within the song. If a client wants to restart
the current song, it can always send "playid".
If nothing has changed since the last save, don't save the state
file. Saving will spin up the hard drive, which is undesirable on
hosts where MPD is idling in background.
Usually, we read our "artist" tag from ffmpeg's "author" tag. In some
cases however (e.g. APE), this tag is named "artist". This patch
implements a fallback: if no "author" is found, MPD tries to use
"artist".
When the ID3 tag in an AAC file is larger than the current buffer, the
function decoder_buffer_consume() aborts. By using the new function
decoder_buffer_skip() instead, we can safely skip the ID3 tag.
This patch implements a light-weight inotify library, and watches all
directories below the music directory. It updates all directories
where files changed after a delay of 5 seconds.
Allow most printable characters in unquoted words. The tokenizer
patch introduced very strict requirements for command parameters -
those were undocumented, and we're reverting the strictness now.
Don't call g_error(), which will abort the process and dump core.
This patch does not affect all the config_get_X() functions. These
need some more refactoring.
using ov_test_callback with function CALLBACKS_STREAMONLY will cause
scanning to stop after the comment field. ov_open (and ov_test)
default to CALLBACKS_DEFAULT which scans the file structure causing a
huge slowdown. The speed improvement is huge: It scanned my files
around 10x faster This procedure has been recommended by monthy (main
vorbis developer) and was said to be safe for scanning files.