aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-17 00:26:05 +0100
committerMax Kellermann <max@duempel.org>2014-01-17 09:46:51 +0100
commitaa64a5328edb4fcafb53cd512d37f9ceed8ed1c5 (patch)
treef58f15a4e2b7b6467b8247fba6c1125843c15a3b /src/db/upnp
parent59510f509a2332b20b998eb766967241d260704a (diff)
downloadmpd-aa64a5328edb4fcafb53cd512d37f9ceed8ed1c5.tar.gz
mpd-aa64a5328edb4fcafb53cd512d37f9ceed8ed1c5.tar.xz
mpd-aa64a5328edb4fcafb53cd512d37f9ceed8ed1c5.zip
db/upnp: split cluCallback()
Diffstat (limited to 'src/db/upnp')
-rw-r--r--src/db/upnp/Discovery.cxx44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/db/upnp/Discovery.cxx b/src/db/upnp/Discovery.cxx
index 8b88a0251..da0fe5c8d 100644
--- a/src/db/upnp/Discovery.cxx
+++ b/src/db/upnp/Discovery.cxx
@@ -156,6 +156,33 @@ discoExplorer(void *)
}
}
+static int
+OnAlive(Upnp_Discovery *disco)
+{
+ if (isMSDevice(disco->DeviceType) ||
+ isCDService(disco->ServiceType)) {
+ DiscoveredTask *tp = new DiscoveredTask(1, disco);
+ if (discoveredQueue.put(tp))
+ return UPNP_E_FINISH;
+ }
+
+ return UPNP_E_SUCCESS;
+}
+
+static int
+OnByeBye(Upnp_Discovery *disco)
+{
+
+ if (isMSDevice(disco->DeviceType) ||
+ isCDService(disco->ServiceType)) {
+ DiscoveredTask *tp = new DiscoveredTask(0, disco);
+ if (discoveredQueue.put(tp))
+ return UPNP_E_FINISH;
+ }
+
+ return UPNP_E_SUCCESS;
+}
+
// This gets called for all libupnp asynchronous events, in a libupnp
// thread context.
// Example: ContentDirectories appearing and disappearing from the network
@@ -168,26 +195,13 @@ cluCallBack(Upnp_EventType et, void *evp)
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
{
Upnp_Discovery *disco = (Upnp_Discovery *)evp;
- if (isMSDevice(disco->DeviceType) ||
- isCDService(disco->ServiceType)) {
- DiscoveredTask *tp = new DiscoveredTask(1, disco);
- if (discoveredQueue.put(tp))
- return UPNP_E_FINISH;
- }
- break;
+ return OnAlive(disco);
}
case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE:
{
Upnp_Discovery *disco = (Upnp_Discovery *)evp;
-
- if (isMSDevice(disco->DeviceType) ||
- isCDService(disco->ServiceType)) {
- DiscoveredTask *tp = new DiscoveredTask(0, disco);
- if (discoveredQueue.put(tp))
- return UPNP_E_FINISH;
- }
- break;
+ return OnByeBye(disco);
}
default: