mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Move code around, no functional changes
This commit is contained in:
parent
c3e24a0d9a
commit
418e818bee
123
src/player.c
123
src/player.c
@ -1191,6 +1191,66 @@ device_check(struct raop_device *dev)
|
||||
return (rd) ? 0 : -1;
|
||||
}
|
||||
|
||||
/* Thread: main (mdns) */
|
||||
static void
|
||||
device_remove_family(const char *name, uint64_t id, int family)
|
||||
{
|
||||
struct raop_device *rd;
|
||||
struct raop_device *prev;
|
||||
|
||||
prev = NULL;
|
||||
for (rd = dev_list; rd; rd = rd->next)
|
||||
{
|
||||
if (rd->id == id)
|
||||
break;
|
||||
|
||||
prev = rd;
|
||||
}
|
||||
|
||||
if (!rd)
|
||||
{
|
||||
DPRINTF(E_WARN, L_PLAYER, "AirTunes device %s stopped advertising, but not in our list\n", name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
if (rd->v4_address)
|
||||
{
|
||||
free(rd->v4_address);
|
||||
rd->v4_address = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
if (rd->v6_address)
|
||||
{
|
||||
free(rd->v6_address);
|
||||
rd->v6_address = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!rd->v4_address && !rd->v6_address)
|
||||
{
|
||||
rd->advertised = 0;
|
||||
|
||||
if (!rd->session)
|
||||
{
|
||||
if (!prev)
|
||||
dev_list = rd->next;
|
||||
else
|
||||
prev->next = rd->next;
|
||||
|
||||
device_free(rd);
|
||||
|
||||
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* RAOP callbacks executed in the player thread */
|
||||
static void
|
||||
device_streaming_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status)
|
||||
@ -2898,67 +2958,6 @@ player_set_update_handler(player_status_handler handler)
|
||||
|
||||
|
||||
/* RAOP devices discovery - mDNS callback & helpers */
|
||||
/* Thread: main (mdns) */
|
||||
/* Call with dev_lck held */
|
||||
static void
|
||||
raop_device_remove_family(const char *name, uint64_t id, int family)
|
||||
{
|
||||
struct raop_device *rd;
|
||||
struct raop_device *prev;
|
||||
|
||||
prev = NULL;
|
||||
for (rd = dev_list; rd; rd = rd->next)
|
||||
{
|
||||
if (rd->id == id)
|
||||
break;
|
||||
|
||||
prev = rd;
|
||||
}
|
||||
|
||||
if (!rd)
|
||||
{
|
||||
DPRINTF(E_WARN, L_PLAYER, "AirTunes device %s stopped advertising, but not in our list\n", name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (family)
|
||||
{
|
||||
case AF_INET:
|
||||
if (rd->v4_address)
|
||||
{
|
||||
free(rd->v4_address);
|
||||
rd->v4_address = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case AF_INET6:
|
||||
if (rd->v6_address)
|
||||
{
|
||||
free(rd->v6_address);
|
||||
rd->v6_address = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!rd->v4_address && !rd->v6_address)
|
||||
{
|
||||
rd->advertised = 0;
|
||||
|
||||
if (!rd->session)
|
||||
{
|
||||
if (!prev)
|
||||
dev_list = rd->next;
|
||||
else
|
||||
prev->next = rd->next;
|
||||
|
||||
device_free(rd);
|
||||
|
||||
DPRINTF(E_DBG, L_PLAYER, "Removed AirTunes device %s; stopped advertising\n", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Thread: main (mdns) */
|
||||
/* Call with dev_lck held */
|
||||
static struct raop_device *
|
||||
@ -3042,7 +3041,7 @@ raop_device_cb(const char *name, const char *type, const char *domain, const cha
|
||||
/* Device stopped advertising */
|
||||
pthread_mutex_lock(&dev_lck);
|
||||
|
||||
raop_device_remove_family(name, id, family);
|
||||
device_remove_family(name, id, family);
|
||||
|
||||
pthread_mutex_unlock(&dev_lck);
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user