From bcc1f933702770c276e7353d71cb0c5fff75bc4a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 26 Jan 2014 15:04:56 +0100 Subject: 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. --- src/lib/upnp/Discovery.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/lib/upnp/Discovery.cxx') 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", -- cgit v1.2.3