zeroconf: pass user data as const

This commit is contained in:
Wim Taymans 2026-02-27 16:06:33 +01:00
parent db713c8264
commit a065cff8c1
7 changed files with 20 additions and 24 deletions

View file

@ -364,7 +364,7 @@ static void pw_properties_from_zeroconf(const char *key, const char *value,
}
}
static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name, *str;
@ -417,7 +417,7 @@ done:
pw_properties_free(props);
}
static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name;

View file

@ -1280,7 +1280,7 @@ static const char *get_service_name(struct impl *impl)
return NULL;
}
static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *str, *service_name, *address, *hostname;
@ -1417,7 +1417,7 @@ error:
return;
}
static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
struct service_info sinfo;

View file

@ -1109,7 +1109,7 @@ static const struct pw_websocket_events websocket_events = {
.connected = on_websocket_connected,
};
static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name, *addr, *port, *path;
@ -1138,7 +1138,7 @@ static void on_zeroconf_added(void *data, void *user, const struct spa_dict *inf
match_client(impl, name, props, NULL);
}
static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name;

View file

@ -1110,7 +1110,7 @@ static const struct pw_websocket_events websocket_events = {
.connected = on_websocket_connected,
};
static void on_zeroconf_added(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_added(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name, *addr, *port, *path;
@ -1136,7 +1136,7 @@ static void on_zeroconf_added(void *data, void *user, const struct spa_dict *inf
match_client(impl, name, props, NULL);
}
static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name;

View file

@ -20,10 +20,6 @@
#include <pipewire/impl.h>
#include <pipewire/i18n.h>
#include <avahi-client/lookup.h>
#include <avahi-common/error.h>
#include <avahi-common/malloc.h>
#include "module-protocol-pulse/format.h"
#include "zeroconf-utils/zeroconf.h"
@ -230,7 +226,7 @@ static const struct pw_impl_module_events submodule_events = {
.destroy = submodule_destroy,
};
static void on_zeroconf_added(void *data, void *user_data, const struct spa_dict *info)
static void on_zeroconf_added(void *data, const void *user_data, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name, *type, *mode, *device, *host_name, *desc, *fqdn, *user, *str;
@ -344,7 +340,7 @@ done:
pw_properties_free(props);
}
static void on_zeroconf_removed(void *data, void *user, const struct spa_dict *info)
static void on_zeroconf_removed(void *data, const void *user, const struct spa_dict *info)
{
struct impl *impl = data;
const char *name, *type, *mode;

View file

@ -49,7 +49,7 @@ struct entry {
#define TYPE_ANNOUNCE 0
#define TYPE_BROWSE 1
uint32_t type;
void *user;
const void *user;
struct pw_properties *props;
@ -110,7 +110,7 @@ static void service_free(struct service *s)
free(s);
}
struct entry *entry_find(struct pw_zeroconf *zc, uint32_t type, void *user)
struct entry *entry_find(struct pw_zeroconf *zc, uint32_t type, const void *user)
{
struct entry *e;
spa_list_for_each(e, &zc->entries, link)
@ -505,7 +505,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *d)
zeroconf_unref(zc);
}
static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info)
static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, const void *user, const struct spa_dict *info)
{
struct entry *e;
@ -524,7 +524,7 @@ static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, void *user
return e;
}
static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info)
static int set_entry(struct pw_zeroconf *zc, uint32_t type, const void *user, const struct spa_dict *info)
{
struct entry *e;
int res = 0;
@ -546,11 +546,11 @@ static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const st
}
return res;
}
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info)
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info)
{
return set_entry(zc, TYPE_ANNOUNCE, user, info);
}
int pw_zeroconf_set_browse(struct pw_zeroconf *zc, void *user, const struct spa_dict *info)
int pw_zeroconf_set_browse(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info)
{
return set_entry(zc, TYPE_BROWSE, user, info);
}

View file

@ -22,8 +22,8 @@ struct pw_zeroconf_events {
void (*destroy) (void *data);
void (*error) (void *data, int err, const char *message);
void (*added) (void *data, void *user, const struct spa_dict *info);
void (*removed) (void *data, void *user, const struct spa_dict *info);
void (*added) (void *data, const void *user, const struct spa_dict *info);
void (*removed) (void *data, const void *user, const struct spa_dict *info);
};
struct pw_zeroconf * pw_zeroconf_new(struct pw_context *context,
@ -31,8 +31,8 @@ struct pw_zeroconf * pw_zeroconf_new(struct pw_context *context,
void pw_zeroconf_destroy(struct pw_zeroconf *zc);
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info);
int pw_zeroconf_set_browse(struct pw_zeroconf *zc, void *user, const struct spa_dict *info);
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info);
int pw_zeroconf_set_browse(struct pw_zeroconf *zc, const void *user, const struct spa_dict *info);
void pw_zeroconf_add_listener(struct pw_zeroconf *zc,
struct spa_hook *listener,