mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-08 13:51:43 +02:00
code formatting
This commit is contained in:
parent
c92588344e
commit
a3796036ff
2 changed files with 161 additions and 151 deletions
|
@ -81,13 +81,15 @@ PublishAvahi::~PublishAvahi()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PublishAvahi::entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
|
void PublishAvahi::entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata)
|
||||||
|
{
|
||||||
assert(g == group || group == NULL);
|
assert(g == group || group == NULL);
|
||||||
group = g;
|
group = g;
|
||||||
|
|
||||||
/* Called whenever the entry group state changes */
|
/* Called whenever the entry group state changes */
|
||||||
|
|
||||||
switch (state) {
|
switch (state)
|
||||||
|
{
|
||||||
case AVAHI_ENTRY_GROUP_ESTABLISHED :
|
case AVAHI_ENTRY_GROUP_ESTABLISHED :
|
||||||
/* The entry group has been established successfully */
|
/* The entry group has been established successfully */
|
||||||
logO << "Service '" << name << "' successfully established.\n";
|
logO << "Service '" << name << "' successfully established.\n";
|
||||||
|
@ -123,7 +125,8 @@ void PublishAvahi::entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PublishAvahi::create_services(AvahiClient *c) {
|
void PublishAvahi::create_services(AvahiClient *c)
|
||||||
|
{
|
||||||
char *n, r[128];
|
char *n, r[128];
|
||||||
int ret;
|
int ret;
|
||||||
assert(c);
|
assert(c);
|
||||||
|
@ -133,7 +136,8 @@ void PublishAvahi::create_services(AvahiClient *c) {
|
||||||
|
|
||||||
if (!group)
|
if (!group)
|
||||||
{
|
{
|
||||||
if (!(group = avahi_entry_group_new(c, entry_group_callback, this))) {
|
if (!(group = avahi_entry_group_new(c, entry_group_callback, this)))
|
||||||
|
{
|
||||||
logE << "avahi_entry_group_new() failed: " << avahi_strerror(avahi_client_errno(c)) << "\n";
|
logE << "avahi_entry_group_new() failed: " << avahi_strerror(avahi_client_errno(c)) << "\n";
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +145,8 @@ void PublishAvahi::create_services(AvahiClient *c) {
|
||||||
/* If the group is empty (either because it was just created, or
|
/* If the group is empty (either because it was just created, or
|
||||||
* because it was reset previously, add our entries. */
|
* because it was reset previously, add our entries. */
|
||||||
|
|
||||||
if (avahi_entry_group_is_empty(group)) {
|
if (avahi_entry_group_is_empty(group))
|
||||||
|
{
|
||||||
logO << "Adding service '" << name << "'\n";
|
logO << "Adding service '" << name << "'\n";
|
||||||
|
|
||||||
/* Create some random TXT data */
|
/* Create some random TXT data */
|
||||||
|
@ -153,7 +158,8 @@ void PublishAvahi::create_services(AvahiClient *c) {
|
||||||
* same name should be put in the same entry group. */
|
* same name should be put in the same entry group. */
|
||||||
|
|
||||||
/* Add the service for IPP */
|
/* Add the service for IPP */
|
||||||
/* if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0) {
|
/* if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AVAHI_PUBLISH_UNIQUE, name, "_ipp._tcp", NULL, NULL, 651, "test=blah", r, NULL)) < 0)
|
||||||
|
{
|
||||||
|
|
||||||
if (ret == AVAHI_ERR_COLLISION)
|
if (ret == AVAHI_ERR_COLLISION)
|
||||||
goto collision;
|
goto collision;
|
||||||
|
@ -177,13 +183,15 @@ void PublishAvahi::create_services(AvahiClient *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add an additional (hypothetic) subtype */
|
/* Add an additional (hypothetic) subtype */
|
||||||
/* if ((ret = avahi_entry_group_add_service_subtype(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AvahiPublishFlags(0), name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0)) {
|
/* if ((ret = avahi_entry_group_add_service_subtype(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AvahiPublishFlags(0), name, "_printer._tcp", NULL, "_magic._sub._printer._tcp") < 0))
|
||||||
|
{
|
||||||
fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", avahi_strerror(ret));
|
fprintf(stderr, "Failed to add subtype _magic._sub._printer._tcp: %s\n", avahi_strerror(ret));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* Tell the server to register the service */
|
/* Tell the server to register the service */
|
||||||
if ((ret = avahi_entry_group_commit(group)) < 0) {
|
if ((ret = avahi_entry_group_commit(group)) < 0)
|
||||||
|
{
|
||||||
logE << "Failed to commit entry group: " << avahi_strerror(ret) << "\n";
|
logE << "Failed to commit entry group: " << avahi_strerror(ret) << "\n";
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -211,12 +219,14 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PublishAvahi::client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) {
|
void PublishAvahi::client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata)
|
||||||
|
{
|
||||||
assert(c);
|
assert(c);
|
||||||
|
|
||||||
/* Called whenever the client or server state changes */
|
/* Called whenever the client or server state changes */
|
||||||
|
|
||||||
switch (state) {
|
switch (state)
|
||||||
|
{
|
||||||
case AVAHI_CLIENT_S_RUNNING:
|
case AVAHI_CLIENT_S_RUNNING:
|
||||||
|
|
||||||
/* The server has startup successfully and registered its host
|
/* The server has startup successfully and registered its host
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue