Commit e11ff967 authored by Max Kellermann's avatar Max Kellermann

output/shout: implement delay()

This makes the plugin more responsive to control commands, because it will listen to control events while waiting.
parent 2dc6ed7b
......@@ -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:
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment