mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-13 14:48:10 -05:00
RAOP device discovery rework, split remove code
This commit is contained in:
parent
01df67ceb6
commit
999066d703
86
src/player.c
86
src/player.c
@ -2879,47 +2879,15 @@ player_set_update_handler(player_status_handler handler)
|
|||||||
command_deinit(&cmd);
|
command_deinit(&cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* RAOP devices discovery - mDNS callback & helpers */
|
||||||
/* Thread: main (mdns) */
|
/* Thread: main (mdns) */
|
||||||
|
/* Call with dev_lck held */
|
||||||
static void
|
static void
|
||||||
raop_device_cb(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt)
|
raop_device_remove_family(const char *name, uint64_t id, int family)
|
||||||
{
|
{
|
||||||
struct player_status status;
|
|
||||||
struct raop_device *rd;
|
struct raop_device *rd;
|
||||||
struct raop_device *prev;
|
struct raop_device *prev;
|
||||||
cfg_t *apex;
|
|
||||||
const char *p;
|
|
||||||
char *at_name;
|
|
||||||
char *password;
|
|
||||||
uint64_t id;
|
|
||||||
char has_password;
|
|
||||||
char encrypt;
|
|
||||||
char auth_quirk_itunes;
|
|
||||||
char last_active;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = safe_hextou64(name, &id);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device ID (%s)\n", name);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
at_name = strchr(name, '@');
|
|
||||||
if (!at_name)
|
|
||||||
{
|
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device name (%s)\n", name);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
at_name++;
|
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_PLAYER, "Found AirTunes device %" PRIx64 "/%s (%d)\n", id, at_name, port);
|
|
||||||
|
|
||||||
if (port < 0)
|
|
||||||
{
|
|
||||||
/* Device stopped advertising */
|
|
||||||
pthread_mutex_lock(&dev_lck);
|
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
for (rd = dev_list; rd; rd = rd->next)
|
for (rd = dev_list; rd; rd = rd->next)
|
||||||
@ -2932,8 +2900,6 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
|||||||
|
|
||||||
if (!rd)
|
if (!rd)
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&dev_lck);
|
|
||||||
|
|
||||||
DPRINTF(E_WARN, L_PLAYER, "AirTunes device %s stopped advertising, but not in our list\n", name);
|
DPRINTF(E_WARN, L_PLAYER, "AirTunes device %s stopped advertising, but not in our list\n", name);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -2974,6 +2940,50 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
|||||||
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Thread: main (mdns) */
|
||||||
|
static void
|
||||||
|
raop_device_cb(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt)
|
||||||
|
{
|
||||||
|
struct player_status status;
|
||||||
|
struct raop_device *rd;
|
||||||
|
cfg_t *apex;
|
||||||
|
const char *p;
|
||||||
|
char *at_name;
|
||||||
|
char *password;
|
||||||
|
uint64_t id;
|
||||||
|
char has_password;
|
||||||
|
char encrypt;
|
||||||
|
char auth_quirk_itunes;
|
||||||
|
char last_active;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = safe_hextou64(name, &id);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device ID (%s)\n", name);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
at_name = strchr(name, '@');
|
||||||
|
if (!at_name)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device name (%s)\n", name);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
at_name++;
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Found AirTunes device %" PRIx64 "/%s (%d)\n", id, at_name, port);
|
||||||
|
|
||||||
|
if (port < 0)
|
||||||
|
{
|
||||||
|
/* Device stopped advertising */
|
||||||
|
pthread_mutex_lock(&dev_lck);
|
||||||
|
|
||||||
|
raop_device_remove_family(name, id, family);
|
||||||
|
|
||||||
pthread_mutex_unlock(&dev_lck);
|
pthread_mutex_unlock(&dev_lck);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user