use listener logic to send dacp update requests

This commit is contained in:
chme 2015-05-03 08:19:15 +02:00
parent 7097dd15eb
commit d2c7c87191
3 changed files with 8 additions and 40 deletions

View File

@ -46,6 +46,7 @@
#include "dmap_common.h"
#include "db.h"
#include "player.h"
#include "listener.h"
/* httpd event base, from httpd.c */
extern struct event_base *evbase_httpd;
@ -342,10 +343,14 @@ playstatusupdate_cb(int fd, short what, void *arg)
/* Thread: player */
static void
dacp_playstatus_update_handler(void)
dacp_playstatus_update_handler(enum listener_event_type type)
{
int ret;
// Only send status update on player change events
if (type != LISTENER_PLAYER)
return;
#ifdef USE_EVENTFD
ret = eventfd_write(update_efd, 1);
if (ret < 0)
@ -2423,7 +2428,7 @@ dacp_init(void)
event_base_set(evbase_httpd, &updateev);
event_add(&updateev, NULL);
player_set_update_handler(dacp_playstatus_update_handler);
listener_add(dacp_playstatus_update_handler);
return 0;
@ -2444,7 +2449,7 @@ dacp_deinit(void)
struct evhttp_connection *evcon;
int i;
player_set_update_handler(NULL);
listener_remove(dacp_playstatus_update_handler);
for (i = 0; dacp_handlers[i].handler; i++)
regfree(&dacp_handlers[i].preg);

View File

@ -165,7 +165,6 @@ struct player_command
struct player_status *status;
struct player_source *ps;
struct player_metadata *pmd;
player_status_handler status_handler;
uint32_t *id_ptr;
uint64_t *raop_ids;
enum repeat_mode mode;
@ -208,9 +207,6 @@ static enum play_status player_state;
static enum repeat_mode repeat;
static char shuffle;
/* Status updates (for DACP) */
static player_status_handler update_handler;
/* Playback timer */
#if defined(__linux__)
static int pb_timer_fd;
@ -300,9 +296,6 @@ status_update(enum play_status status)
{
player_state = status;
if (update_handler)
update_handler();
listener_notify(LISTENER_PLAYER);
if (status == PLAY_PLAYING)
@ -4125,14 +4118,6 @@ queue_plid(struct player_command *cmd)
return 0;
}
static int
set_update_handler(struct player_command *cmd)
{
update_handler = cmd->arg.status_handler;
return 0;
}
/* Command processing */
/* Thread: player */
static void
@ -4821,22 +4806,6 @@ player_queue_plid(uint32_t plid)
command_deinit(&cmd);
}
void
player_set_update_handler(player_status_handler handler)
{
struct player_command cmd;
command_init(&cmd);
cmd.func = set_update_handler;
cmd.func_bh = NULL;
cmd.arg.status_handler = handler;
sync_command(&cmd);
command_deinit(&cmd);
}
/* Non-blocking commands used by mDNS */
static void
player_device_add(struct raop_device *rd)
@ -5198,8 +5167,6 @@ player_init(void)
repeat = REPEAT_OFF;
shuffle = 0;
update_handler = NULL;
history = (struct player_history *)calloc(1, sizeof(struct player_history));
/*

View File

@ -71,7 +71,6 @@ struct player_status {
};
typedef void (*spk_enum_cb)(uint64_t id, const char *name, int relvol, struct spk_flags flags, void *arg);
typedef void (*player_status_handler)(void);
struct player_source
{
@ -224,9 +223,6 @@ player_queue_plid(uint32_t plid);
struct player_history *
player_history_get(void);
void
player_set_update_handler(player_status_handler handler);
int
player_init(void);