From 7715f3bbd3ec482b6e8f4772f49ef9eda004e844 Mon Sep 17 00:00:00 2001 From: badaix Date: Sun, 16 Oct 2016 15:04:13 +0200 Subject: [PATCH] fixed Avahi --- server/Makefile | 6 +++--- server/publishAvahi.cpp | 18 ++++++++---------- server/publishAvahi.h | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/server/Makefile b/server/Makefile index e7dc94cd..74a9528b 100644 --- a/server/Makefile +++ b/server/Makefile @@ -19,7 +19,7 @@ endif ifeq ($(TARGET), OPENWRT) STRIP = echo -CXXFLAGS += -DNO_CPP11_STRING -pthread +CXXFLAGS += -DNO_CPP11_STRING -DHAS_AVAHI -pthread LDFLAGS = -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -latomic OBJ += publishAvahi.o @@ -27,7 +27,7 @@ else ifeq ($(TARGET), FREEBSD) CXX = /usr/local/bin/g++ STRIP = echo -CXXFLAGS += -DNO_CPP11_STRING -DFREEBSD -pthread +CXXFLAGS += -DNO_CPP11_STRING -DFREEBSD -DHAS_AVAHI -pthread LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -static-libgcc -static-libstdc++ OBJ += publishAvahi.o @@ -43,7 +43,7 @@ else CXX = /usr/bin/g++ STRIP = strip -CXXFLAGS += -pthread +CXXFLAGS += -DHAS_AVAHI -pthread LDFLAGS = -lrt -lvorbis -lvorbisenc -logg -lFLAC -lavahi-client -lavahi-common -static-libgcc -static-libstdc++ OBJ += publishAvahi.o diff --git a/server/publishAvahi.cpp b/server/publishAvahi.cpp index 2b79984d..675cdbb2 100644 --- a/server/publishAvahi.cpp +++ b/server/publishAvahi.cpp @@ -27,8 +27,8 @@ static AvahiEntryGroup *group; static AvahiSimplePoll *simple_poll; static char* name; -PublishAvahi::PublishAvahi(const std::string& serviceName) : PublishmDNS(serviceName) - client(NULL), active_(false) +PublishAvahi::PublishAvahi(const std::string& serviceName) : PublishmDNS(serviceName), + client_(NULL), active_(false) { group = NULL; simple_poll = NULL; @@ -40,9 +40,6 @@ void PublishAvahi::publish(const std::vector& services) { this->services = services; - AvahiClient *client = NULL; - int error; - /* Allocate main loop object */ if (!(simple_poll = avahi_simple_poll_new())) { @@ -50,10 +47,11 @@ void PublishAvahi::publish(const std::vector& services) } /* Allocate a new client */ - client = avahi_client_new(avahi_simple_poll_get(simple_poll), AVAHI_CLIENT_IGNORE_USER_CONFIG, client_callback, this, &error); + int error; + client_ = avahi_client_new(avahi_simple_poll_get(simple_poll), AVAHI_CLIENT_IGNORE_USER_CONFIG, client_callback, this, &error); /* Check wether creating the client object succeeded */ - if (!client) + if (!client_) { logE << "Failed to create client: " << avahi_strerror(error) << "\n"; } @@ -74,8 +72,8 @@ PublishAvahi::~PublishAvahi() active_ = false; pollThread_.join(); - if (client) - avahi_client_free(client); + if (client_) + avahi_client_free(client_); if (simple_poll) avahi_simple_poll_free(simple_poll); @@ -174,7 +172,7 @@ void PublishAvahi::create_services(AvahiClient *c) /* Add the same service for BSD LPR */ for (size_t n=0; n active_; std::vector services; };