diff options
author | Max Kellermann <max@duempel.org> | 2009-05-05 22:43:28 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-05-05 22:43:28 +0200 |
commit | e55e560d4e48eaa9d2791b56a52a52bc6620df82 (patch) | |
tree | 38b9bb224aebbb0b8bb173d3fa86eedf4e621f98 /src/output | |
parent | 9080797025d73eb32ce0c7041a0d365015b51f41 (diff) | |
download | mpd-e55e560d4e48eaa9d2791b56a52a52bc6620df82.tar.gz mpd-e55e560d4e48eaa9d2791b56a52a52bc6620df82.tar.xz mpd-e55e560d4e48eaa9d2791b56a52a52bc6620df82.zip |
httpd_output: moved code to httpd_output_encoder_to_clients()
Moved some code from httpd_output_encode_and_play() into separate
functions httpd_output_broadcast_page() and
httpd_output_encoder_to_clients().
Diffstat (limited to '')
-rw-r--r-- | src/output/httpd_output_plugin.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/output/httpd_output_plugin.c b/src/output/httpd_output_plugin.c index 883dff773..e045e8b5a 100644 --- a/src/output/httpd_output_plugin.c +++ b/src/output/httpd_output_plugin.c @@ -310,30 +310,48 @@ httpd_client_send_page(gpointer data, gpointer user_data) httpd_client_send(client, page); } -static bool -httpd_output_encode_and_play(struct httpd_output *httpd, - const void *chunk, size_t size, GError **error) +/** + * Broadcasts a page struct to all clients. + */ +static void +httpd_output_broadcast_page(struct httpd_output *httpd, struct page *page) { - bool success; - struct page *page; + assert(page != NULL); - success = encoder_write(httpd->encoder, chunk, size, error); - if (!success) - return false; + g_mutex_lock(httpd->mutex); + g_list_foreach(httpd->clients, httpd_client_send_page, page); + g_mutex_unlock(httpd->mutex); +} + +/** + * Broadcasts data from the encoder to all clients. + */ +static void +httpd_output_encoder_to_clients(struct httpd_output *httpd) +{ + struct page *page; g_mutex_lock(httpd->mutex); g_list_foreach(httpd->clients, httpd_client_check_queue, NULL); g_mutex_unlock(httpd->mutex); while ((page = httpd_output_read_page(httpd)) != NULL) { - g_mutex_lock(httpd->mutex); - - g_list_foreach(httpd->clients, - httpd_client_send_page, page); - - g_mutex_unlock(httpd->mutex); + httpd_output_broadcast_page(httpd, page); page_unref(page); } +} + +static bool +httpd_output_encode_and_play(struct httpd_output *httpd, + const void *chunk, size_t size, GError **error) +{ + bool success; + + success = encoder_write(httpd->encoder, chunk, size, error); + if (!success) + return false; + + httpd_output_encoder_to_clients(httpd); return true; } |