Commit Graph

161 Commits

Author SHA1 Message Date
Max Kellermann
ac32f36e4e mixer_plugin: pass audio_output pointer to mixer_plugin.init()
This allows the mixer object to access its associated audio output
object.
2009-10-21 09:48:41 +02:00
Max Kellermann
4e2fb3fb89 mixer_plugin: use GError for error handling 2009-10-20 22:10:56 +02:00
Max Kellermann
097e200a97 mixer/{oss,alsa}: renamed the mixer source files 2009-10-20 21:23:05 +02:00
Max Kellermann
bc4266bef8 pulse: renamed source files 2009-10-20 21:05:11 +02:00
Max Kellermann
5d74b1efef mixer/software: new mixer which controls filter/volume
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.
2009-07-06 21:52:15 +02:00
Max Kellermann
9038882d95 alsa_mixer: use g_ascii_strcasecmp() instead of strcasecmp()
strcasecmp() is locale dependent, making it a bad choice for internal
string comparisons.
2009-04-28 09:28:16 +02:00
Daniel Kahn Gillmor
05dfdfdb39 alsa_mixer: add mixer_index option
This allows you to select controls with duplicate names.
2009-04-28 09:15:48 +02:00
Max Kellermann
d2010c0289 pulse_mixer: use PULSE's mainloop lock instead of GMutex
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.
2009-04-25 13:53:15 +02:00
Max Kellermann
eb059a789c alsa_mixer: call snd_config_update_free_global() in finish()
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.
2009-04-21 22:47:08 +02:00
Max Kellermann
43864762ee mixer: assert that the new volume value is valid
Added an assertion in mixer_set_volume().  Removed the range checks
from the ALSA and OSS plugins.
2009-03-27 20:10:39 +01:00
Max Kellermann
7d3921bb88 pulse_mixer: protect the struct with a mutex
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.
2009-03-27 16:55:17 +01:00
Max Kellermann
7f762a5cec pulse_mixer: return if mixer is offline
Eliminate one indent level.  Also remove several debug useless debug
messages.
2009-03-27 16:44:37 +01:00
Max Kellermann
13319e0b70 pulse_mixer: removed superfluous G_GNUC_UNUSED attributes
Those parameters are used after all.
2009-03-27 16:44:36 +01:00
Max Kellermann
d448392f25 pulse_mixer: use local pa_cvolume variable for set_volume()
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().
2009-03-27 16:44:36 +01:00
Max Kellermann
8258457b43 pulse_mixer: wait for get_volume() operation to complete
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.
2009-03-27 16:44:36 +01:00
Max Kellermann
929c200c38 pulse_mixer: adapted code style
Use the same code style as the rest of MPD.
2009-03-27 00:43:47 +01:00
Max Kellermann
4343c108b3 pulse_mixer: removed superfluous initializations
Don't initialize attributes which are only used in an open mixer.  As
long as nobody accesses them, their values are uninitialized and
undefined.
2009-03-26 19:50:31 +01:00
Max Kellermann
239e6da442 pulse_mixer: allocate "volume" statically
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.
2009-03-26 19:50:27 +01:00
Max Kellermann
6c480d7db4 pulse_mixer: removed superfluous NULL checks in close()
When the MPD core knows that the pulse mixer is open, pm->mainloop and
pm->context must be non-NULL.
2009-03-26 19:50:23 +01:00
Max Kellermann
8cf206f2ee pulse_mixer: initialize "online" and "index" in open()
The attributes "online" and "index" were not properly reinitialized
after a close/open cycle.
2009-03-26 19:50:15 +01:00
Max Kellermann
52575d1b9d pulse: make configuration strings const
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.
2009-03-26 19:50:10 +01:00
Max Kellermann
cd4964cdee pulse: don't check config_param!=NULL
The conf.h functions deal well with config_param==NULL and will return
the specified default value then.
2009-03-26 19:50:02 +01:00
Max Kellermann
74273d419a pulse_mixer: free libpulse objects on failure
When the mixer initialization fails, we have to free the libpulse
objects we have already created, to prevent resource leaks.
2009-03-26 19:49:58 +01:00
Max Kellermann
3d2c8b001a pulse_mixer: unlock the mainloop on failure
It's illegal to return from pulse_mixer_setup() without unlocking the
main loop.  In the error handling, that unlock() call was missing.
2009-03-26 19:49:55 +01:00
Max Kellermann
d113c07190 pulse_mixer: moved code to pulse_mixer_setup()
Prepare for adding proper error handling.
2009-03-26 19:49:39 +01:00
Max Kellermann
3be1850744 alsa_mixer: initialize "volume_set" in the open() method
"volume_set" is an attribute which becomes undefined when the mixer is
closed.  That means, it must be initialized each time the mixer is
opened.
2009-03-26 19:49:36 +01:00
Max Kellermann
0c9799babe alsa_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a
consistent state.  This means we can remove lots of checks from the
volume methods.
2009-03-26 19:49:31 +01:00
Max Kellermann
331b714a7a alsa_mixer: pass default device to config_get_block_string()
Instead of replacing NULL with the default device in the open()
method, pass the default device to config_get_block_string().
2009-03-26 19:49:26 +01:00
Max Kellermann
f06f049cd8 alsa_mixer: make "device" and "control" const
Use config_get_block_string() instead of config_dup_block_string().
2009-03-26 19:48:55 +01:00
Max Kellermann
c552d17c03 oss_mixer: call oss_find_mixer() in init() method
Detect misconfiguration during MPD startup.
2009-03-26 19:48:21 +01:00
Max Kellermann
881026623c oss_mixer: removed superfluous checks
The MPD core guarantees that methods are always invoked in a
consistent state.  This means we can remove lots of checks from the
volume methods.
2009-03-26 19:48:13 +01:00
Max Kellermann
dd8c6d6738 oss_mixer: use g_ascii_strncasecmp() instead of strncasecmp()
strncasecmp() is locale dependent, but we only need ASCII here.
2009-03-26 19:47:52 +01:00
Max Kellermann
114d5982bb oss_mixer: pass default path to config_get_block_string()
Instead of replacing NULL with the default path in the open() method,
pass the default path to config_get_block_string().
2009-03-26 19:47:47 +01:00
Max Kellermann
aec4fe06b5 oss_mixer: make "device" and "control" const
Use config_get_block_string() instead of config_dup_block_string().
2009-03-26 19:46:46 +01:00
Max Kellermann
1fcf09a816 mixer_control: close mixer on failure
When getting or setting the volume fails, the MPD core close the
mixer.  Moved the duplicated code from the mixer plugins.
2009-03-26 19:46:33 +01:00
Max Kellermann
617a4fd2d2 mixer: added flag "open"
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.
2009-03-26 19:43:18 +01:00
David Guibert
2a52d49536 pulse_mixer: keep mixer attached when another pulse sink is closed.
The mixer state is defined as offline only if the associated stream is removed.

