Commit Graph

51 Commits

Author SHA1 Message Date
Max Kellermann bde3d14339 output: consistently lock audio output objects
Always keep the audio_output object locked within the output thread,
unless a plugin method is called.  This fixes several race conditions.
2009-10-29 17:06:40 +01:00
Max Kellermann e53ca368a5 output_plugin: added methods enable() and disable()
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.
2009-10-23 10:55:52 +02:00
Max Kellermann 9526fdbe73 audio_format: wildcards allowed in audio_format configuration
An asterisk means that this attribute should not be enforced, and
stays whatever it used to be.  This way, some configuration values
work like masks.
2009-10-21 23:01:04 +02:00
Max Kellermann 2c05430002 output: convert config_audio_format to an audio_format struct
This allows more sophisticated audio format selection.
2009-10-21 22:37:28 +02:00
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 9cd2129eeb output_init: renamed parameter "error" to "error_r"
It's a double pointer.
2009-10-20 21:26:28 +02:00
Max Kellermann f2ff2409ad Merged release 0.15.3 from branch 'v0.15.x'
Conflicts:

	NEWS
	configure.ac
2009-08-30 09:42:12 +02:00
Max Kellermann fd8aa54a90 output_init: initialize the "pause" flag
Fix stuttering due to uninitialized variable.
2009-08-18 11:32:54 +02:00
Max Kellermann 0275690b5c output: use the software mixer plugin
Do all the software volume stuff inside each output thread, not in the
player thread.  This allows one software mixer per output device, and
also allows the user to configure the mixer type (hardware or
software) for each audio output.

This moves the global "mixer_type" setting into the "audio_output"
section, deprecating the "mixer_enabled" flag.
2009-07-06 22:00:50 +02:00
Max Kellermann 171a9ee291 output_init: moved the "convert" filter at the end
The "convert" filter must be the last filter in the chain.  Ensure
that by doing its initialization at the very end of
audio_output_init().
2009-07-06 21:50:25 +02:00
Max Kellermann 13e725ab09 output_init: merge two local string variables 2009-07-06 21:50:13 +02:00
Max Kellermann f5c2acf1d4 output_init: parse audio format earlier 2009-07-06 21:40:43 +02:00
Max Kellermann e47bdfe8e6 output: attach a filter chain to each audio_output
This patch adds initial filter support for audio outputs.  Each audio
output gets a "filter" attribute, which is used by ao_play_chunk().

The PCM conversion is now performed by convert_filter_plugin.
audio_output.convert_state has been removed.
2009-07-06 10:01:47 +02:00
Max Kellermann d78be1ab49 output_init: moved mixer instantiation to separate function 2009-07-05 18:44:37 +02:00
Max Kellermann e710037760 output_init: added option to disable the hardware mixer
Added the per-device option "mixer_enabled" which allows users to
disable the hardware mixer of an audio output.
2009-04-28 20:33:06 +02:00
Max Kellermann 66a2c5669e output_plugin: replaced output_plugin.get_mixer() with mixer_plugin
The mixer core library is now responsible for creating and managing
the mixer object.  This removes duplicated code from the output
plugins.
2009-03-26 18:23:23 +01:00
Max Kellermann e6c753a474 output: convert audio_output.config_audio_format to boolean
The config_audio_format used to contain the configured audio format,
which is copied to out_audio_format.  Let's convert the former to a
boolean, which indicates whether out_audio_format was already set.
This simplifies some code and saves a few bytes.
2009-03-20 15:47: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
Max Kellermann 3291666b57 output: play from a music_pipe object
Instead of passing individual buffers to audio_output_all_play(), pass
music_chunk objects.  Append all those chunks asynchronously to a
music_pipe instance.  All output threads may then read chunks from
this pipe.  This reduces MPD's internal latency by an order of
magnitude.
2009-03-09 19:25:26 +01:00
Max Kellermann d399d4b63b output_init: removed getBlockParam()
Use config_get_block_string() and manual GError handling instead.
2009-03-01 13:32:42 +01:00
Max Kellermann f298fcf3a6 output_init: return GError on error
Do error handling with GError instead of aborting with g_error().
2009-03-01 13:31:56 +01:00
Max Kellermann cb942eeb45 output_init: moved code to audio_output_detect() 2009-03-01 13:31:32 +01:00
Max Kellermann ec4fd9fd88 output: use GTimer instead of time_t for reopen after failure
time() is not a monotonic timer, and MPD might get confused by clock
skews.  clock_gettime() provides a monotonic clock, but is not
portable to non-POSIX systems (i.e. Windows).  This patch uses GLib's
GTimer API, which aims to be portable.
2009-02-28 20:43:23 +01:00
Max Kellermann a5c09c91c4 output: added option to disable audio outputs by default
The option "enabled" is on by default.  If you specify "enabled no" in
an audio_output section, then this device is disabled by default.
2009-02-28 19:40:39 +01:00
Max Kellermann ec926539a3 output_plugin: report errors with GError
Use GLib's GError library for reporting output device failures.

