aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2010-11-04output_thread: fix assertion failure due to race condition in OPENMax Kellermann1-1/+9
Change the assertion on "fail_timer==NULL" in OPEN to a runtime check. This assertion crashed when the output thread failed while the player thread was calling audio_output_open().
2010-11-04output_internal: protect attribute "fail_timer" with mutexMax Kellermann1-0/+5
2010-08-19output_thread: fix race condition after CANCEL commandMax Kellermann1-0/+10
Clear the notification before finishing the CANCEL command, so the notify_wait() after that will always wait for the right notification, sent by audio_output_all_cancel().
2009-10-21output_thread: check again if output is open on PAUSEMax Kellermann1-0/+9
Basically the same as the 0.15.5 patch "check again if output is open on CANCEL". Same race condition, same fix.
2009-10-16output_thread: check again if output is open on CANCELMax Kellermann1-1/+2
When the player thread unpauses, it sends CANCEL to the output thread, after having checked that the output is still open. Problem is when the output thread closes the device before it can process the CANCEL command - race condition. This patch adds another "open" check inside the output thread.
2009-08-14output: fixed shout stuck pause bugMax Kellermann1-0/+3
Explicitly make the output thread leave the ao_pause() loop. This patch is a workaround, and the "pause" flag is not managed in a thread-safe way, but that's good enough for now.
2009-06-29output_thread: don't play next chunk after command==PAUSEMax Kellermann1-1/+5
When the PAUSE loop ends, re-check the next command before calling ao_play() again.
2009-03-26output_all: synchronize playback with player_control.notifyMax Kellermann1-1/+2
This patch fixes a longer delay when moving around songs in the playlist. The main thread wants to enqueue a new "next" song into the player thread, but the player thread is waiting inside audio_output_all_wait() for the output threads. Use player_control.notify there, so audio_output_all_wait() gets woken up by the main thread, too.
2009-03-25output_all: synchronize playback with a notify objectMax Kellermann1-0/+2
Use audio_output_client_notify instead of g_usleep(1ms) in audio_output_all_wait() to synchronize with the output_thread. Signal the audio_output_client_notify object in ao_play().
2009-03-25output: protect audio_output.open with the mutexMax Kellermann1-2/+4
There was a deadlock between the output thread and the player thread: when the output thread failed (and closed itself) while the player thread worked with the audio_output object, MPD could crash.
2009-03-13all: Update copyright header.Avuton Olrich1-6/+7
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-10output_thread: check commands while playingMax Kellermann1-1/+1
Check audio_output.command after each sub-chunk has been played. It discards the rest of the chunk, but since all commands make the device stop anyway, this is not a problem, but part of the improvement. This improves the latency of audio output commands.
2009-03-09output: play from a music_pipe objectMax Kellermann1-17/+80
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-09output_thread: wait 10 seconds before reopening after play failureMax Kellermann1-0/+4
This is similar to the MPD 0.14 patch "wait 10 seconds before reopening a failed device", which only covered open() failures. This patch adds the same feature for play().
2009-03-08output_thread: print "closed" debug messageMax Kellermann1-0/+2
2009-03-01output_thread: log audio format in a debug messageMax Kellermann1-0/+16
To aid debugging, print the audio format of the output plugin in a debug message, and print information about PCM conversion.
2009-02-28output: use GTimer instead of time_t for reopen after failureMax Kellermann1-7/+2
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-26output_plugin: report errors with GErrorMax Kellermann1-3/+18
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-26output_thread: use the right audio_format in assert()Max Kellermann1-1/+1
ao_play() gets PCM data in the in_audio_format, and converts it to out_audio_format. Comparing the input data with out_audio_format is wrong. prefixed with "STG:" will be automatically removed. STG: Trailing empty lines will be automatically removed. STG: vi: set textwidth=75 filetype=diff nobackup:
2009-02-25output: set a GLib log domainMax Kellermann1-0/+4
2009-02-23output_api: play() returns a lengthMax Kellermann1-5/+17
The old API required an output plugin to not return until all data passed to the play() method is consumed. Some output plugins have to loop to fulfill that requirement, and may block during that. Simplify these, by letting them consume only part of the buffer: make play() return the length of the consumed data.
2009-02-16output_plugin: added inline wrapper functionsMax Kellermann1-28/+20
Similar to the decoder plugin API: added wrapper functions to increase code readability.
2009-02-10output_thread: moved code to ao_close()Max Kellermann1-12/+14
Merge some duplicate code into one function.
2009-02-10output_thread: leave the pause loop on failureMax Kellermann1-0/+1
When the pause() method fails, leave the pause loop, because calling pause() on a closed device is not allowed.
2009-02-10output_thread: consistently (de)initialize pcm_convert_stateMax Kellermann1-3/+5
Fix a memory leak: it was not guaranteed that pcm_convert_deinit() was called for each pcm_convert_init(). This patch always (de)initializes the pcm_convert library when the audio_output.open flag is flipped.
2009-02-10output_api: no CamelCase in struct audio_outputMax Kellermann1-8/+8
Renamed audio_output struct members.
2009-01-30output_api: moved the command check out of method pause()Max Kellermann1-1/+11
Move the "while" loop which checks for commands to the caller ao_pause(). This simplifies the pause() method, and lets us remove audio_output_is_pending().
2009-01-17pcm_convert: return PCM buffer from pcm_convert()Max Kellermann1-25/+4
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-07output: join the output thread after sending the KILL commandMax Kellermann1-1/+1
Be sure that the output thread has quite before we start destructing the output object.
2009-01-07pcm: added pcm_convert_deinit(), pcm_resample_deinit()Max Kellermann1-0/+4
Free memory allocated by libsamplerate when the output or the decoder is closed.
2009-01-04initialize GError pointersMax Kellermann1-1/+1
GLib mandates that you initialize all GError objects with NULL prior to passing it.
2008-12-28output: migrate from pthread to glib threadsThomas Jansen1-6/+4
2008-12-24pcm_utils: check pcm_convert()==0Max Kellermann1-1/+9
It is illegal to pass an empty audio buffer around. pcm_resample() sometimes seems to result in 0 samples, maybe related to libsamplerate. To work around that problem, add special checks after both pcm_convert() invocations. Removed the pcm_resample()==0 checks from pcm_convert().
2008-11-25output: use GLib instead of log.h/util.hMax Kellermann1-3/+5
2008-11-02output: don't allow length==0Max Kellermann1-0/+2
Nobody should call playAudio() with an empty chunk. Add some assertions on that.
2008-10-29output: removed audio_output.resultMax Kellermann1-5/+7
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/+8
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: always call cancel() before stop()Max Kellermann1-0/+4
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: close device on play errorMax Kellermann1-0/+5
When an output plugin fails to play a chunk, close it. This replaces various manual close() calls in nearly all plugins.
2008-10-29output: use bool for return values and flagsMax Kellermann1-4/+4
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
2008-10-21pcm_utils: no CamelCaseMax Kellermann1-8/+8
Renamed all functions which were still in CamelCase.
2008-10-08don't include os_compat.hMax Kellermann1-0/+2
When there are standardized headers, use these instead of the bloated os_compat.h.
2008-09-29audio_output: added method pause()Max Kellermann1-0/+18
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-26notify: protect notify->pending with the mutexMax Kellermann1-2/+0
There was a known deadlocking bug in the notify library: when the other thread set notify->pending after the according check in notify_wait(), the latter thread was deadlocked. Resolve this by synchronizing all accesses to notify->pending with the notify object's mutex. Since notify_signal_sync() was never used, we can remove it. As a consequence, we don't need notify_enter() and notify_leave() anymore; eliminate them, too.
2008-09-24output: make "struct audio_output" opaque for output pluginsMax Kellermann1-5/+7
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-24output: set audio_output->open=1 in audio_output_task()Max Kellermann1-1/+7
Since the output plugin returns a value indicating success or error, we can have the output core code assign the "open" flag.
2008-09-24output: pass audio_format to plugin.init() and plugin.open()Max Kellermann1-1/+1
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-24output: one thread per audio outputMax Kellermann1-0/+121
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.