aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-11-05 08:11:01 +0100
committerMax Kellermann <max@duempel.org>2010-11-05 09:49:20 +0100
commite11ff967d0876177fdc5058d55427fdba9625f9c (patch)
tree0e099d1bcfbab4e40e0d5153112aee4f393103e4
parent2dc6ed7b3a2faf27d33fa8bbcf924031fde0e21a (diff)
downloadmpd-e11ff967d0876177fdc5058d55427fdba9625f9c.tar.gz
mpd-e11ff967d0876177fdc5058d55427fdba9625f9c.tar.xz
mpd-e11ff967d0876177fdc5058d55427fdba9625f9c.zip
output/shout: implement delay()
This makes the plugin more responsive to control commands, because it will listen to control events while waiting.
-rw-r--r--NEWS1
-rw-r--r--src/output/shout_plugin.c21
2 files changed, 14 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 7758269b3..57b765547 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,7 @@ ver 0.16 (20??/??/??)
- httpd: bind_to_address support (including IPv6)
- oss: 24 bit support via OSS4
- win32: new output plugin for Windows Wave
+ - shout: more responsive to control commands
- wildcards allowed in audio_format configuration
- consistently lock audio output objects
* player:
diff --git a/src/output/shout_plugin.c b/src/output/shout_plugin.c
index d1466eb3a..4b73bb334 100644
--- a/src/output/shout_plugin.c
+++ b/src/output/shout_plugin.c
@@ -342,7 +342,6 @@ write_page(struct shout_data *sd, GError **error)
if (sd->buf.len == 0)
return true;
- shout_sync(sd->shout_conn);
err = shout_send(sd->shout_conn, sd->buf.data, sd->buf.len);
if (!handle_shout_error(sd, err, error))
return false;
@@ -441,6 +440,18 @@ my_shout_open_device(void *data, struct audio_format *audio_format,
return true;
}
+static unsigned
+my_shout_delay(void *data)
+{
+ struct shout_data *sd = (struct shout_data *)data;
+
+ int delay = shout_delay(sd->shout_conn);
+ if (delay < 0)
+ delay = 0;
+
+ return delay;
+}
+
static size_t
my_shout_play(void *data, const void *chunk, size_t size, GError **error)
{
@@ -455,15 +466,8 @@ my_shout_play(void *data, const void *chunk, size_t size, GError **error)
static bool
my_shout_pause(void *data)
{
- struct shout_data *sd = (struct shout_data *)data;
static const char silence[1020];
- if (shout_delay(sd->shout_conn) > 500) {
- /* cap the latency for unpause */
- g_usleep(500000);
- return true;
- }
-
return my_shout_play(data, silence, sizeof(silence), NULL);
}
@@ -540,6 +544,7 @@ const struct audio_output_plugin shoutPlugin = {
.init = my_shout_init_driver,
.finish = my_shout_finish_driver,
.open = my_shout_open_device,
+ .delay = my_shout_delay,
.play = my_shout_play,
.pause = my_shout_pause,
.cancel = my_shout_drop_buffered_audio,