Signed-off-by: David Guibert <david.guibert@gmail.com>
2009-03-17 08:40:50 +01:00
David Guibert
0ad56e0f8e pulse_mixer: close
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>
2009-03-17 08:40:50 +01:00
Avuton Olrich
0aee49bdf8 all: Update copyright header.
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.
2009-03-13 11:51:55 -07:00
David Guibert
498ec26f25 pulse_mixer: allow mpd to reconnect to the pulse mixer
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>
2009-03-07 19:55:09 +01:00
Max Kellermann
5ffb2dd88c pulse_mixer: added missing copyright header 2009-03-07 15:59:29 +01:00
Max Kellermann
b1137fe81a pulse_mixer: added GLib log domain
Shorten some log messages, let GLib add the "pulse_mixer" prefix.
2009-03-07 15:59:26 +01:00
Max Kellermann
6069cafda0 pulse: clean up includes
Don't include output_api.h - this is not an output plugin.  Added
missing explicit conf.h and string.h includes.
2009-03-07 15:59:22 +01:00
David Guibert
21bb10f4bf pulse mixer
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]
2009-03-07 15:59:20 +01:00
Max Kellermann
83ce0e5325 mixer_api: replaced method "control()" with "{get,set}_volume()"
The method control() is too complicated, and overengineered.  Replace
it with two trivial functions: get_volume() and set_volume().
2009-02-16 01:39:52 +01:00
Max Kellermann
936449c622 mixer_api: removed struct mixer_data
The mixer plugins should re-use the mixer struct and incorporate it in
their object class.
2009-01-25 17:45:16 +01:00
Max Kellermann
dc575106c2 mixer: merged methods "init" and "configure"
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.
2009-01-25 17:38:12 +01:00
Max Kellermann
db2058a265 mixer: removed mixer_configure_legacy(), AC_MIXER_CONFIGURE
Those have been superseded by the new legacy configuration code.
2009-01-25 17:38:06 +01:00
Max Kellermann
ad8561bfdc mixer: make all mixer_plugin pointers const
The plugin structures must never be modified.
2009-01-25 17:37:52 +01:00
Max Kellermann
899eb5383d mixer: added missing copyright headers 2009-01-25 17:37:50 +01:00
Max Kellermann
3635c93acb conf: allow param==NULL
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.
2009-01-25 16:04:03 +01:00
Max Kellermann
5f77910097 conf: const pointers in block get functions
All config_get_block_*() functions should accept constant config_param
pointers.
2009-01-25 16:03:49 +01:00
Max Kellermann
a531a1e650 conf: added config_get_block_string()
This replaces lots of getBlockParam() invocations.
2009-01-18 19:37:27 +01:00
Max Kellermann
a0603d8897 mixer: don't check for NULL before g_free()
The g_free() function includes a NULL check.  We don't have to do it
twice.
2009-01-18 18:55:51 +01:00
Max Kellermann
4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann
b12b5130c9 mixer: check param==NULL in the alsa and oss mixer code
When MPD starts without audio output configuration, the "param"
variable is NULL.  This triggers a segmentation fault in both mixer
plugins.
2009-01-16 17:11:18 +01:00
Viliam Mateicka
d357f58542 removing mixer_reconfigure memmory leak, fixing configure of alsa and oss mixer (passing parameters) 2009-01-11 17:13:01 +01:00
Viliam Mateicka
11c29cccb3 Introducing mixer api
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
2009-01-10 17:55:38 +01:00
Viliam Mateicka
1a04e57168 renaming mixer.h to mixer_api.h 2009-01-04 19:15:18 +01:00
Max Kellermann
ecb20c5f7e mixer: renamed mix_* options to mixer_*
There is no reason to use the shortcut "mix" instead of "mixer".
2009-01-01 18:36:47 +01:00
Viliam Mateicka
9a70c4d06d Moving mixers to audio outputs 2008-12-31 16:46:41 +01:00