diff options
author | Max Kellermann <max@duempel.org> | 2008-09-29 16:43:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-29 16:43:55 +0200 |
commit | 6e21e24caed1a9497e876e4b89b12687aa73d6ad (patch) | |
tree | dd1fe746cdd61eafc82117421cf3633e014a9bef /src/audioOutputs/audioOutput_shout.c | |
parent | c13e8b5146993999a87373a98b5a3da4b6cf599a (diff) | |
download | mpd-6e21e24caed1a9497e876e4b89b12687aa73d6ad.tar.gz mpd-6e21e24caed1a9497e876e4b89b12687aa73d6ad.tar.xz mpd-6e21e24caed1a9497e876e4b89b12687aa73d6ad.zip |
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.
Diffstat (limited to 'src/audioOutputs/audioOutput_shout.c')
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index b55c06cc9..6b59044d8 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -87,7 +87,7 @@ static void free_shout_data(struct shout_data *sd) } \ } -static void *my_shout_init_driver(mpd_unused struct audio_output *audio_output, +static void *my_shout_init_driver(struct audio_output *audio_output, const struct audio_format *audio_format, ConfigParam *param) { @@ -104,6 +104,7 @@ static void *my_shout_init_driver(mpd_unused struct audio_output *audio_output, int public; sd = new_shout_data(); + sd->audio_output = audio_output; if (shout_init_count == 0) shout_init(); @@ -516,6 +517,21 @@ static int my_shout_play(void *data, return 0; } +static void my_shout_pause(void *data) +{ + struct shout_data *sd = (struct shout_data *)data; + static const char silence[1020]; + int ret; + + /* play silence until the player thread sends us a command */ + + while (sd->opened && !audio_output_is_pending(sd->audio_output)) { + ret = my_shout_play(data, silence, sizeof(silence)); + if (ret != 0) + break; + } +} + static void my_shout_set_tag(void *data, const struct tag *tag) { @@ -539,6 +555,7 @@ const struct audio_output_plugin shoutPlugin = { .finish = my_shout_finish_driver, .open = my_shout_open_device, .play = my_shout_play, + .pause = my_shout_pause, .cancel = my_shout_drop_buffered_audio, .close = my_shout_close_device, .send_tag = my_shout_set_tag, |