httpd_output: disable Icy-Metadata when encoder supports tags
There's no reason to send both encoder tags and Icy-Metadata to the client. Let's disable Icy-Metadata when the encoder supports embedded tags.
This commit is contained in:
parent
ebc1d3516c
commit
9080797025
@ -89,6 +89,12 @@ struct httpd_client {
|
|||||||
|
|
||||||
/* ICY */
|
/* ICY */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do we support sending Icy-Metadata to the client? This is
|
||||||
|
* disabled if the httpd audio output uses encoder tags.
|
||||||
|
*/
|
||||||
|
bool metadata_supported;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we should sent icy metadata.
|
* If we should sent icy metadata.
|
||||||
*/
|
*/
|
||||||
@ -210,7 +216,8 @@ httpd_client_handle_line(struct httpd_client *client, const char *line)
|
|||||||
|
|
||||||
if (g_ascii_strncasecmp(line, "Icy-MetaData: 1", 15) == 0) {
|
if (g_ascii_strncasecmp(line, "Icy-MetaData: 1", 15) == 0) {
|
||||||
/* Send icy metadata */
|
/* Send icy metadata */
|
||||||
client->metadata_requested = true;
|
client->metadata_requested =
|
||||||
|
client->metadata_supported;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +424,7 @@ httpd_client_in_event(G_GNUC_UNUSED GIOChannel *source, GIOCondition condition,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct httpd_client *
|
struct httpd_client *
|
||||||
httpd_client_new(struct httpd_output *httpd, int fd)
|
httpd_client_new(struct httpd_output *httpd, int fd, bool metadata_supported)
|
||||||
{
|
{
|
||||||
struct httpd_client *client = g_new(struct httpd_client, 1);
|
struct httpd_client *client = g_new(struct httpd_client, 1);
|
||||||
|
|
||||||
@ -443,6 +450,7 @@ httpd_client_new(struct httpd_output *httpd, int fd)
|
|||||||
client->input = fifo_buffer_new(4096);
|
client->input = fifo_buffer_new(4096);
|
||||||
client->state = REQUEST;
|
client->state = REQUEST;
|
||||||
|
|
||||||
|
client->metadata_supported = metadata_supported;
|
||||||
client->metadata_requested = false;
|
client->metadata_requested = false;
|
||||||
client->metadata_sent = true;
|
client->metadata_sent = true;
|
||||||
client->metaint = 8192; /*TODO: just a std value */
|
client->metaint = 8192; /*TODO: just a std value */
|
||||||
|
@ -35,7 +35,7 @@ struct page;
|
|||||||
* @param fd the socket file descriptor
|
* @param fd the socket file descriptor
|
||||||
*/
|
*/
|
||||||
struct httpd_client *
|
struct httpd_client *
|
||||||
httpd_client_new(struct httpd_output *httpd, int fd);
|
httpd_client_new(struct httpd_output *httpd, int fd, bool metadata_supported);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees memory and resources allocated by the #httpd_client object.
|
* Frees memory and resources allocated by the #httpd_client object.
|
||||||
|
@ -118,7 +118,9 @@ httpd_output_finish(void *data)
|
|||||||
static void
|
static void
|
||||||
httpd_client_add(struct httpd_output *httpd, int fd)
|
httpd_client_add(struct httpd_output *httpd, int fd)
|
||||||
{
|
{
|
||||||
struct httpd_client *client = httpd_client_new(httpd, fd);
|
struct httpd_client *client =
|
||||||
|
httpd_client_new(httpd, fd,
|
||||||
|
httpd->encoder->plugin->tag == NULL);
|
||||||
|
|
||||||
httpd->clients = g_list_prepend(httpd->clients, client);
|
httpd->clients = g_list_prepend(httpd->clients, client);
|
||||||
|
|
||||||
@ -380,21 +382,28 @@ httpd_output_tag(void *data, const struct tag *tag)
|
|||||||
|
|
||||||
assert(tag != NULL);
|
assert(tag != NULL);
|
||||||
|
|
||||||
if (httpd->metadata != NULL)
|
if (httpd->encoder->plugin->tag != NULL) {
|
||||||
page_unref (httpd->metadata);
|
/* embed encoder tags */
|
||||||
|
|
||||||
httpd->metadata = icy_server_metadata_page(tag, TAG_ITEM_ALBUM,
|
encoder_tag(httpd->encoder, tag, NULL);
|
||||||
TAG_ITEM_ARTIST,
|
} else {
|
||||||
TAG_ITEM_TITLE,
|
/* use Icy-Metadata */
|
||||||
TAG_NUM_OF_ITEM_TYPES);
|
|
||||||
|
|
||||||
if (httpd->metadata) {
|
if (httpd->metadata != NULL)
|
||||||
g_mutex_lock(httpd->mutex);
|
page_unref (httpd->metadata);
|
||||||
g_list_foreach(httpd->clients, httpd_send_metadata, httpd->metadata);
|
|
||||||
g_mutex_unlock(httpd->mutex);
|
httpd->metadata =
|
||||||
|
icy_server_metadata_page(tag, TAG_ITEM_ALBUM,
|
||||||
|
TAG_ITEM_ARTIST,
|
||||||
|
TAG_ITEM_TITLE,
|
||||||
|
TAG_NUM_OF_ITEM_TYPES);
|
||||||
|
if (httpd->metadata != NULL) {
|
||||||
|
g_mutex_lock(httpd->mutex);
|
||||||
|
g_list_foreach(httpd->clients,
|
||||||
|
httpd_send_metadata, httpd->metadata);
|
||||||
|
g_mutex_unlock(httpd->mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
encoder_tag(httpd->encoder, tag, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user