aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/upnp/Discovery.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-26 15:04:56 +0100
committerMax Kellermann <max@duempel.org>2014-01-26 15:04:56 +0100
commitbcc1f933702770c276e7353d71cb0c5fff75bc4a (patch)
treea7251a557d441353fcc630a8eba67b1e1c695efe /src/lib/upnp/Discovery.cxx
parentb161d723269d851a2d237880b8f5149b58b736c2 (diff)
downloadmpd-bcc1f933702770c276e7353d71cb0c5fff75bc4a.tar.gz
mpd-bcc1f933702770c276e7353d71cb0c5fff75bc4a.tar.xz
mpd-bcc1f933702770c276e7353d71cb0c5fff75bc4a.zip
upnp: add class UpnpCallback
Each Upnp*Async() call passes a new cookie pointer, and the cookie passed to UpnpRegisterClient() appears to be ignored. Using this interface is a more elegant approach than having one single "handler" function.
Diffstat (limited to 'src/lib/upnp/Discovery.cxx')
-rw-r--r--src/lib/upnp/Discovery.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx
index da32372ba..ce512bdde 100644
--- a/src/lib/upnp/Discovery.cxx
+++ b/src/lib/upnp/Discovery.cxx
@@ -184,8 +184,8 @@ UPnPDeviceDirectory::OnByeBye(Upnp_Discovery *disco)
// thread context.
// Example: ContentDirectories appearing and disappearing from the network
// We queue a task for our worker thread(s)
-inline int
-UPnPDeviceDirectory::cluCallBack(Upnp_EventType et, void *evp)
+int
+UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp)
{
switch (et) {
case UPNP_DISCOVERY_SEARCH_RESULT:
@@ -254,10 +254,6 @@ UPnPDeviceDirectory::Start(Error &error)
return false;
}
- lib->SetHandler([this](Upnp_EventType type, void *event){
- cluCallBack(type, event);
- });
-
return search(error);
}
@@ -271,7 +267,7 @@ UPnPDeviceDirectory::search(Error &error)
// We search both for device and service just in case.
int code = UpnpSearchAsync(lib->getclh(), m_searchTimeout,
- ContentDirectorySType, lib);
+ ContentDirectorySType, GetUpnpCookie());
if (code != UPNP_E_SUCCESS) {
error.Format(upnp_domain, code,
"UpnpSearchAsync() failed: %s",
@@ -280,7 +276,7 @@ UPnPDeviceDirectory::search(Error &error)
}
code = UpnpSearchAsync(lib->getclh(), m_searchTimeout,
- MediaServerDType, lib);
+ MediaServerDType, GetUpnpCookie());
if (code != UPNP_E_SUCCESS) {
error.Format(upnp_domain, code,
"UpnpSearchAsync() failed: %s",