Commit Graph

162 Commits

Author SHA1 Message Date
Max Kellermann a45922cd66 use g_free() instead of free()
On some platforms, g_free() must be used for memory allocated by
GLib.  This patch intends to correct a lot of occurrences, but is
probably not complete.
2009-01-25 18:47:21 +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 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
Viliam Mateicka 1a04e57168 renaming mixer.h to mixer_api.h 2009-01-04 19:15:18 +01:00
Max Kellermann 6ce06a4863 audio: use GLib instead of utils.h 2009-01-03 13:36:20 +01:00
Viliam Mateicka 9a70c4d06d Moving mixers to audio outputs 2008-12-31 16:46:41 +01:00
Viliam Mateicka dd9af72a74 exporting functions 2008-12-31 15:10:53 +01:00
Max Kellermann 95b3430f52 removed os_compat.h
Only include headers which are really needed.  os_compat.h aimed to
make MPD easily portable, but was never actually made portable.
2008-12-29 17:28:32 +01:00
Max Kellermann 859aac7242 utils: removed myFgets()
Replaced myFgets() with fgets() + g_strchomp().
2008-12-28 19:54:49 +01:00
Max Kellermann e8c44782d0 output_control: no static "notify" initialization
Don't use NOTIFY_INITIALIZER to initialize audio_output_client_notify.
2008-12-27 20:53:52 +01:00
Max Kellermann 7918785c78 output: use GLib instead of log.h/util.h 2008-11-25 17:47:46 +01:00
Max Kellermann 79d70f124d output: don't allow length==0
Nobody should call playAudio() with an empty chunk.  Add some
assertions on that.
2008-11-02 20:16:56 +01:00
Max Kellermann f8722913cf output: removed audio_output.result
Since open() and play() close the device on error, we can simply check
audio_output.open instead of audio_output.result after a call.
2008-10-29 22:34:37 +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 0eae1c55ad output: moved code to audio_output_update()
Moved code from syncAudioDeviceStates() to audio_output_update().
2008-10-29 22:17:44 +01:00
Max Kellermann 678314534a output: always call cancel() before stop()
Stopping an audio output device without cancelling its buffer doesn't
make sense.  Combine the two operations, which saves several cancel
calls.
2008-10-29 22:17:42 +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 03390d8be1 audio: call closeAudioDevice() on error
Instead of implementing another loop which calls audio_output_close()
on all configured devices, simply call closeAudioDevice().
2008-10-29 20:39:56 +01:00
Max Kellermann 030238bb10 audio: removed variable "audioOpened"
This variable is never read, and can be removed.
2008-10-29 20:39:48 +01:00
Max Kellermann 016d996131 utils: use g_str_has_prefix() instead of prefixcmp()
Remove duplicated code from MPD.
2008-10-28 20:33:56 +01:00
Max Kellermann 80603cf6f1 audio: allow 24 and 8 bit output
I added 24 bit support a while ago, but it wasn't possible to force 24
bit output.  Add 24 and 8 bit to the list of allowed sample sizes.
Although 8 bit audio isn't as widely used as 24 bit, there is no
reason to exclude it.
2008-10-23 16:57:58 +02:00
Max Kellermann 980f2ca56d output_buffer: don't split frames
Splitting a frame between two buffer chunks causes distortion in the
output.  MPD used to assume that the chunk size 1020 would never cause
splitted frames, but that isn't the case for 24 bit stereo (127.5
frames), and even less for files with even more channels.
2008-10-23 16:48:49 +02:00
Max Kellermann a3e3d2c950 command: added command "idle"
"idle" waits until something noteworthy happens on the server,
e.g. song change, playlist modified, database updated.  This allows
clients to keep up to date without polling.
2008-10-14 22:38:14 +02:00
Max Kellermann 07c9b62764 audio: don't clear input_audio_format on openAudioDevice(NULL)
Commit 80a2c937 broke resume after pause: it cleared the
input_audio_format when it attempted to simplify a complicated
expression.  Don't clear it, just assign input_audio_format if a new
format was specified.
2008-10-13 14:31:18 +02:00
Max Kellermann 80a2c937c4 audio: renamed the audio_format variables
Renamed audio_configFormat to configured_audio_format.  Renamed
audio_buffer.format to input_audio_format.  Simplified its
initialization in openAudioDevice().
2008-10-12 01:00:00 +02:00
Max Kellermann 336b193097 audio: removed enum ad_state
All what's left from ad_state is a simple boolean flag (ENABLE /
DISABLE).  Convert it to a C99 bool.
2008-10-12 00:48:59 +02:00
Max Kellermann c297c8555f audio: removed audio_buffer.buffer
audio.c maintained one of MPD's many layers of audio buffers.  It was
without any benefit, since playAudio() can simply send the source
buffer directly to the audio output plugin.
2008-10-12 00:42:33 +02:00
Max Kellermann 96155a3376 audio_format: added audio_format_frame_size()
A frame contains one sample per channel, thus it is sample_size *
channels.  This patch includes some cleanup for various locations
where the sample size for 24 bit audio was still 3 bytes (instead of
4).
2008-10-10 14:41:37 +02:00
Max Kellermann de2cb3f375 audio_format: renamed sampleRate to sample_rate
The last bit of CamelCase in audio_format.h.  Additionally, rename a
bunch of local variables.
2008-10-10 14:40:54 +02:00
Max Kellermann 6101dc6c76 audio_format: unsigned integers
"bits" and "channels" cannot be negative.
2008-10-10 14:03:33 +02:00
Max Kellermann b084bc28ed use the "bool" data type instead of "int"
"bool" should be used in C99 programs for boolean values.
2008-10-08 11:03:39 +02:00
Max Kellermann 6e21e24cae audio_output: added method pause()
pause() puts the audio output into pause mode: if supported, it may
perform a special action, which keeps the device open, but does not
play anything.  Output plugins like "shout" might want to play silence
during pause, so their clients won't be disconnected.  Plugins which
do not support pausing will simply be closed, and have to be reopened
when unpaused.

