Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
09880564
Commit
09880564
authored
Jan 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZeroconfBonjour: use SocketMonitor instead of GIOChannel
parent
95c3f57b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
32 deletions
+40
-32
Main.cxx
src/Main.cxx
+1
-1
ZeroconfBonjour.cxx
src/ZeroconfBonjour.cxx
+29
-26
ZeroconfBonjour.hxx
src/ZeroconfBonjour.hxx
+3
-1
ZeroconfGlue.cxx
src/ZeroconfGlue.cxx
+3
-2
ZeroconfGlue.hxx
src/ZeroconfGlue.hxx
+4
-2
No files found.
src/Main.cxx
View file @
09880564
...
...
@@ -490,7 +490,7 @@ int mpd_main(int argc, char *argv[])
return
EXIT_FAILURE
;
}
ZeroconfInit
();
ZeroconfInit
(
*
main_loop
);
player_create
(
&
global_partition
->
pc
);
...
...
src/ZeroconfBonjour.cxx
View file @
09880564
...
...
@@ -21,6 +21,8 @@
#include "ZeroconfBonjour.hxx"
#include "ZeroconfInternal.hxx"
#include "Listen.hxx"
#include "event/SocketMonitor.hxx"
#include "gcc.h"
#include <glib.h>
...
...
@@ -29,8 +31,28 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "bonjour"
static
DNSServiceRef
dnsReference
;
static
GIOChannel
*
bonjour_channel
;
class
BonjourMonitor
final
:
public
SocketMonitor
{
DNSServiceRef
service_ref
;
public
:
BonjourMonitor
(
EventLoop
&
_loop
,
DNSServiceRef
_service_ref
)
:
SocketMonitor
(
DNSServiceRefSockFD
(
_service_ref
),
_loop
),
service_ref
(
_service_ref
)
{
ScheduleRead
();
}
~
BonjourMonitor
()
{
Steal
();
DNSServiceRefDeallocate
(
service_ref
);
}
protected
:
virtual
void
OnSocketReady
(
gcc_unused
unsigned
flags
)
override
{
DNSServiceProcessResult
(
service_ref
);
}
};
static
BonjourMonitor
*
bonjour_monitor
;
static
void
dnsRegisterCallback
(
G_GNUC_UNUSED
DNSServiceRef
sdRef
,
...
...
@@ -43,25 +65,16 @@ dnsRegisterCallback(G_GNUC_UNUSED DNSServiceRef sdRef,
if
(
errorCode
!=
kDNSServiceErr_NoError
)
{
g_warning
(
"Failed to register zeroconf service."
);
BonjourDeinit
();
bonjour_monitor
->
Cancel
();
}
else
{
g_debug
(
"Registered zeroconf service with name '%s'"
,
name
);
}
}
static
gboolean
bonjour_channel_event
(
G_GNUC_UNUSED
GIOChannel
*
source
,
G_GNUC_UNUSED
GIOCondition
condition
,
G_GNUC_UNUSED
gpointer
data
)
{
DNSServiceProcessResult
(
dnsReference
);
return
dnsReference
!=
NULL
;
}
void
BonjourInit
(
const
char
*
service_name
)
BonjourInit
(
EventLoop
&
loop
,
const
char
*
service_name
)
{
DNSServiceRef
dnsReference
;
DNSServiceErrorType
error
=
DNSServiceRegister
(
&
dnsReference
,
0
,
0
,
service_name
,
SERVICE_TYPE
,
NULL
,
NULL
,
...
...
@@ -80,21 +93,11 @@ BonjourInit(const char *service_name)
return
;
}
bonjour_channel
=
g_io_channel_unix_new
(
DNSServiceRefSockFD
(
dnsReference
));
g_io_add_watch
(
bonjour_channel
,
G_IO_IN
,
bonjour_channel_event
,
NULL
);
bonjour_monitor
=
new
BonjourMonitor
(
loop
,
dnsReference
);
}
void
BonjourDeinit
()
{
if
(
bonjour_channel
!=
NULL
)
{
g_io_channel_unref
(
bonjour_channel
);
bonjour_channel
=
NULL
;
}
if
(
dnsReference
!=
NULL
)
{
DNSServiceRefDeallocate
(
dnsReference
);
dnsReference
=
NULL
;
g_debug
(
"Deregistered Zeroconf service."
);
}
delete
bonjour_monitor
;
}
src/ZeroconfBonjour.hxx
View file @
09880564
...
...
@@ -20,8 +20,10 @@
#ifndef MPD_ZEROCONF_BONJOUR_HXX
#define MPD_ZEROCONF_BONJOUR_HXX
class
EventLoop
;
void
BonjourInit
(
const
char
*
service_name
);
BonjourInit
(
EventLoop
&
loop
,
const
char
*
service_name
);
void
BonjourDeinit
();
...
...
src/ZeroconfGlue.cxx
View file @
09880564
...
...
@@ -23,6 +23,7 @@
#include "ZeroconfBonjour.hxx"
#include "conf.h"
#include "Listen.hxx"
#include "gcc.h"
#include <glib.h>
...
...
@@ -36,7 +37,7 @@
static
int
zeroconfEnabled
;
void
ZeroconfInit
()
ZeroconfInit
(
gcc_unused
EventLoop
&
loop
)
{
const
char
*
serviceName
;
...
...
@@ -58,7 +59,7 @@ ZeroconfInit()
#endif
#ifdef HAVE_BONJOUR
BonjourInit
(
serviceName
);
BonjourInit
(
loop
,
serviceName
);
#endif
}
...
...
src/ZeroconfGlue.hxx
View file @
09880564
...
...
@@ -22,10 +22,12 @@
#include "check.h"
class
EventLoop
;
#ifdef HAVE_ZEROCONF
void
ZeroconfInit
();
ZeroconfInit
(
EventLoop
&
loop
);
void
ZeroconfDeinit
();
...
...
@@ -33,7 +35,7 @@ ZeroconfDeinit();
#else
/* ! HAVE_ZEROCONF */
static
inline
void
ZeroconfInit
()
ZeroconfInit
(
EventLoop
&
)
{}
static
inline
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment