aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_thread.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* output_thread: check command before g_cond_wait()Max Kellermann2009-11-021-1/+2
| | | | | | | After CANCEL, call g_cond_wait() only if the new command is still NONE. Problem is that ao_command_finished() has to unlock the audio_output object, and in the meantime, the player thread might have submitted a new command.
* Merge branch 'v0.15.x'Max Kellermann2009-10-311-0/+9
|\ | | | | | | | | | | | | | | Conflicts: NEWS configure.ac src/decoder/ffmpeg_plugin.c src/update.c
| * output_thread: check again if output is open on PAUSEMax Kellermann2009-10-211-0/+9
| | | | | | | | | | Basically the same as the 0.15.5 patch "check again if output is open on CANCEL". Same race condition, same fix.
* | player_control: protect command, state, error with a mutexMax Kellermann2009-10-311-1/+1
| | | | | | | | | | | | Use GMutex/GCond instead of the notify library. Manually lock the player_control object before accessing the protected attributes. Use the GCond object to notify the player thread and the main thread.
* | output_thread: return bool from ao_play()Max Kellermann2009-10-291-4/+22
| | | | | | | | | | | | Return false when there was no chunk in the pipe. If the function returns true, then audio_output_task() will not wait for a notify from the player thread. This fixes a race condition.
* | output: consistently lock audio output objectsMax Kellermann2009-10-291-16/+39
| | | | | | | | | | Always keep the audio_output object locked within the output thread, unless a plugin method is called. This fixes several race conditions.
* | output_plugin: added method "drain"Max Kellermann2009-10-291-11/+13
| | | | | | | | | | | | | | drain() is the opposite of cancel(): it waits until all data in the buffer has finished playing. Instead of implicitly draining in the close() method like the ALSA plugin has been doing it forever, let the output thread decide whether to drain or to cancel.
* | output_thread: removed redundant filter_close() callMax Kellermann2009-10-291-4/+0
| | | | | | | | Don't call filter_close() right after ao_close().
* | output_plugin: added methods enable() and disable()Max Kellermann2009-10-231-0/+50
| | | | | | | | | | | | | | 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.
* | audio_format: wildcards allowed in audio_format configurationMax Kellermann2009-10-211-5/+6
| | | | | | | | | | | | 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.
* | output: convert config_audio_format to an audio_format structMax Kellermann2009-10-211-2/+4
| | | | | | | | This allows more sophisticated audio format selection.
* | Merged release 0.15.5 from branch 'v0.15.x'Max Kellermann2009-10-181-1/+2
|\| | | | | | | | | | | | | | | Conflicts: NEWS configure.ac src/decoder/flac_plugin.c src/update.c
| * output_thread: check again if output is open on CANCELMax Kellermann2009-10-161-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.
* | Merged release 0.15.2 from branch 'v0.15.x'Max Kellermann2009-08-151-0/+3
|\| | | | | | | | | | | | | Conflicts: NEWS configure.ac
| * output: fixed shout stuck pause bugMax Kellermann2009-08-141-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.
* | Add reverse_endian field to struct audio_format and handle conversionDavid Woodhouse2009-07-191-4/+6
| |
* | Merged release 0.15.1 from branch 'v0.15.x'Max Kellermann2009-07-161-1/+5
|\|
| * output_thread: don't play next chunk after command==PAUSEMax Kellermann2009-06-291-1/+5
| | | | | | | | | | When the PAUSE loop ends, re-check the next command before calling ao_play() again.
* | output: attach a filter chain to each audio_outputMax Kellermann2009-07-061-15/+77
| | | | | | | | | | | | | | | | 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.
* | output: added command REOPENMax Kellermann2009-07-061-0/+25
| | | | | | | | | | REOPEN is called when the input audio format changes. The output thread may be reconfigure the PCM converter.
* | output_thread: moved OPEN handler to ao_open()Max Kellermann2009-07-061-43/+48
|/
* output_all: synchronize playback with player_control.notifyMax Kellermann2009-03-261-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.
* output_all: synchronize playback with a notify objectMax Kellermann2009-03-251-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().
* output: protect audio_output.open with the mutexMax Kellermann2009-03-251-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.
* all: Update copyright header.Avuton Olrich2009-03-131-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.
* output_thread: check commands while playingMax Kellermann2009-03-101-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.
* output: play from a music_pipe objectMax Kellermann2009-03-091-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.
* output_thread: wait 10 seconds before reopening after play failureMax Kellermann2009-03-091-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().
* output_thread: print "closed" debug messageMax Kellermann2009-03-081-0/+2
|
* output_thread: log audio format in a debug messageMax Kellermann2009-03-011-0/+16
| | | | | To aid debugging, print the audio format of the output plugin in a debug message, and print information about PCM conversion.
* output: use GTimer instead of time_t for reopen after failureMax Kellermann2009-02-281-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.
* output_plugin: report errors with GErrorMax Kellermann2009-02-261-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.
* output_thread: use the right audio_format in assert()Max Kellermann2009-02-261-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:
* output: set a GLib log domainMax Kellermann2009-02-251-0/+4
|
* output_api: play() returns a lengthMax Kellermann2009-02-231-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.
* output_plugin: added inline wrapper functionsMax Kellermann2009-02-161-28/+20
| | | | | Similar to the decoder plugin API: added wrapper functions to increase code readability.
* output_thread: moved code to ao_close()Max Kellermann2009-02-101-12/+14
| | | | Merge some duplicate code into one function.
* output_thread: leave the pause loop on failureMax Kellermann2009-02-101-0/+1
| | | | | When the pause() method fails, leave the pause loop, because calling pause() on a closed device is not allowed.
* output_thread: consistently (de)initialize pcm_convert_stateMax Kellermann2009-02-101-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.
* output_api: no CamelCase in struct audio_outputMax Kellermann2009-02-101-8/+8
| | | | Renamed audio_output struct members.
* output_api: moved the command check out of method pause()Max Kellermann2009-01-301-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().
* pcm_convert: return PCM buffer from pcm_convert()Max Kellermann2009-01-171-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.
* output: join the output thread after sending the KILL commandMax Kellermann2009-01-071-1/+1
| | | | | Be sure that the output thread has quite before we start destructing the output object.
* pcm: added pcm_convert_deinit(), pcm_resample_deinit()Max Kellermann2009-01-071-0/+4
| | | | | Free memory allocated by libsamplerate when the output or the decoder is closed.
* initialize GError pointersMax Kellermann2009-01-041-1/+1
| | | | | GLib mandates that you initialize all GError objects with NULL prior to passing it.
* output: migrate from pthread to glib threadsThomas Jansen2008-12-281-6/+4
|
* pcm_utils: check pcm_convert()==0Max Kellermann2008-12-241-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().
* output: use GLib instead of log.h/util.hMax Kellermann2008-11-251-3/+5
|
* output: don't allow length==0Max Kellermann2008-11-021-0/+2
| | | | | Nobody should call playAudio() with an empty chunk. Add some assertions on that.
* output: removed audio_output.resultMax Kellermann2008-10-291-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.