Note that some init() methods don't clean up properly after a failure,
but that's ok for now, because the MPD core will abort anyway.
2009-02-26 22:04:59 +01:00
Max Kellermann 6aa6def776 output: audio_output_init() returns bool
Return true/false instead of 1/0.
2009-02-25 19:53:56 +01:00
Max Kellermann 9512704055 output: set a GLib log domain 2009-02-25 19:53:38 +01:00
Max Kellermann dcd84c19cd output_plugin: don't pass audio_output object to method init()
audio_output_get_name() has been removed, which was the only function
left in output_api.h.  The output plugin doesn't need the audio_output
object at all, remove the parameter from the init() method.
2009-02-25 18:34:02 +01:00
Max Kellermann 79b50b7d9c output_plugin: added inline wrapper functions
Similar to the decoder plugin API: added wrapper functions to increase
code readability.
2009-02-16 01:38:10 +01:00
Max Kellermann 5090cf6484 audio: replaced parseAudioConfig() with audio_format_parse()
Added audio_format_parse() in a separate library, with a modern
interface: return a GError instead of logging errors.  This allows the
caller to deal with the error.
2009-02-11 18:00:41 +01:00
Max Kellermann 61e3075981 output_api: no CamelCase in struct audio_output
Renamed audio_output struct members.
2009-02-10 21:50:51 +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 4d472c265e conf: no CamelCase, part I
Renamed functions, types, variables.
2009-01-17 20:23:27 +01:00
Max Kellermann 356526457c pcm_convert: return PCM buffer from pcm_convert()
Removed yet another superfluous buffer layer: return the PCM buffer
from pcm_convert() instead of copying PCM data into the
caller-supplied buffer.
2009-01-17 13:11:16 +01:00
Thomas Jansen 36b8968e36 output: migrate from pthread to glib threads 2008-12-28 22:09:42 +01:00
Max Kellermann 7918785c78 output: use GLib instead of log.h/util.h 2008-11-25 17:47:46 +01:00
Max Kellermann 7da0e005f3 output: delay reopen after device failure
When one of several output devices failed, MPD tried to reopen it
quite often, wasting a lot of resources.  This patch adds a delay:
wait 10 seconds before retrying.  This might be changed to exponential
delays later, but for now, it makes the problem go away.
2008-10-29 22:32:50 +01:00
Max Kellermann cf376b4bc8 output: moved audioDeviceStates to audio_output.enabled 2008-10-29 20:49:51 +01:00
Max Kellermann 58c5bee9f0 output: use bool for return values and flags
Don't return 0/-1 on success/error, but true/false.  Instead of int,
use bool for storing flags.
2008-10-29 20:40:27 +01:00
Max Kellermann e6d90d4e83 pcm_utils: added pcm_convert_init()
Instead of manually calling memset(0) on the pcm_convert_state struct,
client code should use a library function from pcm_utils.c.  This way,
we can change the semantics of the struct easily.
2008-10-21 22:53:16 +02:00
Max Kellermann fb416964d6 pcm_utils: renamed ConvState to struct pcm_convert_state
No CamelCase, and a struct instead of a typedef.
2008-10-21 21:59:43 +02:00
Max Kellermann acc4a0ba2d output: make "struct audio_output" opaque for output plugins
We have eliminated direct accesses to the audio_output struct from
the all output plugins.  Make it opaque for them, and move its real
declaration to output_internal.h, similar to decoder_internal.h.

Pass the opaque structure to plugin.init() only, which will return the
plugin's data pointer on success, and NULL on failure.  This data
pointer will be passed to all other methods instead of the
audio_output struct.
2008-09-24 07:20:55 +02:00
Max Kellermann 3cae6856b8 output: pass audio_format to plugin.init() and plugin.open()
Pass the globally configured audio_format as a const pointer to
plugin.init().  plugin.open() gets a writable pointer which contains
the audio_format requested by the plugin.  Its initial value is either
the configured audio_format or the input file's audio_format.
2008-09-24 07:20:36 +02:00
Max Kellermann d32f49a90b output: one thread per audio output
To keep I/O nastiness and latencies away from the core, move the audio
output code to a separate thread, one per output.  The thread is
created on demand, and currently runs until mpd exits.
2008-09-24 07:20:26 +02:00
Max Kellermann 420c879dd6 output: don't initialize inAudioFormat, outAudioFormat
As long as the device isn't open, both attributes are not used.  Since
they will both be initialized in audio_output_open(), we do not need
the initialization in audio_output_init().
2008-09-11 07:50:11 +02:00
Max Kellermann 3aa4564b56 output: removed audio_output.sameInAndOutFormats
Eliminate sameInAndOutFormats and check with audio_format_equals()
each time it this information is needed.  Another 4 bytes saved.
2008-09-11 07:48:30 +02:00
Max Kellermann 56cf54e880 output: removed audio_output.convertAudioFormat
Instead of checking convertAudioFormat, we can simply check if
reqAudioFormat is defined.  This saves 4 bytes in the struct.
2008-09-11 07:47:28 +02:00
Max Kellermann 7f1cccb3ea audio: replaced copyAudioFormat() with simple assignment
The "!src" check in copyAudioFormat() used to hide bugs - one should
never pass NULL to it.  There is one caller which might pass NULL, add
a check in this caller.

Instead of doing mempcy(), we can simply assign the structures, which
looks more natural.
2008-09-09 10:04:42 +02:00
Max Kellermann f9316fbbbe output: renamed the functions in output_control.c
Getting rid of CamcelCase, again.
2008-09-09 10:03:24 +02:00