-fixes regression introduced by:
'8d6fedf8177d0d2ced81e6d93d35c368b2ac69db [PATCH] Mixer: add class MixerListener'
-listener.OnMixerVolumeChanged() called GetVolume() which attempted to acquire
the lock but as per 'pa_threaded_mainloop_lock()' documentation:
This function may not be called inside the event loop thread. Events that are
dispatched from the event loop thread are executed with this lock held
-this patch seperates the underlying action of GetVolume() into a new
GetVolumeInternal() function, to be called only when the lock is already held, as
is the case for the listener.OnMixerVolumeChanged() call
This deadlock was a regression by commit 8e38b4f8. Since we currently
can't resolve this, let's revert the commit, and add a GLib specific
workaround for the build failure.
This plugin is horrible code, I mean it. Last year, I tried hard to
fix it, but I figured would take less time to do a full rewrite.
Given that I don't even have any device that supports RAOP, I can't do
that properly. After 16 months, nobody volunteered for fixing it.
Hereby, I delete it, because having no RAOP plugin is better than
having this mess. Sorry.
Use libasound's polling functions, implement a bridge to GSource /
GPollFD and send idle events to clients when an external program
changes the ALSA mixer volume.
After we've been hit by Large File Support problems several times in
the past week (which only occur on 32 bit platforms, which I don't
have), this is yet another attempt to fix the issue.
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.
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.
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".
This mixer plugin may be used instead of the traditional global
software mixer. It integrates with the "volume" filter plugin, and
can control the software volume of an audio output which has no
hardware mixer.
Using two different kinds of locks may result in a race condition with
a deadlock. The libpulse callbacks need no locks at all, because the
mainloop object can be assumed to be already locked.
snd_config_update_free_global() frees cached ALSA configuration. This
keeps valgrind a little bit more quiet. This patch moves the call
from the open() method into the finish() method, which seems more
natural: it allows the use of the config cache, and improves the
cleanup phase.
There are numerous race conditions between the libpulse thread
(pulse_mixer.c callbacks) and the rest of MPD. Protect the volatile
attributes of the pulse_mixer struct with a mutex to fix that.
Don't mess with pulse_mixer.volume for setting the volume. This
variable should only be used to transfer the current volume from
sink_input_vol() to pulse_mixer_get_volume().
The pa_context_get_sink_input_info() function is asynchronous, and
after it returns, libpulse does not guarantee that the operation has
completed yet; in fact, it is not likely. Explicitly wait for the
operation to complete.
The code for the new pulse_wait_for_operation() function was inspired
by mplayer and xine code.
The pm->volume attribute was allocated in pulse_mixer_init(), but is
never freed. This leaks memory. Instead of adding the g_free() call
to pulse_mixer_finish(), let's just make "volume" a static attribute
of the pulse_mixer struct. That is easier to deal with.
Nobody needs to modify these strings. We can make them const, and
convert config_dup_block_string() to config_get_block_string(). This
also fixes memory leaks in the pulse mixer.
Remember if a mixer object is open or closed. Don't call open() again
if it is already open. This guarantees that the mixer plugin is
always called in a consistent state, and we will be able to remove
lots of checks from the implementations.
To support mixers which are automatically opened even if the audio
output is still closed (to set the volume before playback starts),
this patch also adds the "global" flag to the mixer_plugin struct.
Both ALSA and OSS set this flag, while PULSE does not.
when the mixer is closed,
- the mainloop is stopped.
- the context is disconnected.
- then the mainloop is freed.
Signed-off-by: David Guibert <david.guibert@gmail.com>
This updates the copyright header to all be the same, which is
pretty much an update of where to mail request for a copy of the GPL
and the years of the MPD project. This also puts all committers under
'The Music Player Project' umbrella. These entries should go
individually in the AUTHORS file, for consistancy.
This patch follows the commit 21bb10f4b.
>From Max Kellermann:
> I removed the daemonization changes in main.c. Please explain why you
> changed that. If you need it for some reason, make that a separate
> patch with a good description of your rationale.
> That's the biggest flaw of your code: it opens the mixer device in the
> init() method, while the open() method is empty. When the pulse
> daemon is not available (either during MPD startup or when it dies
> while MPD runs), the plugin will not even attempt to reconnect to
> pulse. Please move the code to the open() method, to make that work.
I changed the daemonize call as the fork losts the connection to the
pulse server. According to your remark, the init() method should be
moved to the open() ones.
With the modification, mpd is able to reconnect the pulse mixer after
restarting the pulseaudio daemon.
Signed-off-by: David Guibert <david.guibert@gmail.com>
Signed-off-by: Max Kellermann <max@duempel.org>
This patch introduces the mixer for the pulse output.
Technically speaking, the pulse index is needed to get or set
the volume. You must define callback fonctions to get this index since
the pulse output in mpd is done using the simpe api. The pulse simple api
does not provide the index of the newly defined output.
So callback fonctions are associated to the pulse context.
The list of all the sink input is then retreived.
Then we select the name of the mpd pulse output and control
its volume by its associated index number.
Signed-off-by: Patrice Linel <patnathanael@gmail.com>
Signed-off-by: David Guibert <david.guibert@gmail.com>
[mk: fixed whitespace errors and broke long lines; removed
daemonization changes from main.c]
Both methods are always called together. There is no point in having
them separate. This simplifies the code, because the old configure()
method could be called more than once, and had to free old
allocations.
Return the default value in the conf_get_block_*() functions when
param==NULL was passed.
This simplifies a lot of code, because all initialization can be done
in one code path, regardless whether configuration is present.
This patch tryes to introduce pluggable mixer (struct mixer_plugin) along with some basic infrastructure (mixer_* functions). Instance of mixer (struct mixer) is used in
alsa and oss output plugin