mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
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:
parent
48dbb4da3c
commit
f5d51162c4
54 changed files with 303 additions and 241 deletions
|
|
@ -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"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue