mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 00:23:23 -05:00
use listener logic to send dacp update requests
This commit is contained in:
parent
7097dd15eb
commit
d2c7c87191
@ -46,6 +46,7 @@
|
|||||||
#include "dmap_common.h"
|
#include "dmap_common.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "listener.h"
|
||||||
|
|
||||||
/* httpd event base, from httpd.c */
|
/* httpd event base, from httpd.c */
|
||||||
extern struct event_base *evbase_httpd;
|
extern struct event_base *evbase_httpd;
|
||||||
@ -342,10 +343,14 @@ playstatusupdate_cb(int fd, short what, void *arg)
|
|||||||
|
|
||||||
/* Thread: player */
|
/* Thread: player */
|
||||||
static void
|
static void
|
||||||
dacp_playstatus_update_handler(void)
|
dacp_playstatus_update_handler(enum listener_event_type type)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
// Only send status update on player change events
|
||||||
|
if (type != LISTENER_PLAYER)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef USE_EVENTFD
|
#ifdef USE_EVENTFD
|
||||||
ret = eventfd_write(update_efd, 1);
|
ret = eventfd_write(update_efd, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -2423,7 +2428,7 @@ dacp_init(void)
|
|||||||
event_base_set(evbase_httpd, &updateev);
|
event_base_set(evbase_httpd, &updateev);
|
||||||
event_add(&updateev, NULL);
|
event_add(&updateev, NULL);
|
||||||
|
|
||||||
player_set_update_handler(dacp_playstatus_update_handler);
|
listener_add(dacp_playstatus_update_handler);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2444,7 +2449,7 @@ dacp_deinit(void)
|
|||||||
struct evhttp_connection *evcon;
|
struct evhttp_connection *evcon;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
player_set_update_handler(NULL);
|
listener_remove(dacp_playstatus_update_handler);
|
||||||
|
|
||||||
for (i = 0; dacp_handlers[i].handler; i++)
|
for (i = 0; dacp_handlers[i].handler; i++)
|
||||||
regfree(&dacp_handlers[i].preg);
|
regfree(&dacp_handlers[i].preg);
|
||||||
|
33
src/player.c
33
src/player.c
@ -165,7 +165,6 @@ struct player_command
|
|||||||
struct player_status *status;
|
struct player_status *status;
|
||||||
struct player_source *ps;
|
struct player_source *ps;
|
||||||
struct player_metadata *pmd;
|
struct player_metadata *pmd;
|
||||||
player_status_handler status_handler;
|
|
||||||
uint32_t *id_ptr;
|
uint32_t *id_ptr;
|
||||||
uint64_t *raop_ids;
|
uint64_t *raop_ids;
|
||||||
enum repeat_mode mode;
|
enum repeat_mode mode;
|
||||||
@ -208,9 +207,6 @@ static enum play_status player_state;
|
|||||||
static enum repeat_mode repeat;
|
static enum repeat_mode repeat;
|
||||||
static char shuffle;
|
static char shuffle;
|
||||||
|
|
||||||
/* Status updates (for DACP) */
|
|
||||||
static player_status_handler update_handler;
|
|
||||||
|
|
||||||
/* Playback timer */
|
/* Playback timer */
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
static int pb_timer_fd;
|
static int pb_timer_fd;
|
||||||
@ -300,9 +296,6 @@ status_update(enum play_status status)
|
|||||||
{
|
{
|
||||||
player_state = status;
|
player_state = status;
|
||||||
|
|
||||||
if (update_handler)
|
|
||||||
update_handler();
|
|
||||||
|
|
||||||
listener_notify(LISTENER_PLAYER);
|
listener_notify(LISTENER_PLAYER);
|
||||||
|
|
||||||
if (status == PLAY_PLAYING)
|
if (status == PLAY_PLAYING)
|
||||||
@ -4125,14 +4118,6 @@ queue_plid(struct player_command *cmd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
set_update_handler(struct player_command *cmd)
|
|
||||||
{
|
|
||||||
update_handler = cmd->arg.status_handler;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Command processing */
|
/* Command processing */
|
||||||
/* Thread: player */
|
/* Thread: player */
|
||||||
static void
|
static void
|
||||||
@ -4821,22 +4806,6 @@ player_queue_plid(uint32_t plid)
|
|||||||
command_deinit(&cmd);
|
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 */
|
/* Non-blocking commands used by mDNS */
|
||||||
static void
|
static void
|
||||||
player_device_add(struct raop_device *rd)
|
player_device_add(struct raop_device *rd)
|
||||||
@ -5198,8 +5167,6 @@ player_init(void)
|
|||||||
repeat = REPEAT_OFF;
|
repeat = REPEAT_OFF;
|
||||||
shuffle = 0;
|
shuffle = 0;
|
||||||
|
|
||||||
update_handler = NULL;
|
|
||||||
|
|
||||||
history = (struct player_history *)calloc(1, sizeof(struct player_history));
|
history = (struct player_history *)calloc(1, sizeof(struct player_history));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -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 (*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
|
struct player_source
|
||||||
{
|
{
|
||||||
@ -224,9 +223,6 @@ player_queue_plid(uint32_t plid);
|
|||||||
struct player_history *
|
struct player_history *
|
||||||
player_history_get(void);
|
player_history_get(void);
|
||||||
|
|
||||||
void
|
|
||||||
player_set_update_handler(player_status_handler handler);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
player_init(void);
|
player_init(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user