diff options
author | Max Kellermann <max@duempel.org> | 2014-01-26 13:53:03 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-26 15:23:26 +0100 |
commit | 01f7abfc6385884251cc57fa615a065f82d274df (patch) | |
tree | 48d5cd64a1dc247f41168885b07b03ce7bf4a9d8 /src/lib/upnp/upnpplib.cxx | |
parent | e57e89b9d59faed31abcd11453fb33af95c55f40 (diff) | |
download | mpd-01f7abfc6385884251cc57fa615a065f82d274df.tar.gz mpd-01f7abfc6385884251cc57fa615a065f82d274df.tar.xz mpd-01f7abfc6385884251cc57fa615a065f82d274df.zip |
upnp: move library initialization to Init.cxx
Allow calling UpnpGlobalInit() multiple times.
Diffstat (limited to '')
-rw-r--r-- | src/lib/upnp/upnpplib.cxx | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/lib/upnp/upnpplib.cxx b/src/lib/upnp/upnpplib.cxx index 452c033d5..d36fc3593 100644 --- a/src/lib/upnp/upnpplib.cxx +++ b/src/lib/upnp/upnpplib.cxx @@ -21,33 +21,24 @@ #include "upnpplib.hxx" #include "Callback.hxx" #include "Domain.hxx" +#include "Init.hxx" #include "Log.hxx" -#include <upnp/ixml.h> #include <upnp/upnptools.h> LibUPnP::LibUPnP() { - auto code = UpnpInit(0, 0); - if (code != UPNP_E_SUCCESS) { - init_error.Format(upnp_domain, code, - "UpnpInit() failed: %s", - UpnpGetErrorMessage(code)); + if (!UpnpGlobalInit(init_error)) return; - } - - UpnpSetMaxContentLength(2000*1024); - code = UpnpRegisterClient(o_callback, nullptr, &m_clh); + auto code = UpnpRegisterClient(o_callback, nullptr, &m_clh); if (code != UPNP_E_SUCCESS) { + UpnpGlobalFinish(); init_error.Format(upnp_domain, code, "UpnpRegisterClient() failed: %s", UpnpGetErrorMessage(code)); return; } - - // Servers sometimes make error (e.g.: minidlna returns bad utf-8) - ixmlRelaxParser(1); } int @@ -65,8 +56,5 @@ LibUPnP::o_callback(Upnp_EventType et, void* evp, void* cookie) LibUPnP::~LibUPnP() { - int error = UpnpFinish(); - if (error != UPNP_E_SUCCESS) - FormatError(upnp_domain, "UpnpFinish() failed: %s", - UpnpGetErrorMessage(error)); + UpnpGlobalFinish(); } |