diff options
author | Max Kellermann <max@duempel.org> | 2010-08-06 07:23:17 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-08-31 06:50:14 +0200 |
commit | 917434269c102d98ce45eb89964c322c3c2041c8 (patch) | |
tree | 3a209cb4702aaf4b06c8c12362908c672e92fb69 /src/output/httpd_output_plugin.c | |
parent | a77506ae215df09ed02c30f39a3be663a3180d5b (diff) | |
download | mpd-917434269c102d98ce45eb89964c322c3c2041c8.tar.gz mpd-917434269c102d98ce45eb89964c322c3c2041c8.tar.xz mpd-917434269c102d98ce45eb89964c322c3c2041c8.zip |
output/httpd: implement "pause"
Send silence to all connected clients while paused, to avoid
connection interruption.
Diffstat (limited to '')
-rw-r--r-- | src/output/httpd_output_plugin.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/output/httpd_output_plugin.c b/src/output/httpd_output_plugin.c index a71e21604..51ae820bc 100644 --- a/src/output/httpd_output_plugin.c +++ b/src/output/httpd_output_plugin.c @@ -499,6 +499,24 @@ httpd_output_play(void *data, const void *chunk, size_t size, GError **error) return size; } +static bool +httpd_output_pause(void *data) +{ + struct httpd_output *httpd = data; + + g_mutex_lock(httpd->mutex); + bool has_clients = httpd->clients != NULL; + g_mutex_unlock(httpd->mutex); + + if (has_clients) { + static const char silence[1020]; + return httpd_output_play(data, silence, sizeof(silence), NULL); + } else { + g_usleep(100000); + return true; + } +} + static void httpd_send_metadata(gpointer data, gpointer user_data) { @@ -587,5 +605,6 @@ const struct audio_output_plugin httpd_output_plugin = { .close = httpd_output_close, .send_tag = httpd_output_tag, .play = httpd_output_play, + .pause = httpd_output_pause, .cancel = httpd_output_cancel, }; |