This pach includes an implementation for the shout plugin, which
sends silence chunks.
2008-09-29 16:43:55 +02:00
Eric Wong 0352766dca Switch to C99 types (retaining compat with old compilers)
Seeing the "mpd_" prefix _everywhere_ is mind-numbing as the
mind needs to retrain itself to skip over the first 4 tokens of
a type to get to its meaning.  So avoid having extra characters
on my terminal to make it easier to follow code at 2:30 am in
the morning.

Please report any new issues you may come across on Free
toolchains.  I realize how difficult it can be to build/maintain
cross-compiling toolchains and I have no intention of forcing
people to upgrade their toolchains to build mpd.

Tested with gcc 2.95.4 and and gcc 4.3.1 on x86-32.
2008-09-29 13:29:33 +02:00
Max Kellermann 75cba9343e output: fix the "outputenabled" value
Patch 9a5b5998 broke the "outputenabled" value of the "outputs"
response.  Make it print "1" if the output is enabled, "0" otherwise.
2008-09-28 18:34:10 +02:00
Max Kellermann e2a12deead audio_output: workaround for deadlock
During debugging, I found a deadlock between flushAudioBuffer() and
the audio_output_task(): audio_output_task() didn't notice that there
is a command, and flushAudioBuffer() waited forever in notify_wait().
I am not sure yet what is the real cause; work around this for now by
waking up non-finished audio outputs in every iteration.
2008-09-26 07:12:29 +02:00
Max Kellermann 9a5b599883 output: removed DEVICE_ON, DEVICE_OFF
To check whether a device is really on or off, we should rather check
audio_output.open, instead of managing another variable.  Wrap
audio_output.open in the inline function audio_output_is_open() and
use it instead of DEVICE_ON and DEVICE_OFF.
2008-09-24 07:25:07 +02:00
Max Kellermann 2b782b82ea output: semi-asynchronous playback
Send an output buffer to all output plugins at the same time, instead
of waiting for each of them separately.  Make several functions
non-blocking, and introduce the new function audio_output_wait_all()
to synchronize with all audio output threads.
2008-09-24 07:23:19 +02:00
Max Kellermann 6bbea44e91 output: call send_tag() only if device is on
Why send tags to a device which isn't enabled?
2008-09-24 07:21:58 +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
Eric Wong 27fad52c6b start using prefixcmp()
LOC reduction and less noise makes things easier for
tired old folks to follow.
2008-09-23 20:48:12 +02:00
Max Kellermann a751011e8c audio: removed commented code
We have git..
2008-09-10 11:47:28 +02:00
Max Kellermann 52ed06cbd8 audio: added assertions 2008-09-10 11:46:54 +02:00
Max Kellermann 688298e265 audio: make audio_configFormat a static variable
Save one allocation, since the whole audio_format struct is nearly the
same size as the pointer to it.  Check audio_format_defined(af)
instead of af!=NULL.
2008-09-10 11:44:06 +02:00
Max Kellermann 5d0a8ce3af audio: don't free uninitialized audio_buffer
free(NULL) isn't explicitly forbidden, but isn't exactly good style.
Check the rare case that the audio buffer isn't initialized yet in
closeAudioDevice().  In this case, we also don't have to call
flushAudioBuffer().
2008-09-10 11:44:02 +02:00
Max Kellermann 8d1801c59d audio: added function audio_buffer_resize()
To make openAudioDevice() smaller and more readable, move code to a
static function.  Also don't use realloc(), since the old value of the
buffer isn't needed anymore, saving a memcpy().
2008-09-10 11:43:56 +02:00
Max Kellermann cdbb9627a7 audio: moved static variables into struct audio_buffer
There are too many static variables in audio.c - organize all
properties of the audio buffer in a struct.  The current audio format
is also a property of the buffer, since it describes the buffer's
data format.
2008-09-10 11:43:49 +02:00
Max Kellermann 9f16a34d76 audio: don't allow isCurrentAudioFormat(NULL)
Passing NULL to this function doesn't make sense, and complicates its
implementation.  The one caller which might pass NULL should rather
check this.
2008-09-10 11:43:40 +02:00
Max Kellermann a53047af7d audio: removed isAudioDeviceOpen()
The function isAudioDeviceOpen() is never used.
2008-09-10 11:43:29 +02:00