aboutsummaryrefslogtreecommitdiffstats
path: root/src/output_control.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-24 07:23:19 +0200
committerMax Kellermann <max@duempel.org>2008-09-24 07:23:19 +0200
commit2b782b82eaadeff36fa230ce3ac30893eb6581e3 (patch)
tree6d53007dd37083bc93647e0c68da705506edf412 /src/output_control.c
parent6bbea44e91dd954a32915f824eaa28dfbf4d97d7 (diff)
downloadmpd-2b782b82eaadeff36fa230ce3ac30893eb6581e3.tar.gz
mpd-2b782b82eaadeff36fa230ce3ac30893eb6581e3.tar.xz
mpd-2b782b82eaadeff36fa230ce3ac30893eb6581e3.zip
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.
Diffstat (limited to 'src/output_control.c')
-rw-r--r--src/output_control.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/output_control.c b/src/output_control.c
index 34e51aa41..3be1f6cd6 100644
--- a/src/output_control.c
+++ b/src/output_control.c
@@ -41,6 +41,14 @@ static void ao_command(struct audio_output *ao, enum audio_output_command cmd)
ao_command_wait(ao);
}
+static void ao_command_async(struct audio_output *ao,
+ enum audio_output_command cmd)
+{
+ assert(ao->command == AO_COMMAND_NONE);
+ ao->command = cmd;
+ notify_signal(&ao->notify);
+}
+
int audio_output_open(struct audio_output *audioOutput,
const struct audio_format *audioFormat)
{
@@ -78,22 +86,20 @@ int audio_output_open(struct audio_output *audioOutput,
return ret;
}
-int audio_output_play(struct audio_output *audioOutput,
- const char *playChunk, size_t size)
+void audio_output_play(struct audio_output *audioOutput,
+ const char *playChunk, size_t size)
{
if (!audioOutput->open)
- return -1;
+ return;
audioOutput->args.play.data = playChunk;
audioOutput->args.play.size = size;
- ao_command(audioOutput, AO_COMMAND_PLAY);
-
- return audioOutput->result;
+ ao_command_async(audioOutput, AO_COMMAND_PLAY);
}
void audio_output_cancel(struct audio_output *audioOutput)
{
- ao_command(audioOutput, AO_COMMAND_CANCEL);
+ ao_command_async(audioOutput, AO_COMMAND_CANCEL);
}
void audio_output_close(struct audio_output *audioOutput)
@@ -120,5 +126,5 @@ void audio_output_send_tag(struct audio_output *audioOutput,
return;
audioOutput->args.tag = tag;
- ao_command(audioOutput, AO_COMMAND_SEND_TAG);
+ ao_command_async(audioOutput, AO_COMMAND_SEND_TAG);
}