aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-11-02output: don't allow length==0Max Kellermann1-0/+1
Nobody should call playAudio() with an empty chunk. Add some assertions on that.
2008-10-29output: removed audio_output.resultMax Kellermann1-5/+3
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-29output: delay reopen after device failureMax Kellermann1-0/+1
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-29output: moved code to audio_output_update()Max Kellermann1-8/+2
Moved code from syncAudioDeviceStates() to audio_output_update().
2008-10-29output: always call cancel() before stop()Max Kellermann1-10/+1
Stopping an audio output device without cancelling its buffer doesn't make sense. Combine the two operations, which saves several cancel calls.
2008-10-29output: moved audioDeviceStates to audio_output.enabledMax Kellermann1-20/+6
2008-10-29output: use bool for return values and flagsMax Kellermann1-14/+14
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
2008-10-29audio: call closeAudioDevice() on errorMax Kellermann1-5/+2
Instead of implementing another loop which calls audio_output_close() on all configured devices, simply call closeAudioDevice().
2008-10-29audio: removed variable "audioOpened"Max Kellermann1-9/+1
This variable is never read, and can be removed.
2008-10-28utils: use g_str_has_prefix() instead of prefixcmp()Max Kellermann1-1/+3
Remove duplicated code from MPD.
2008-10-23audio: allow 24 and 8 bit outputMax Kellermann1-4/+2
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-23output_buffer: don't split framesMax Kellermann1-0/+3
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-14command: added command "idle"Max Kellermann1-0/+3
"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-13audio: don't clear input_audio_format on openAudioDevice(NULL)Max Kellermann1-3/+1
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-12audio: renamed the audio_format variablesMax Kellermann1-17/+13
Renamed audio_configFormat to configured_audio_format. Renamed audio_buffer.format to input_audio_format. Simplified its initialization in openAudioDevice().
2008-10-12audio: removed enum ad_stateMax Kellermann1-22/+14
All what's left from ad_state is a simple boolean flag (ENABLE / DISABLE). Convert it to a C99 bool.
2008-10-12audio: removed audio_buffer.bufferMax Kellermann1-69/+2
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-10audio_format: added audio_format_frame_size()Max Kellermann1-1/+1
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-10audio_format: renamed sampleRate to sample_rateMax Kellermann1-5/+5
The last bit of CamelCase in audio_format.h. Additionally, rename a bunch of local variables.
2008-10-10audio_format: unsigned integersMax Kellermann1-4/+4
"bits" and "channels" cannot be negative.
2008-10-08use the "bool" data type instead of "int"Max Kellermann1-1/+2
"bool" should be used in C99 programs for boolean values.
2008-09-29audio_output: added method pause()Max Kellermann1-0/+13
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-29Switch to C99 types (retaining compat with old compilers)Eric Wong1-3/+3
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-28output: fix the "outputenabled" valueMax Kellermann1-1/+1
Patch 9a5b5998 broke the "outputenabled" value of the "outputs" response. Make it print "1" if the output is enabled, "0" otherwise.
2008-09-26audio_output: workaround for deadlockMax Kellermann1-2/+4
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-24output: removed DEVICE_ON, DEVICE_OFFMax Kellermann1-29/+14
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-24output: semi-asynchronous playbackMax Kellermann1-13/+63
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-24output: call send_tag() only if device is onMax Kellermann1-3/+3
Why send tags to a device which isn't enabled?
2008-09-24output: make "struct audio_output" opaque for output pluginsMax Kellermann1-0/+1
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-23start using prefixcmp()Eric Wong1-2/+1
LOC reduction and less noise makes things easier for tired old folks to follow.
2008-09-10audio: removed commented codeMax Kellermann1-12/+0
We have git..
2008-09-10audio: added assertionsMax Kellermann1-0/+5
2008-09-10audio: make audio_configFormat a static variableMax Kellermann1-8/+5
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-10audio: don't free uninitialized audio_bufferMax Kellermann1-5/+6
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-10audio: added function audio_buffer_resize()Max Kellermann1-4/+22
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-10audio: moved static variables into struct audio_bufferMax Kellermann1-26/+30
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-10audio: don't allow isCurrentAudioFormat(NULL)Max Kellermann1-3/+5
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-10audio: removed isAudioDeviceOpen()Max Kellermann1-5/+0
The function isAudioDeviceOpen() is never used.
2008-09-10audio_format: added audio_format_clear() and audio_format_defined()Max Kellermann1-1/+1
audio_format_clear() sets an audio_format struct to an cleared (undefined) state, which is both faster and smaller than memset(0). audio_format_defined() checks if the audio_format struct actually has a defined value (i.e. non-zero). Both can be used to avoid pointers to audio_format, replacing the "NULL" value with an "undefined" audio_format.
2008-09-09audio: moved cmpAudioFormat() to audio_format.hMax Kellermann1-15/+2
Rename it to audio_format_equals() and return "true" if they are equal.
2008-09-09audio: replaced copyAudioFormat() with simple assignmentMax Kellermann1-13/+5
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-09output: renamed the functions in output_control.cMax Kellermann1-12/+12
Getting rid of CamcelCase, again.
2008-09-09output: moved code from audioOutput.c to output_control.cMax Kellermann1-1/+1
Similar to decoder_control.c, output_control.c will provide functions for controlling the output thread (which will be implemented later).
2008-09-08output: static audio_output_plugin list as arrayMax Kellermann1-17/+0
Instead of having to register each output plugin, store them statically in an array. This eliminates the need for the List library here, and saves some small allocations during startup.
2008-09-07output: renamed typedef AudioOutput to struct audio_outputMax Kellermann1-4/+5
Also rename AudioOutputPlugin to struct audio_output_plugin, and use forward declarations to reduce include dependencies.
2008-09-07output: added output_api.hMax Kellermann1-0/+1
Just like decoder_api.h, output_api.h provides the audio output API which is used by the plugins.
2008-09-07audio_format: converted typedef AudioFormat to struct audio_formatMax Kellermann1-12/+13
Get rid of CamelCase, and don't use a typedef, so we can forward-declare it, and unclutter the include dependencies.
2008-09-07audio: don't pass "fd" to printAudioDevices()Max Kellermann1-7/+9
Pass the client struct instead.
2008-09-07audio: don't pass "fd" to {en,dis}ableAudioDevice()Max Kellermann1-12/+5
No protocol code in the audio output library.
2008-08-29tag: renamed MpdTag and MpdTagItem to struct tag, struct mpd_tag_itemMax Kellermann1-1/+1
Getting rid of CamelCase; not having typedefs also allows us to forward-declare the structures.