treewide: mark things static and const

Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
This commit is contained in:
Barnabás Pőcze 2021-06-27 17:47:13 +02:00
parent 48dbb4da3c
commit f5d51162c4
54 changed files with 303 additions and 241 deletions

View file

@ -408,12 +408,7 @@ static int save_stream(struct stream *str)
static void update_stream(struct stream *str)
{
struct impl *impl = str->impl;
uint32_t i;
const char *p;
char *key;
struct sm_object *obj = &str->obj->obj;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_MEDIA_ROLE,
PW_KEY_APP_ID,
PW_KEY_APP_NAME,
@ -421,6 +416,12 @@ static void update_stream(struct stream *str)
PW_KEY_NODE_NAME,
};
struct impl *impl = str->impl;
uint32_t i;
const char *p;
char *key;
struct sm_object *obj = &str->obj->obj;
key = NULL;
for (i = 0; i < SPA_N_ELEMENTS(keys); i++) {
if ((p = pw_properties_get(obj->props, keys[i]))) {

View file

@ -1098,7 +1098,7 @@ static int client_node_port_buffers(void *data,
return 0;
}
static struct pw_client_node_methods client_node_methods = {
static const struct pw_client_node_methods client_node_methods = {
PW_VERSION_CLIENT_NODE_METHODS,
.get_node = client_node_get_node,
.update = client_node_update,

View file

@ -1095,7 +1095,7 @@ static void client_node0_event(void *data, struct spa_event *event)
}
}
static struct pw_client_node0_methods client_node0_methods = {
static const struct pw_client_node0_methods client_node0_methods = {
PW_VERSION_CLIENT_NODE0_METHODS,
.done = client_node0_done,
.update = client_node0_update,
@ -1303,12 +1303,13 @@ static const struct pw_resource_events resource_events = {
static void convert_properties(struct pw_properties *properties)
{
struct {
static const struct {
const char *from, *to;
} props[] = {
{ "pipewire.autoconnect", PW_KEY_NODE_AUTOCONNECT, },
{ "pipewire.target.node", PW_KEY_NODE_TARGET, }
};
uint32_t i;
const char *str;

View file

@ -2015,7 +2015,7 @@ pw_protocol_native_registry_event_demarshal[PW_REGISTRY_EVENT_NUM] =
[PW_REGISTRY_EVENT_GLOBAL_REMOVE] = { &registry_demarshal_global_remove, 0, }
};
const struct pw_protocol_marshal pw_protocol_native_registry_marshal = {
static const struct pw_protocol_marshal pw_protocol_native_registry_marshal = {
PW_TYPE_INTERFACE_Registry,
PW_VERSION_REGISTRY,
0,
@ -2050,7 +2050,7 @@ pw_protocol_native_module_method_demarshal[PW_MODULE_METHOD_NUM] =
[PW_MODULE_METHOD_ADD_LISTENER] = { NULL, 0, },
};
const struct pw_protocol_marshal pw_protocol_native_module_marshal = {
static const struct pw_protocol_marshal pw_protocol_native_module_marshal = {
PW_TYPE_INTERFACE_Module,
PW_VERSION_MODULE,
0,
@ -2084,7 +2084,7 @@ pw_protocol_native_factory_method_demarshal[PW_FACTORY_METHOD_NUM] =
[PW_FACTORY_METHOD_ADD_LISTENER] = { NULL, 0, },
};
const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
static const struct pw_protocol_marshal pw_protocol_native_factory_marshal = {
PW_TYPE_INTERFACE_Factory,
PW_VERSION_FACTORY,
0,

View file

@ -1,5 +1,4 @@
const struct type_info {
static const struct type_info {
const char *type;
const char *name;
uint32_t id;

View file

@ -220,7 +220,7 @@ enum {
SOURCE_FLAT_VOLUME = 0x0080U,
};
static const char *port_types[] = {
static const char * const port_types[] = {
"unknown",
"aux",
"speaker",

View file

@ -380,7 +380,7 @@ bool channel_map_valid(const struct channel_map *map)
}
static const char *encoding_names[] = {
static const char * const encoding_names[] = {
[ENCODING_ANY] = "ANY",
[ENCODING_PCM] = "PCM",
[ENCODING_AC3_IEC61937] = "AC3-IEC61937",

View file

@ -379,16 +379,16 @@ static void service_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupStat
static void publish_service(struct service *s)
{
AvahiStringList *txt = NULL;
const char *t;
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
const char * const subtype_text[] = {
static const char * const subtype_text[] = {
[SUBTYPE_HARDWARE] = "hardware",
[SUBTYPE_VIRTUAL] = "virtual",
[SUBTYPE_MONITOR] = "monitor"
};
AvahiStringList *txt = NULL;
const char *t;
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
spa_assert(s);
if (!s->userdata->client || avahi_client_get_state(s->userdata->client) != AVAHI_CLIENT_S_RUNNING)

View file

@ -451,7 +451,7 @@ static void on_core_proxy_destroy(void *data)
client_cleanup(client);
}
static struct pw_proxy_events core_proxy_events = {
static const struct pw_proxy_events core_proxy_events = {
PW_VERSION_CORE_EVENTS,
.destroy = on_core_proxy_destroy,
};

View file

@ -78,8 +78,7 @@ static int client_endpoint_stream_update(void *object,
struct pw_properties *props = NULL;
if (!stream) {
struct pw_context *context = pw_global_get_context(endpoint->global);
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_ENDPOINT_ID,
@ -90,6 +89,8 @@ static int client_endpoint_stream_update(void *object,
NULL
};
struct pw_context *context = pw_global_get_context(endpoint->global);
stream = calloc(1, sizeof(struct endpoint_stream));
if (!stream)
goto no_mem;
@ -128,7 +129,7 @@ static int client_endpoint_stream_update(void *object,
return -ENOMEM;
}
static struct pw_client_endpoint_methods methods = {
static const struct pw_client_endpoint_methods methods = {
PW_VERSION_CLIENT_ENDPOINT_METHODS,
.update = client_endpoint_update,
.stream_update = client_endpoint_stream_update,

View file

@ -304,7 +304,7 @@ int endpoint_init(struct endpoint *this,
struct pw_context *context,
struct pw_properties *properties)
{
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_DEVICE_ID,

View file

@ -78,8 +78,7 @@ static int client_session_link_update(void *object,
struct pw_properties *props = NULL;
if (!link) {
struct pw_context *context = pw_global_get_context(session->global);
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_SESSION_ID,
@ -90,6 +89,8 @@ static int client_session_link_update(void *object,
NULL
};
struct pw_context *context = pw_global_get_context(session->global);
link = calloc(1, sizeof(struct endpoint_link));
if (!link)
goto no_mem;
@ -127,7 +128,7 @@ static int client_session_link_update(void *object,
return -ENOMEM;
}
static struct pw_client_session_methods methods = {
static const struct pw_client_session_methods methods = {
PW_VERSION_CLIENT_SESSION_METHODS,
.update = client_session_update,
.link_update = client_session_link_update,

View file

@ -275,7 +275,7 @@ int session_init(struct session *this,
struct pw_context *context,
struct pw_properties *properties)
{
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
NULL

View file

@ -135,7 +135,7 @@ static int client_error(void *object, uint32_t id, int res, const char *error)
return 0;
}
static bool has_key(const char *keys[], const char *key)
static bool has_key(const char * const keys[], const char *key)
{
int i;
for (i = 0; keys[i]; i++) {
@ -147,14 +147,16 @@ static bool has_key(const char *keys[], const char *key)
static int update_properties(struct pw_impl_client *client, const struct spa_dict *dict, bool filter)
{
struct pw_resource *resource;
int changed = 0;
uint32_t i;
const char *old, *ignored[] = {
static const char * const ignored[] = {
PW_KEY_OBJECT_ID,
NULL
};
struct pw_resource *resource;
int changed = 0;
uint32_t i;
const char *old;
for (i = 0; i < dict->n_items; i++) {
if (filter) {
if (strstr(dict->items[i].key, "pipewire.") == dict->items[i].key &&
@ -200,14 +202,16 @@ static void update_busy(struct pw_impl_client *client)
static int finish_register(struct pw_impl_client *client)
{
struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this);
struct pw_impl_client *current;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_ACCESS,
PW_KEY_CLIENT_ACCESS,
PW_KEY_APP_NAME,
NULL
};
struct impl *impl = SPA_CONTAINER_OF(client, struct impl, this);
struct pw_impl_client *current;
if (impl->registered)
return 0;
@ -469,8 +473,7 @@ SPA_EXPORT
int pw_impl_client_register(struct pw_impl_client *client,
struct pw_properties *properties)
{
struct pw_context *context = client->context;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_MODULE_ID,
PW_KEY_PROTOCOL,
PW_KEY_SEC_PID,
@ -480,6 +483,8 @@ int pw_impl_client_register(struct pw_impl_client *client,
NULL
};
struct pw_context *context = client->context;
if (client->registered)
goto error_existed;

View file

@ -609,9 +609,7 @@ SPA_EXPORT
int pw_impl_core_register(struct pw_impl_core *core,
struct pw_properties *properties)
{
struct pw_context *context = core->context;
int res;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_USER_NAME,
PW_KEY_HOST_NAME,
PW_KEY_CORE_NAME,
@ -619,6 +617,9 @@ int pw_impl_core_register(struct pw_impl_core *core,
NULL
};
struct pw_context *context = core->context;
int res;
if (core->registered)
goto error_existed;

View file

@ -554,9 +554,7 @@ SPA_EXPORT
int pw_impl_device_register(struct pw_impl_device *device,
struct pw_properties *properties)
{
struct pw_context *context = device->context;
struct object_data *od;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
@ -569,6 +567,9 @@ int pw_impl_device_register(struct pw_impl_device *device,
NULL
};
struct pw_context *context = device->context;
struct object_data *od;
if (device->registered)
goto error_existed;
@ -644,8 +645,7 @@ static void emit_info_changed(struct pw_impl_device *device)
static int update_properties(struct pw_impl_device *device, const struct spa_dict *dict, bool filter)
{
int changed;
const char *ignored[] = {
static const char * const ignored[] = {
PW_KEY_OBJECT_ID,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
@ -653,6 +653,8 @@ static int update_properties(struct pw_impl_device *device, const struct spa_dic
NULL
};
int changed;
changed = pw_properties_update_ignore(device->properties, dict, filter ? ignored : NULL);
device->info.props = &device->properties->dict;

View file

@ -176,8 +176,7 @@ SPA_EXPORT
int pw_impl_factory_register(struct pw_impl_factory *factory,
struct pw_properties *properties)
{
struct pw_context *context = factory->context;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_NAME,
PW_KEY_FACTORY_TYPE_NAME,
@ -185,6 +184,8 @@ int pw_impl_factory_register(struct pw_impl_factory *factory,
NULL
};
struct pw_context *context = factory->context;
if (factory->registered)
goto error_existed;

View file

@ -1228,9 +1228,7 @@ SPA_EXPORT
int pw_impl_link_register(struct pw_impl_link *link,
struct pw_properties *properties)
{
struct pw_context *context = link->context;
struct pw_impl_node *output_node, *input_node;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
@ -1242,6 +1240,9 @@ int pw_impl_link_register(struct pw_impl_link *link,
NULL
};
struct pw_context *context = link->context;
struct pw_impl_node *output_node, *input_node;
if (link->registered)
goto error_existed;

View file

@ -267,7 +267,7 @@ static int metadata_property(void *object, uint32_t subject, const char *key,
return 0;
}
static struct pw_metadata_events metadata_events = {
static const struct pw_metadata_events metadata_events = {
PW_VERSION_METADATA_EVENTS,
.property = metadata_property,
};
@ -508,13 +508,14 @@ SPA_EXPORT
int pw_impl_metadata_register(struct pw_impl_metadata *metadata,
struct pw_properties *properties)
{
struct pw_context *context = metadata->context;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_MODULE_ID,
PW_KEY_METADATA_NAME,
NULL
};
struct pw_context *context = metadata->context;
if (metadata->registered)
goto error_existed;

View file

@ -650,9 +650,7 @@ SPA_EXPORT
int pw_impl_node_register(struct pw_impl_node *this,
struct pw_properties *properties)
{
struct pw_context *context = this->context;
struct pw_impl_port *port;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
@ -672,6 +670,9 @@ int pw_impl_node_register(struct pw_impl_node *this,
NULL
};
struct pw_context *context = this->context;
struct pw_impl_port *port;
pw_log_debug(NAME" %p: register", this);
if (this->registered)
@ -1273,8 +1274,7 @@ const struct pw_properties *pw_impl_node_get_properties(struct pw_impl_node *nod
static int update_properties(struct pw_impl_node *node, const struct spa_dict *dict, bool filter)
{
int changed;
const char *ignored[] = {
static const char * const ignored[] = {
PW_KEY_OBJECT_ID,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
@ -1283,6 +1283,8 @@ static int update_properties(struct pw_impl_node *node, const struct spa_dict *d
NULL
};
int changed;
changed = pw_properties_update_ignore(node->properties, dict, filter ? ignored : NULL);
node->info.props = &node->properties->dict;

View file

@ -270,8 +270,7 @@ int pw_impl_port_release_mix(struct pw_impl_port *port, struct pw_impl_port_mix
static int update_properties(struct pw_impl_port *port, const struct spa_dict *dict, bool filter)
{
int changed;
const char *ignored[] = {
static const char * const ignored[] = {
PW_KEY_OBJECT_ID,
PW_KEY_PORT_DIRECTION,
PW_KEY_PORT_CONTROL,
@ -280,6 +279,8 @@ static int update_properties(struct pw_impl_port *port, const struct spa_dict *d
NULL
};
int changed;
changed = pw_properties_update_ignore(port->properties, dict, filter ? ignored : NULL);
port->info.props = &port->properties->dict;
@ -876,8 +877,7 @@ static const struct pw_global_events global_events = {
int pw_impl_port_register(struct pw_impl_port *port,
struct pw_properties *properties)
{
struct pw_impl_node *node = port->node;
const char *keys[] = {
static const char * const keys[] = {
PW_KEY_OBJECT_PATH,
PW_KEY_FORMAT_DSP,
PW_KEY_NODE_ID,
@ -894,6 +894,8 @@ int pw_impl_port_register(struct pw_impl_port *port,
NULL
};
struct pw_impl_node *node = port->node;
if (node == NULL || node->global == NULL)
return -EIO;

View file

@ -395,11 +395,12 @@ static void init_i18n(struct support *support)
static void *add_i18n(struct support *support)
{
static struct spa_i18n_methods i18n_methods = {
static const struct spa_i18n_methods i18n_methods = {
SPA_VERSION_I18N_METHODS,
.text = i18n_text,
.ntext = i18n_ntext,
};
support->i18n_iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_I18N,
SPA_VERSION_I18N,

View file

@ -92,7 +92,7 @@ static int metadata_property(void *data, uint32_t subject, const char *key,
return 0;
}
static struct pw_impl_metadata_events metadata_events = {
static const struct pw_impl_metadata_events metadata_events = {
PW_VERSION_IMPL_METADATA_EVENTS,
.destroy = metadata_destroy,
.property = metadata_property,

View file

@ -33,8 +33,7 @@ do { \
static void test_abi(void)
{
struct pw_impl_client_events ev;
struct {
static const struct {
uint32_t version;
void (*destroy) (void *data);
void (*free) (void *data);
@ -45,6 +44,8 @@ static void test_abi(void)
void (*busy_changed) (void *data, bool busy);
} test = { PW_VERSION_IMPL_CLIENT_EVENTS, NULL };
struct pw_impl_client_events ev;
TEST_FUNC(ev, test, destroy);
TEST_FUNC(ev, test, free);
TEST_FUNC(ev, test, initialized);

View file

@ -32,9 +32,7 @@ do { \
static void test_core_abi(void)
{
struct pw_core_methods m;
struct pw_core_events e;
struct {
static const struct {
uint32_t version;
int (*add_listener) (void *object,
struct spa_hook *listener,
@ -54,7 +52,7 @@ static void test_core_abi(void)
size_t user_data_size);
int (*destroy) (void *object, void *proxy);
} methods = { PW_VERSION_CORE_METHODS, };
struct {
static const struct {
uint32_t version;
void (*info) (void *object, const struct pw_core_info *info);
void (*done) (void *object, uint32_t id, int seq);
@ -66,6 +64,9 @@ static void test_core_abi(void)
void (*remove_mem) (void *object, uint32_t id);
} events = { PW_VERSION_CORE_EVENTS, };
struct pw_core_events e;
struct pw_core_methods m;
TEST_FUNC(m, methods, version);
TEST_FUNC(m, methods, add_listener);
TEST_FUNC(m, methods, hello);

View file

@ -36,13 +36,12 @@ do { \
static void test_abi(void)
{
struct pw_stream_events ev;
struct {
static const struct {
uint32_t version;
void (*destroy) (void *data);
void (*state_changed) (void *data, enum pw_stream_state old,
enum pw_stream_state state, const char *error);
void (*control_info) (void *data, uint32_t id, const struct pw_stream_control *control);
void (*control_info) (void *data, uint32_t id, const struct pw_stream_control *control);
void (*io_changed) (void *data, uint32_t id, void *area, uint32_t size);
void (*param_changed) (void *data, uint32_t id, const struct spa_pod *param);
void (*add_buffer) (void *data, struct pw_buffer *buffer);
@ -51,6 +50,8 @@ static void test_abi(void)
void (*drained) (void *data);
} test = { PW_VERSION_STREAM_EVENTS, NULL };
struct pw_stream_events ev;
TEST_FUNC(ev, test, destroy);
TEST_FUNC(ev, test, state_changed);
TEST_FUNC(ev, test, control_info);

View file

@ -461,17 +461,17 @@ int midi_file_write_event(struct midi_file *mf, const struct midi_event *event)
return 0;
}
static const char *event_names[] = {
static const char * const event_names[] = {
"Text", "Copyright", "Sequence/Track Name",
"Instrument", "Lyric", "Marker", "Cue Point",
"Program Name", "Device (Port) Name"
};
static const char *note_names[] = {
static const char * const note_names[] = {
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
};
static const char *controller_names[128] = {
static const char * const controller_names[128] = {
[0] = "Bank Select (coarse)",
[1] = "Modulation Wheel (coarse)",
[2] = "Breath controller (coarse)",
@ -541,7 +541,7 @@ static const char *controller_names[128] = {
[127] = "Poly Operation",
};
static const char *program_names[] = {
static const char * const program_names[] = {
"Acoustic Grand", "Bright Acoustic", "Electric Grand", "Honky-Tonk",
"Electric Piano 1", "Electric Piano 2", "Harpsichord", "Clavinet",
"Celesta", "Glockenspiel", "Music Box", "Vibraphone", "Marimba",
@ -572,19 +572,19 @@ static const char *program_names[] = {
"Applause", "Gunshot"
};
static const char *smpte_rates[] = {
static const char * const smpte_rates[] = {
"24 fps",
"25 fps",
"30 fps (drop frame)",
"30 fps (non drop frame)"
};
static const char *const major_keys[] = {
static const char * const major_keys[] = {
"Unknown major", "Fb", "Cb", "Gb", "Db", "Ab", "Eb", "Bb", "F",
"C", "G", "D", "A", "E", "B", "F#", "C#", "G#", "Unknown major"
};
static const char *const minor_keys[] = {
static const char * const minor_keys[] = {
"Unknown minor", "Dbm", "Abm", "Ebm", "Bbm", "Fm", "Cm", "Gm", "Dm",
"Am", "Em", "Bm", "F#m", "C#m", "G#m", "D#m", "A#m", "E#m", "Unknown minor"
};

View file

@ -1163,7 +1163,7 @@ static int setup_midifile(struct data *data)
static int fill_properties(struct data *data)
{
static const char* table[] = {
static const char * const table[] = {
[SF_STR_TITLE] = PW_KEY_MEDIA_TITLE,
[SF_STR_COPYRIGHT] = PW_KEY_MEDIA_COPYRIGHT,
[SF_STR_SOFTWARE] = PW_KEY_MEDIA_SOFTWARE,
@ -1171,6 +1171,7 @@ static int fill_properties(struct data *data)
[SF_STR_COMMENT] = PW_KEY_MEDIA_COMMENT,
[SF_STR_DATE] = PW_KEY_MEDIA_DATE
};
SF_INFO sfi;
SF_FORMAT_INFO fi;
int res;

View file

@ -202,7 +202,7 @@ static bool do_dump(struct data *data, const char *cmd, char *args, char **error
#define DUMP_NAMES "Core|Module|Device|Node|Port|Factory|Client|Link|Session|Endpoint|EndpointStream"
static struct command command_list[] = {
static const struct command command_list[] = {
{ "help", "h", "Show this help", do_help },
{ "load-module", "lm", "Load a module. <module-name> [<module-arguments>]", do_load_module },
{ "unload-module", "um", "Unload a module. <module-var>", do_not_implemented },
@ -2002,7 +2002,7 @@ enum dump_flags {
is_notype = BIT(3)
};
static const char *dump_types[] = {
static const char * const dump_types[] = {
PW_TYPE_INTERFACE_Core,
PW_TYPE_INTERFACE_Module,
PW_TYPE_INTERFACE_Device,

View file

@ -376,14 +376,16 @@ static void put_pod_value(struct data *d, const char *key, const struct spa_type
SPA_POD_CONTENTS(struct spa_pod, &b->child),
b->child.size);
} else {
void *p;
static const char *range_labels[] = { "default", "min", "max", NULL };
static const char *step_labels[] = { "default", "min", "max", "step", NULL };
static const char *enum_labels[] = { "default", "alt%u" };
static const char *flags_labels[] = { "default", "flag%u" };
const char **labels, *label;
static const char * const range_labels[] = { "default", "min", "max", NULL };
static const char * const step_labels[] = { "default", "min", "max", "step", NULL };
static const char * const enum_labels[] = { "default", "alt%u" };
static const char * const flags_labels[] = { "default", "flag%u" };
const char * const *labels;
const char *label;
char buffer[64];
int max_labels, flags = 0;
void *p;
switch (b->type) {
case SPA_CHOICE_Range:
@ -512,7 +514,7 @@ struct flags_info {
};
static void put_flags(struct data *d, const char *key,
uint64_t flags, struct flags_info *info)
uint64_t flags, const struct flags_info *info)
{
uint32_t i;
put_begin(d, key, "[", STATE_SIMPLE);
@ -526,12 +528,14 @@ static void put_flags(struct data *d, const char *key,
/* core */
static void core_dump(struct object *o)
{
struct data *d = o->data;
struct pw_core_info *i = d->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_CORE_CHANGE_MASK_PROPS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_core_info *i = d->info;
put_begin(d, "info", "{", 0);
put_int(d, "cookie", i->cookie);
put_value(d, "user-name", i->user_name);
@ -552,12 +556,14 @@ static const struct class core_class = {
/* client */
static void client_dump(struct object *o)
{
struct data *d = o->data;
struct pw_client_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_CLIENT_CHANGE_MASK_PROPS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_client_info *i = o->info;
put_begin(d, "info", "{", 0);
put_flags(d, "change-mask", i->change_mask, fl);
put_dict(d, "props", i->props);
@ -606,12 +612,14 @@ static const struct class client_class = {
/* module */
static void module_dump(struct object *o)
{
struct data *d = o->data;
struct pw_module_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_MODULE_CHANGE_MASK_PROPS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_module_info *i = o->info;
put_begin(d, "info", "{", 0);
put_value(d, "name", i->name);
put_value(d, "filename", i->filename);
@ -663,12 +671,14 @@ static const struct class module_class = {
/* factory */
static void factory_dump(struct object *o)
{
struct data *d = o->data;
struct pw_factory_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_FACTORY_CHANGE_MASK_PROPS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_factory_info *i = o->info;
put_begin(d, "info", "{", 0);
put_value(d, "name", i->name);
put_value(d, "type", i->type);
@ -720,13 +730,15 @@ static const struct class factory_class = {
/* device */
static void device_dump(struct object *o)
{
struct data *d = o->data;
struct pw_device_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_DEVICE_CHANGE_MASK_PROPS },
{ "params", PW_DEVICE_CHANGE_MASK_PARAMS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_device_info *i = o->info;
put_begin(d, "info", "{", 0);
put_flags(d, "change-mask", i->change_mask, fl);
put_dict(d, "props", i->props);
@ -802,9 +814,7 @@ static const struct class device_class = {
/* node */
static void node_dump(struct object *o)
{
struct data *d = o->data;
struct pw_node_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "input-ports", PW_NODE_CHANGE_MASK_INPUT_PORTS },
{ "output-ports", PW_NODE_CHANGE_MASK_OUTPUT_PORTS },
{ "state", PW_NODE_CHANGE_MASK_STATE },
@ -812,6 +822,10 @@ static void node_dump(struct object *o)
{ "params", PW_NODE_CHANGE_MASK_PARAMS },
{ NULL, 0 },
};
struct data *d = o->data;
struct pw_node_info *i = o->info;
put_begin(d, "info", "{", 0);
put_int(d, "max-input-ports", i->max_input_ports);
put_int(d, "max-output-ports", i->max_output_ports);
@ -896,13 +910,15 @@ static const struct class node_class = {
/* port */
static void port_dump(struct object *o)
{
struct data *d = o->data;
struct pw_port_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "props", PW_PORT_CHANGE_MASK_PROPS },
{ "params", PW_PORT_CHANGE_MASK_PARAMS },
{ NULL, },
};
struct data *d = o->data;
struct pw_port_info *i = o->info;
put_begin(d, "info", "{", 0);
put_value(d, "direction", pw_direction_as_string(i->direction));
put_flags(d, "change-mask", i->change_mask, fl);
@ -979,14 +995,16 @@ static const struct class port_class = {
/* link */
static void link_dump(struct object *o)
{
struct data *d = o->data;
struct pw_link_info *i = o->info;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "state", PW_LINK_CHANGE_MASK_STATE },
{ "format", PW_LINK_CHANGE_MASK_FORMAT },
{ "props", PW_LINK_CHANGE_MASK_PROPS },
{ NULL, },
};
struct data *d = o->data;
struct pw_link_info *i = o->info;
put_begin(d, "info", "{", 0);
put_int(d, "output-node-id", i->output_node_id);
put_int(d, "output-port-id", i->output_port_id);
@ -1314,14 +1332,16 @@ static const struct pw_registry_events registry_events = {
static void dump_objects(struct data *d)
{
struct object *o;
struct flags_info fl[] = {
static const struct flags_info fl[] = {
{ "r", PW_PERM_R },
{ "w", PW_PERM_W },
{ "x", PW_PERM_X },
{ "m", PW_PERM_M },
{ NULL, },
};
struct object *o;
d->state = STATE_FIRST;
spa_list_for_each(o, &d->object_list, link) {
if (d->id != SPA_ID_INVALID && d->id != o->id)