diff --git a/pipewire-alsa/alsa-plugins/ctl_pipewire.c b/pipewire-alsa/alsa-plugins/ctl_pipewire.c index 1754b7420..60391c495 100644 --- a/pipewire-alsa/alsa-plugins/ctl_pipewire.c +++ b/pipewire-alsa/alsa-plugins/ctl_pipewire.c @@ -98,7 +98,7 @@ struct global { snd_ctl_pipewire_t *ctl; - struct global_info *ginfo; + const struct global_info *ginfo; uint32_t id; uint32_t permissions; @@ -896,7 +896,7 @@ static const struct pw_device_events device_events = { .param = device_event_param, }; -struct global_info device_info = { +static const struct global_info device_info = { .type = PW_TYPE_INTERFACE_Device, .version = PW_VERSION_DEVICE, .events = &device_events, @@ -974,7 +974,7 @@ static const struct pw_node_events node_events = { .param = node_event_param, }; -struct global_info node_info = { +static const struct global_info node_info = { .type = PW_TYPE_INTERFACE_Node, .version = PW_VERSION_NODE, .events = &node_events, @@ -1044,7 +1044,7 @@ static const struct pw_metadata_events metadata_events = { .property = metadata_property, }; -struct global_info metadata_info = { +static const struct global_info metadata_info = { .type = PW_TYPE_INTERFACE_Metadata, .version = PW_VERSION_METADATA, .events = &metadata_events, @@ -1076,7 +1076,7 @@ static void registry_event_global(void *data, uint32_t id, const struct spa_dict *props) { snd_ctl_pipewire_t *ctl = data; - struct global_info *info = NULL; + const struct global_info *info = NULL; struct pw_proxy *proxy; const char *str; diff --git a/spa/plugins/alsa/acp-tool.c b/spa/plugins/alsa/acp-tool.c index cd3ad0ba6..bddefab53 100644 --- a/spa/plugins/alsa/acp-tool.c +++ b/spa/plugins/alsa/acp-tool.c @@ -135,7 +135,7 @@ static void on_mute_changed(void *data, struct acp_device *dev) fprintf(stderr, "*** mute %s changed to %d\n", dev->name, mute); } -struct acp_card_events card_events = { +static const struct acp_card_events card_events = { ACP_VERSION_CARD_EVENTS, .props_changed = card_props_changed, .profile_changed = card_profile_changed, diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 2d271c468..58bd3af91 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -876,7 +876,7 @@ static void on_mute_changed(void *data, struct acp_device *dev) spa_device_emit_event(&this->hooks, event); } -struct acp_card_events card_events = { +static const struct acp_card_events card_events = { ACP_VERSION_CARD_EVENTS, .props_changed = card_props_changed, .profile_changed = card_profile_changed, diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 3252fd4db..49e7fee13 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -591,7 +591,7 @@ static void fmt_input_port_info(void *data, spa_node_emit_port_info(&this->hooks, direction, port, info); } -static struct spa_node_events fmt_input_events = { +static const struct spa_node_events fmt_input_events = { SPA_VERSION_NODE_EVENTS, .port_info = fmt_input_port_info, .result = on_node_result, @@ -612,7 +612,7 @@ static void fmt_output_port_info(void *data, spa_node_emit_port_info(&this->hooks, direction, port, info); } -static struct spa_node_events fmt_output_events = { +static const struct spa_node_events fmt_output_events = { SPA_VERSION_NODE_EVENTS, .port_info = fmt_output_port_info, .result = on_node_result, @@ -655,13 +655,13 @@ static void on_channelmix_info(void *data, const struct spa_node_info *info) emit_node_info(this, false); } -static struct spa_node_events channelmix_events = { +static const struct spa_node_events channelmix_events = { SPA_VERSION_NODE_EVENTS, .info = on_channelmix_info, .result = on_node_result, }; -static struct spa_node_events resample_events = { +static const struct spa_node_events resample_events = { SPA_VERSION_NODE_EVENTS, .result = on_node_result, }; diff --git a/spa/plugins/audioconvert/test-fmt-ops.c b/spa/plugins/audioconvert/test-fmt-ops.c index 7ef038a1c..c234d0b23 100644 --- a/spa/plugins/audioconvert/test-fmt-ops.c +++ b/spa/plugins/audioconvert/test-fmt-ops.c @@ -124,8 +124,8 @@ static void run_test(const char *name, static void test_f32_u8(void) { - const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; - uint8_t out[] = { 128, 255, 0, 191, 64, 255, 0, }; + static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; + static const uint8_t out[] = { 128, 255, 0, 191, 64, 255, 0, }; run_test("test_f32_u8", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, true, conv_f32_to_u8_c); @@ -139,8 +139,8 @@ static void test_f32_u8(void) static void test_u8_f32(void) { - uint8_t in[] = { 128, 255, 0, 192, 64, }; - const float out[] = { 0.0f, 0.9921875f, -1.0f, 0.5f, -0.5f, }; + static const uint8_t in[] = { 128, 255, 0, 192, 64, }; + static const float out[] = { 0.0f, 0.9921875f, -1.0f, 0.5f, -0.5f, }; run_test("test_u8_f32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, true, conv_u8_to_f32_c); @@ -154,8 +154,8 @@ static void test_u8_f32(void) static void test_f32_s16(void) { - const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; - const int16_t out[] = { 0, 32767, -32767, 16383, -16383, 32767, -32767 }; + static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; + static const int16_t out[] = { 0, 32767, -32767, 16383, -16383, 32767, -32767 }; run_test("test_f32_s16", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, true, conv_f32_to_s16_c); @@ -175,8 +175,8 @@ static void test_f32_s16(void) static void test_s16_f32(void) { - const int16_t in[] = { 0, 32767, -32767, 16383, -16383, }; - const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f }; + static const int16_t in[] = { 0, 32767, -32767, 16383, -16383, }; + static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f }; run_test("test_s16_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, false, conv_s16_to_f32d_c); @@ -196,8 +196,8 @@ static void test_s16_f32(void) static void test_f32_s32(void) { - const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; - const int32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100, + static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; + static const int32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100, 0x7fffff00, 0x80000100 }; run_test("test_f32_s32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), @@ -218,8 +218,8 @@ static void test_f32_s32(void) static void test_s32_f32(void) { - const int32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 }; - const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; + static const int32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 }; + static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; run_test("test_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, false, conv_s32_to_f32d_c); @@ -239,12 +239,12 @@ static void test_s32_f32(void) static void test_f32_s24(void) { - const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; + static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; #if __BYTE_ORDER == __LITTLE_ENDIAN - const uint8_t out[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80, + static const uint8_t out[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80 }; #else - const uint8_t out[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01, + static const uint8_t out[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01, 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01 }; #endif @@ -261,13 +261,13 @@ static void test_f32_s24(void) static void test_s24_f32(void) { #if __BYTE_ORDER == __LITTLE_ENDIAN - const uint8_t in[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80, + static const uint8_t in[] = { 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80, 0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, }; #else - const uint8_t in[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01, + static const uint8_t in[] = { 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01, 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, }; #endif - const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; + static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; run_test("test_s24_f32d", in, 3, out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, false, conv_s24_to_f32d_c); @@ -299,8 +299,8 @@ static void test_s24_f32(void) static void test_f32_s24_32(void) { - const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; - const int32_t out[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001, + static const float in[] = { 0.0f, 1.0f, -1.0f, 0.5f, -0.5f, 1.1f, -1.1f }; + static const int32_t out[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001, 0x7fffff, 0xff800001 }; run_test("test_f32_s24_32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), @@ -315,8 +315,8 @@ static void test_f32_s24_32(void) static void test_s24_32_f32(void) { - const int32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 }; - const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; + static const int32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 }; + static const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999999404f, -0.4999999404f, }; run_test("test_s24_32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), true, false, conv_s24_32_to_f32d_c); diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c index 05b5d91ca..27b4cfbb8 100644 --- a/spa/plugins/bluez5/a2dp-codec-aac.c +++ b/spa/plugins/bluez5/a2dp-codec-aac.c @@ -61,7 +61,7 @@ struct impl { static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { - const a2dp_aac_t a2dp_aac = { + static const a2dp_aac_t a2dp_aac = { .object_type = /* NOTE: AAC Long Term Prediction and AAC Scalable are * not supported by the FDK-AAC library. */ @@ -86,11 +86,12 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, .vbr = 1, AAC_INIT_BITRATE(DEFAULT_AAC_BITRATE) }; + memcpy(caps, &a2dp_aac, sizeof(a2dp_aac)); return sizeof(a2dp_aac); } -static struct a2dp_codec_config +static const struct a2dp_codec_config aac_frequencies[] = { { AAC_SAMPLING_FREQ_48000, 48000, 11 }, { AAC_SAMPLING_FREQ_44100, 44100, 10 }, @@ -106,7 +107,7 @@ aac_frequencies[] = { { AAC_SAMPLING_FREQ_8000, 8000, 0 }, }; -static struct a2dp_codec_config +static const struct a2dp_codec_config aac_channel_modes[] = { { AAC_CHANNELS_2, 2, 1 }, { AAC_CHANNELS_1, 1, 0 }, diff --git a/spa/plugins/bluez5/a2dp-codec-aptx.c b/spa/plugins/bluez5/a2dp-codec-aptx.c index 53b92c734..240da71dd 100644 --- a/spa/plugins/bluez5/a2dp-codec-aptx.c +++ b/spa/plugins/bluez5/a2dp-codec-aptx.c @@ -76,7 +76,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, return actual_conf_size; } -static struct a2dp_codec_config +static const struct a2dp_codec_config aptx_frequencies[] = { { APTX_SAMPLING_FREQ_48000, 48000, 3 }, { APTX_SAMPLING_FREQ_44100, 44100, 2 }, diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index f767affec..5494cc50f 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -81,7 +81,7 @@ struct impl { static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { - const a2dp_ldac_t a2dp_ldac = { + static const a2dp_ldac_t a2dp_ldac = { .info.vendor_id = LDAC_VENDOR_ID, .info.codec_id = LDAC_CODEC_ID, .frequency = LDACBT_SAMPLING_FREQ_044100 | @@ -92,11 +92,12 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8 LDACBT_CHANNEL_MODE_DUAL_CHANNEL | LDACBT_CHANNEL_MODE_STEREO, }; + memcpy(caps, &a2dp_ldac, sizeof(a2dp_ldac)); return sizeof(a2dp_ldac); } -static struct a2dp_codec_config +static const struct a2dp_codec_config ldac_frequencies[] = { { LDACBT_SAMPLING_FREQ_044100, 44100, 3 }, { LDACBT_SAMPLING_FREQ_048000, 48000, 2 }, @@ -104,7 +105,7 @@ ldac_frequencies[] = { { LDACBT_SAMPLING_FREQ_096000, 96000, 0 }, }; -static struct a2dp_codec_config +static const struct a2dp_codec_config ldac_channel_modes[] = { { LDACBT_CHANNEL_MODE_STEREO, 2, 2 }, { LDACBT_CHANNEL_MODE_DUAL_CHANNEL, 2, 1 }, diff --git a/spa/plugins/bluez5/a2dp-codec-sbc.c b/spa/plugins/bluez5/a2dp-codec-sbc.c index 875adba04..c90eb1936 100644 --- a/spa/plugins/bluez5/a2dp-codec-sbc.c +++ b/spa/plugins/bluez5/a2dp-codec-sbc.c @@ -55,7 +55,7 @@ struct impl { static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]) { - const a2dp_sbc_t a2dp_sbc = { + static const a2dp_sbc_t a2dp_sbc = { .frequency = SBC_SAMPLING_FREQ_16000 | SBC_SAMPLING_FREQ_32000 | @@ -80,6 +80,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, .min_bitpool = SBC_MIN_BITPOOL, .max_bitpool = SBC_MAX_BITPOOL, }; + memcpy(caps, &a2dp_sbc, sizeof(a2dp_sbc)); return sizeof(a2dp_sbc); } @@ -121,7 +122,7 @@ static uint8_t default_bitpool(uint8_t freq, uint8_t mode, bool xq) } -static struct a2dp_codec_config +static const struct a2dp_codec_config sbc_frequencies[] = { { SBC_SAMPLING_FREQ_48000, 48000, 3 }, { SBC_SAMPLING_FREQ_44100, 44100, 2 }, @@ -129,13 +130,13 @@ sbc_frequencies[] = { { SBC_SAMPLING_FREQ_16000, 16000, 0 }, }; -static struct a2dp_codec_config +static const struct a2dp_codec_config sbc_xq_frequencies[] = { { SBC_SAMPLING_FREQ_44100, 44100, 1 }, { SBC_SAMPLING_FREQ_48000, 48000, 0 }, }; -static struct a2dp_codec_config +static const struct a2dp_codec_config sbc_channel_modes[] = { { SBC_CHANNEL_MODE_JOINT_STEREO, 2, 3 }, { SBC_CHANNEL_MODE_STEREO, 2, 2 }, @@ -143,7 +144,7 @@ sbc_channel_modes[] = { { SBC_CHANNEL_MODE_MONO, 1, 0 }, }; -static struct a2dp_codec_config +static const struct a2dp_codec_config sbc_xq_channel_modes[] = { { SBC_CHANNEL_MODE_DUAL_CHANNEL, 2, 2 }, { SBC_CHANNEL_MODE_JOINT_STEREO, 2, 1 }, @@ -158,7 +159,7 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags, a2dp_sbc_t conf; int bitpool, i; size_t n; - struct a2dp_codec_config * configs; + const struct a2dp_codec_config *configs; bool xq = false; diff --git a/spa/plugins/bluez5/a2dp-codecs.c b/spa/plugins/bluez5/a2dp-codecs.c index 38dd809d3..da169d451 100644 --- a/spa/plugins/bluez5/a2dp-codecs.c +++ b/spa/plugins/bluez5/a2dp-codecs.c @@ -134,7 +134,7 @@ extern struct a2dp_codec a2dp_codec_aptx; extern struct a2dp_codec a2dp_codec_aptx_hd; #endif -const struct a2dp_codec *a2dp_codec_list[] = { +static const struct a2dp_codec * const a2dp_codec_list[] = { #if ENABLE_LDAC &a2dp_codec_ldac, #endif @@ -150,6 +150,7 @@ const struct a2dp_codec *a2dp_codec_list[] = { #endif &a2dp_codec_sbc_xq, &a2dp_codec_sbc, - NULL, + NULL }; -const struct a2dp_codec **a2dp_codecs = a2dp_codec_list; + +const struct a2dp_codec * const * const a2dp_codecs = a2dp_codec_list; diff --git a/spa/plugins/bluez5/a2dp-codecs.h b/spa/plugins/bluez5/a2dp-codecs.h index b2b2a16e9..3120ca275 100644 --- a/spa/plugins/bluez5/a2dp-codecs.h +++ b/spa/plugins/bluez5/a2dp-codecs.h @@ -371,7 +371,7 @@ struct a2dp_codec { int (*increase_bitpool) (void *data); }; -extern const struct a2dp_codec **a2dp_codecs; +extern const struct a2dp_codec * const * const a2dp_codecs; struct a2dp_codec_config { uint32_t config; diff --git a/spa/plugins/bluez5/backend-native.c b/spa/plugins/bluez5/backend-native.c index 3e3bc2491..d10fbdf2c 100644 --- a/spa/plugins/bluez5/backend-native.c +++ b/spa/plugins/bluez5/backend-native.c @@ -698,9 +698,11 @@ static bool rfcomm_hfp_ag(struct spa_source *source, char* buf) /* retrieve supported codecs */ /* response has the form AT+BAC=,, strategy: split the string into tokens */ + static const char separators[] = "=,"; + char* token; - char separators[] = "=,"; int cntr = 0; + token = strtok (buf, separators); while (token != NULL) { @@ -855,13 +857,14 @@ static bool rfcomm_hfp_ag(struct spa_source *source, char* buf) static bool rfcomm_hfp_hf(struct spa_source *source, char* buf) { + static const char separators[] = "\r\n:"; + struct rfcomm *rfcomm = source->data; struct impl *backend = rfcomm->backend; unsigned int features; unsigned int gain; unsigned int selected_codec; char* token; - char separators[] = "\r\n:"; token = strtok(buf, separators); while (token != NULL) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 9ce83ab5f..a8b39c3f6 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -2534,7 +2534,7 @@ static int a2dp_codec_switch_cmp(const void *a, const void *b) } /* Ensure there's a transport for at least one of the listed codecs */ -int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec **codecs) +int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec * const *codecs) { struct spa_bt_a2dp_codec_switch *sw; struct spa_bt_remote_endpoint *ep; diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 318383c95..47041c0b3 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -163,7 +163,7 @@ static void init_node(struct impl *this, struct node *node, uint32_t id) static const struct a2dp_codec *get_a2dp_codec(enum spa_bluetooth_audio_codec id) { - const struct a2dp_codec **c; + const struct a2dp_codec * const *c; for (c = a2dp_codecs; *c; ++c) if ((*c)->id == id) @@ -684,7 +684,9 @@ static int set_profile(struct impl *this, uint32_t profile, enum spa_bluetooth_a */ if (profile == DEVICE_PROFILE_A2DP && !(this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE)) { int ret; - const struct a2dp_codec *codec_list[2], **codecs, *a2dp_codec; + const struct a2dp_codec *codec_list[2]; + const struct a2dp_codec * const *codecs; + const struct a2dp_codec *a2dp_codec; a2dp_codec = get_a2dp_codec(codec); if (a2dp_codec == NULL) { diff --git a/spa/plugins/bluez5/defs.h b/spa/plugins/bluez5/defs.h index 30d8fd97a..8eedd0f19 100644 --- a/spa/plugins/bluez5/defs.h +++ b/spa/plugins/bluez5/defs.h @@ -463,7 +463,7 @@ struct spa_bt_device *spa_bt_device_find_by_address(struct spa_bt_monitor *monit int spa_bt_device_add_profile(struct spa_bt_device *device, enum spa_bt_profile profile); int spa_bt_device_connect_profile(struct spa_bt_device *device, enum spa_bt_profile profile); int spa_bt_device_check_profiles(struct spa_bt_device *device, bool force); -int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec **codecs); +int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec * const *codecs); bool spa_bt_device_supports_a2dp_codec(struct spa_bt_device *device, const struct a2dp_codec *codec); const struct a2dp_codec **spa_bt_device_get_supported_a2dp_codecs(struct spa_bt_device *device, size_t *count); int spa_bt_device_ensure_hfp_codec(struct spa_bt_device *device, unsigned int codec); diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index f7cfe6a3e..5443b5a86 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -693,18 +693,19 @@ static int impl_node_send_command(void *object, const struct spa_command *comman static void emit_node_info(struct impl *this, bool full) { - bool is_ag = (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); - struct spa_dict_item ag_node_info_items[] = { + static const struct spa_dict_item hu_node_info_items[] = { + { SPA_KEY_DEVICE_API, "bluez5" }, + { SPA_KEY_MEDIA_CLASS, "Audio/Sink" }, + { SPA_KEY_NODE_DRIVER, "true" }, + }; + + const struct spa_dict_item ag_node_info_items[] = { { SPA_KEY_DEVICE_API, "bluez5" }, { SPA_KEY_MEDIA_CLASS, "Stream/Input/Audio" }, { "media.name", ((this->transport && this->transport->device->name) ? this->transport->device->name : "HSP/HFP") }, }; - struct spa_dict_item hu_node_info_items[] = { - { SPA_KEY_DEVICE_API, "bluez5" }, - { SPA_KEY_MEDIA_CLASS, "Audio/Sink" }, - { SPA_KEY_NODE_DRIVER, "true" }, - }; + bool is_ag = (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); uint64_t old = full ? this->info.change_mask : 0; if (full) @@ -1311,7 +1312,7 @@ static const struct spa_dict_item info_items[] = { static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); -struct spa_handle_factory spa_sco_sink_factory = { +const struct spa_handle_factory spa_sco_sink_factory = { SPA_VERSION_HANDLE_FACTORY, SPA_NAME_API_BLUEZ5_SCO_SINK, &info, diff --git a/spa/plugins/bluez5/sco-source.c b/spa/plugins/bluez5/sco-source.c index 99a406aa7..bd3d4a8cd 100644 --- a/spa/plugins/bluez5/sco-source.c +++ b/spa/plugins/bluez5/sco-source.c @@ -722,20 +722,21 @@ static int impl_node_send_command(void *object, const struct spa_command *comman static void emit_node_info(struct impl *this, bool full) { - bool is_ag = this->transport && (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); - char latency[64] = "128/8000"; - struct spa_dict_item ag_node_info_items[] = { - { SPA_KEY_DEVICE_API, "bluez5" }, - { SPA_KEY_MEDIA_CLASS, "Stream/Output/Audio" }, - { SPA_KEY_NODE_LATENCY, latency }, - { "media.name", ((this->transport && this->transport->device->name) ? - this->transport->device->name : "HSP/HFP") }, - }; - struct spa_dict_item hu_node_info_items[] = { + static const struct spa_dict_item hu_node_info_items[] = { { SPA_KEY_DEVICE_API, "bluez5" }, { SPA_KEY_MEDIA_CLASS, "Audio/Source" }, { SPA_KEY_NODE_DRIVER, "true" }, }; + + char latency[64] = "128/8000"; + const struct spa_dict_item ag_node_info_items[] = { + { SPA_KEY_DEVICE_API, "bluez5" }, + { SPA_KEY_MEDIA_CLASS, "Stream/Output/Audio" }, + { SPA_KEY_NODE_LATENCY, latency }, + { "media.name", ((this->transport && this->transport->device->name) ? + this->transport->device->name : "HSP/HFP") }, + }; + bool is_ag = this->transport && (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); uint64_t old = full ? this->info.change_mask : 0; if (full) @@ -1372,7 +1373,7 @@ static const struct spa_dict_item info_items[] = { static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items); -struct spa_handle_factory spa_sco_source_factory = { +const struct spa_handle_factory spa_sco_source_factory = { SPA_VERSION_HANDLE_FACTORY, SPA_NAME_API_BLUEZ5_SCO_SOURCE, &info, diff --git a/spa/plugins/libcamera/libcamera_wrapper.cpp b/spa/plugins/libcamera/libcamera_wrapper.cpp index 72afd681f..58c062412 100644 --- a/spa/plugins/libcamera/libcamera_wrapper.cpp +++ b/spa/plugins/libcamera/libcamera_wrapper.cpp @@ -75,7 +75,7 @@ using namespace controls; extern "C" { - static struct { + static const struct { spa_video_format video_format; unsigned int drm_fourcc; } format_map[] = { diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index 21f103588..ddd6d2630 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -112,7 +112,7 @@ static uint32_t get_count(struct impl *this) #else static uint32_t get_count(struct impl *this) { - int mib[] = {CTL_HW, HW_NCPU}; + static const int mib[] = {CTL_HW, HW_NCPU}; int r; size_t rSize = sizeof(r); if(-1 == sysctl(mib, 2, &r, &rSize, 0, 0)) diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index d0a59a5a0..e6aa51447 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -81,7 +81,7 @@ impl_log_logv(void *object, char timestamp[15] = {0}; char filename[64] = {0}; char location[1000 + RESERVED_LENGTH], *p, *s; - static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" }; + static const char * const levels[] = { "-", "E", "W", "I", "D", "T", "*T*" }; const char *prefix = "", *suffix = ""; int size, len; bool do_trace; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index f151652b3..ef90bd80f 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -658,9 +658,11 @@ spa_v4l2_enum_format(struct impl *this, int seq, goto exit; } if (filter) { + static const struct spa_rectangle step = {1, 1}; + + const struct spa_rectangle *values; const struct spa_pod_prop *p; struct spa_pod *val; - const struct spa_rectangle step = { 1, 1 }, *values; uint32_t choice, i, n_values; /* check if we have a fixed frame size */ @@ -749,10 +751,12 @@ spa_v4l2_enum_format(struct impl *this, int seq, goto exit; } if (filter) { + static const struct spa_fraction step = {1, 1}; + + const struct spa_fraction *values; const struct spa_pod_prop *p; struct spa_pod *val; uint32_t i, n_values, choice; - const struct spa_fraction step = { 1, 1 }, *values; if (!(p = spa_pod_find_prop(filter, NULL, SPA_FORMAT_VIDEO_framerate))) goto have_framerate; diff --git a/spa/plugins/vulkan/vulkan-utils.c b/spa/plugins/vulkan/vulkan-utils.c index 9560bf6a2..3552af080 100644 --- a/spa/plugins/vulkan/vulkan-utils.c +++ b/spa/plugins/vulkan/vulkan-utils.c @@ -100,7 +100,7 @@ static int vkresult_to_errno(VkResult result) static int createInstance(struct vulkan_state *s) { - const VkApplicationInfo applicationInfo = { + static const VkApplicationInfo applicationInfo = { .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pApplicationName = "PipeWire", .applicationVersion = 0, @@ -108,10 +108,11 @@ static int createInstance(struct vulkan_state *s) .engineVersion = 0, .apiVersion = VK_API_VERSION_1_1 }; - const char *extensions[] = { + static const char * const extensions[] = { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME }; - VkInstanceCreateInfo createInfo = { + + const VkInstanceCreateInfo createInfo = { .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pApplicationInfo = &applicationInfo, .enabledExtensionCount = 1, @@ -166,17 +167,18 @@ static int findPhysicalDevice(struct vulkan_state *s) static int createDevice(struct vulkan_state *s) { - VkDeviceQueueCreateInfo queueCreateInfo = { + + const VkDeviceQueueCreateInfo queueCreateInfo = { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, .queueFamilyIndex = s->queueFamilyIndex, .queueCount = 1, .pQueuePriorities = (const float[]) { 1.0f } }; - const char *extensions[] = { + static const char * const extensions[] = { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME }; - VkDeviceCreateInfo deviceCreateInfo = { + const VkDeviceCreateInfo deviceCreateInfo = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, .queueCreateInfoCount = 1, .pQueueCreateInfos = &queueCreateInfo, @@ -188,7 +190,7 @@ static int createDevice(struct vulkan_state *s) vkGetDeviceQueue(s->device, s->queueFamilyIndex, 0, &s->queue); - VkFenceCreateInfo fenceCreateInfo = { + static const VkFenceCreateInfo fenceCreateInfo = { .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .flags = 0, }; @@ -215,11 +217,11 @@ static uint32_t findMemoryType(struct vulkan_state *s, static int createDescriptors(struct vulkan_state *s) { - VkDescriptorPoolSize descriptorPoolSize = { + static const VkDescriptorPoolSize descriptorPoolSize = { .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, .descriptorCount = 1 }; - VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = { + static const VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .maxSets = 1, .poolSizeCount = 1, @@ -230,13 +232,13 @@ static int createDescriptors(struct vulkan_state *s) &descriptorPoolCreateInfo, NULL, &s->descriptorPool)); - VkDescriptorSetLayoutBinding descriptorSetLayoutBinding = { + static const VkDescriptorSetLayoutBinding descriptorSetLayoutBinding = { .binding = 0, .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, .descriptorCount = 1, .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT }; - VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { + static const VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &descriptorSetLayoutBinding @@ -245,7 +247,7 @@ static int createDescriptors(struct vulkan_state *s) &descriptorSetLayoutCreateInfo, NULL, &s->descriptorSetLayout)); - VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { + const VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, .descriptorPool = s->descriptorPool, .descriptorSetCount = 1, @@ -260,7 +262,7 @@ static int createDescriptors(struct vulkan_state *s) static int createBuffer(struct vulkan_state *s, uint32_t id) { - VkBufferCreateInfo bufferCreateInfo = { + const VkBufferCreateInfo bufferCreateInfo = { .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .size = s->bufferSize, .usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, @@ -274,14 +276,14 @@ static int createBuffer(struct vulkan_state *s, uint32_t id) vkGetBufferMemoryRequirements(s->device, s->buffers[id].buffer, &memoryRequirements); - VkMemoryAllocateInfo allocateInfo = { + const VkMemoryAllocateInfo allocateInfo = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, - .allocationSize = memoryRequirements.size + .allocationSize = memoryRequirements.size, + .memoryTypeIndex = findMemoryType(s, + memoryRequirements.memoryTypeBits, + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT), }; - allocateInfo.memoryTypeIndex = findMemoryType(s, - memoryRequirements.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); VK_CHECK_RESULT(vkAllocateMemory(s->device, &allocateInfo, NULL, &s->buffers[id].memory)); @@ -296,12 +298,12 @@ static int updateDescriptors(struct vulkan_state *s, uint32_t buffer_id) if (s->current_buffer_id == buffer_id) return 0; - VkDescriptorBufferInfo descriptorBufferInfo = { + const VkDescriptorBufferInfo descriptorBufferInfo = { .buffer = s->buffers[buffer_id].buffer, .offset = 0, .range = s->bufferSize, }; - VkWriteDescriptorSet writeDescriptorSet = { + const VkWriteDescriptorSet writeDescriptorSet = { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = s->descriptorSet, .dstBinding = 0, @@ -335,7 +337,7 @@ static VkShaderModule createShaderModule(struct vulkan_state *s, const char* sha data = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - VkShaderModuleCreateInfo shaderModuleCreateInfo = { + const VkShaderModuleCreateInfo shaderModuleCreateInfo = { .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .codeSize = stat.st_size, .pCode = data, @@ -355,13 +357,13 @@ static VkShaderModule createShaderModule(struct vulkan_state *s, const char* sha static int createComputePipeline(struct vulkan_state *s, const char *shader_file) { - const VkPushConstantRange range = { + static const VkPushConstantRange range = { .stageFlags = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, .offset = 0, .size = sizeof(struct push_constants) }; - VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { + const VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 1, .pSetLayouts = &s->descriptorSetLayout, @@ -376,13 +378,13 @@ static int createComputePipeline(struct vulkan_state *s, const char *shader_file if (s->computeShaderModule == VK_NULL_HANDLE) return -ENOENT; - VkPipelineShaderStageCreateInfo shaderStageCreateInfo = { + const VkPipelineShaderStageCreateInfo shaderStageCreateInfo = { .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .stage = VK_SHADER_STAGE_COMPUTE_BIT, .module = s->computeShaderModule, .pName = "main", }; - VkComputePipelineCreateInfo pipelineCreateInfo = { + const VkComputePipelineCreateInfo pipelineCreateInfo = { .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, .stage = shaderStageCreateInfo, .layout = s->pipelineLayout, @@ -395,7 +397,7 @@ static int createComputePipeline(struct vulkan_state *s, const char *shader_file static int createCommandBuffer(struct vulkan_state *s) { - VkCommandPoolCreateInfo commandPoolCreateInfo = { + const VkCommandPoolCreateInfo commandPoolCreateInfo = { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, .queueFamilyIndex = s->queueFamilyIndex, @@ -404,7 +406,7 @@ static int createCommandBuffer(struct vulkan_state *s) &commandPoolCreateInfo, NULL, &s->commandPool)); - VkCommandBufferAllocateInfo commandBufferAllocateInfo = { + const VkCommandBufferAllocateInfo commandBufferAllocateInfo = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, .commandPool = s->commandPool, .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, @@ -419,7 +421,7 @@ static int createCommandBuffer(struct vulkan_state *s) static int runCommandBuffer(struct vulkan_state *s) { - VkCommandBufferBeginInfo beginInfo = { + static const VkCommandBufferBeginInfo beginInfo = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, }; @@ -440,7 +442,7 @@ static int runCommandBuffer(struct vulkan_state *s) VK_CHECK_RESULT(vkResetFences(s->device, 1, &s->fence)); - VkSubmitInfo submitInfo = { + const VkSubmitInfo submitInfo = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, .pCommandBuffers = &s->commandBuffer, @@ -476,7 +478,7 @@ int spa_vulkan_use_buffers(struct vulkan_state *s, uint32_t flags, for (i = 0; i < n_buffers; i++) { createBuffer(s, i); - VkMemoryGetFdInfoKHR getFdInfo = { + const VkMemoryGetFdInfoKHR getFdInfo = { .sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR, .memory = s->buffers[i].memory, .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT diff --git a/src/examples/media-session/restore-stream.c b/src/examples/media-session/restore-stream.c index 9636ede76..afa5b2fd9 100644 --- a/src/examples/media-session/restore-stream.c +++ b/src/examples/media-session/restore-stream.c @@ -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]))) { diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 8d6026a67..32f93463d 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -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, diff --git a/src/modules/module-client-node/v0/client-node.c b/src/modules/module-client-node/v0/client-node.c index 800925737..78767f252 100644 --- a/src/modules/module-client-node/v0/client-node.c +++ b/src/modules/module-client-node/v0/client-node.c @@ -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; diff --git a/src/modules/module-protocol-native/protocol-native.c b/src/modules/module-protocol-native/protocol-native.c index 46c115e93..411bd5098 100644 --- a/src/modules/module-protocol-native/protocol-native.c +++ b/src/modules/module-protocol-native/protocol-native.c @@ -2015,7 +2015,7 @@ pw_protocol_native_registry_event_demarshal[PW_REGISTRY_EVENT_NUM] = [PW_REGISTRY_EVENT_GLOBAL_REMOVE] = { ®istry_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, diff --git a/src/modules/module-protocol-native/v0/typemap.h b/src/modules/module-protocol-native/v0/typemap.h index de671f5e2..48d3cced4 100644 --- a/src/modules/module-protocol-native/v0/typemap.h +++ b/src/modules/module-protocol-native/v0/typemap.h @@ -1,5 +1,4 @@ - -const struct type_info { +static const struct type_info { const char *type; const char *name; uint32_t id; diff --git a/src/modules/module-protocol-pulse/defs.h b/src/modules/module-protocol-pulse/defs.h index ce3e0b366..bded84956 100644 --- a/src/modules/module-protocol-pulse/defs.h +++ b/src/modules/module-protocol-pulse/defs.h @@ -220,7 +220,7 @@ enum { SOURCE_FLAT_VOLUME = 0x0080U, }; -static const char *port_types[] = { +static const char * const port_types[] = { "unknown", "aux", "speaker", diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index 48424fb4f..0233772e0 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -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", diff --git a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c index c86f6d596..fde9bef0a 100644 --- a/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c +++ b/src/modules/module-protocol-pulse/modules/module-zeroconf-publish.c @@ -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) diff --git a/src/modules/module-protocol-simple.c b/src/modules/module-protocol-simple.c index 38ba69541..344b7b030 100644 --- a/src/modules/module-protocol-simple.c +++ b/src/modules/module-protocol-simple.c @@ -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, }; diff --git a/src/modules/module-session-manager/client-endpoint/client-endpoint.c b/src/modules/module-session-manager/client-endpoint/client-endpoint.c index f5f06b925..1ef5268ad 100644 --- a/src/modules/module-session-manager/client-endpoint/client-endpoint.c +++ b/src/modules/module-session-manager/client-endpoint/client-endpoint.c @@ -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, diff --git a/src/modules/module-session-manager/client-endpoint/endpoint.c b/src/modules/module-session-manager/client-endpoint/endpoint.c index 3a2f01086..c53c1045f 100644 --- a/src/modules/module-session-manager/client-endpoint/endpoint.c +++ b/src/modules/module-session-manager/client-endpoint/endpoint.c @@ -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, diff --git a/src/modules/module-session-manager/client-session/client-session.c b/src/modules/module-session-manager/client-session/client-session.c index 066738609..5842ab35a 100644 --- a/src/modules/module-session-manager/client-session/client-session.c +++ b/src/modules/module-session-manager/client-session/client-session.c @@ -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, diff --git a/src/modules/module-session-manager/client-session/session.c b/src/modules/module-session-manager/client-session/session.c index e61910234..21d42977f 100644 --- a/src/modules/module-session-manager/client-session/session.c +++ b/src/modules/module-session-manager/client-session/session.c @@ -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 diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 20b9c2ba2..35a6c7a3e 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -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; diff --git a/src/pipewire/impl-core.c b/src/pipewire/impl-core.c index 009fd4c03..56d67cadc 100644 --- a/src/pipewire/impl-core.c +++ b/src/pipewire/impl-core.c @@ -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; diff --git a/src/pipewire/impl-device.c b/src/pipewire/impl-device.c index ae507a36b..775a47780 100644 --- a/src/pipewire/impl-device.c +++ b/src/pipewire/impl-device.c @@ -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; diff --git a/src/pipewire/impl-factory.c b/src/pipewire/impl-factory.c index 27bc1acd9..531057d0d 100644 --- a/src/pipewire/impl-factory.c +++ b/src/pipewire/impl-factory.c @@ -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; diff --git a/src/pipewire/impl-link.c b/src/pipewire/impl-link.c index 28626e58d..019aa685c 100644 --- a/src/pipewire/impl-link.c +++ b/src/pipewire/impl-link.c @@ -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; diff --git a/src/pipewire/impl-metadata.c b/src/pipewire/impl-metadata.c index 8df494e9d..a10cab306 100644 --- a/src/pipewire/impl-metadata.c +++ b/src/pipewire/impl-metadata.c @@ -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; diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index e2bfcd0d9..4f1f7d5c8 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -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; diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index d6fbfa948..6c49fa6b4 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -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; diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index 1737622c3..03127009a 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -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, diff --git a/src/pipewire/settings.c b/src/pipewire/settings.c index bed3c643c..950e9df69 100644 --- a/src/pipewire/settings.c +++ b/src/pipewire/settings.c @@ -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, diff --git a/src/tests/test-client.c b/src/tests/test-client.c index 3346c5a52..5dc22ea82 100644 --- a/src/tests/test-client.c +++ b/src/tests/test-client.c @@ -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); diff --git a/src/tests/test-interfaces.c b/src/tests/test-interfaces.c index 3dbdee4a9..10b541f8f 100644 --- a/src/tests/test-interfaces.c +++ b/src/tests/test-interfaces.c @@ -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); diff --git a/src/tests/test-stream.c b/src/tests/test-stream.c index 70457116c..e9d6d21bc 100644 --- a/src/tests/test-stream.c +++ b/src/tests/test-stream.c @@ -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); diff --git a/src/tools/midifile.c b/src/tools/midifile.c index 204bd1de2..fe4d14c38 100644 --- a/src/tools/midifile.c +++ b/src/tools/midifile.c @@ -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" }; diff --git a/src/tools/pw-cat.c b/src/tools/pw-cat.c index dbd7803fe..4b7b71f76 100644 --- a/src/tools/pw-cat.c +++ b/src/tools/pw-cat.c @@ -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; diff --git a/src/tools/pw-cli.c b/src/tools/pw-cli.c index 18e34c2ed..e622fe948 100644 --- a/src/tools/pw-cli.c +++ b/src/tools/pw-cli.c @@ -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. []", do_load_module }, { "unload-module", "um", "Unload a module. ", 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, diff --git a/src/tools/pw-dump.c b/src/tools/pw-dump.c index c727faa45..5bd4859f7 100644 --- a/src/tools/pw-dump.c +++ b/src/tools/pw-dump.c @@ -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) diff --git a/test/test-context.c b/test/test-context.c index a2e55bbde..74e8d39b3 100644 --- a/test/test-context.c +++ b/test/test-context.c @@ -220,11 +220,7 @@ PWTEST(context_properties) PWTEST(context_support) { - struct pw_main_loop *loop; - struct pw_context *context; - const struct spa_support *support; - uint32_t n_support; - const char * types[] = { + static const char * const types[] = { SPA_TYPE_INTERFACE_DataSystem, SPA_TYPE_INTERFACE_DataLoop, SPA_TYPE_INTERFACE_System, @@ -234,6 +230,11 @@ PWTEST(context_support) SPA_TYPE_INTERFACE_DBus, SPA_TYPE_INTERFACE_CPU }; + + struct pw_main_loop *loop; + struct pw_context *context; + const struct spa_support *support; + uint32_t n_support; size_t i; pw_init(0, NULL); diff --git a/test/test-spa-pod.c b/test/test-spa-pod.c index 6c0860abb..efd69ac5e 100644 --- a/test/test-spa-pod.c +++ b/test/test-spa-pod.c @@ -1570,12 +1570,7 @@ PWTEST(pod_static) PWTEST(pod_overflow) { - uint8_t buffer[1024]; - struct spa_pod_builder b = { 0 }; - struct spa_pod_builder_state state; - struct spa_pod_frame f[2]; - uint32_t idx; - const char *labels[] = { + static const char * const labels[] = { "640x480p59", "720x480i29", "720x480p59", "720x576i25", "720x576p50", "1280x720p24", "1280x720p25", "1280x720p30", "1280x720p50", "1280x720p60", "1920x1080p24", "1920x1080p25", "1920x1080p30", "1920x1080i25", "1920x1080p50", @@ -1599,6 +1594,12 @@ PWTEST(pod_overflow) "3840x2160p24", "3840x2160p25", "3840x2160p30", "3840x2160p50", "3840x2160p60", "4096x2160p24", "4096x2160p25", "4096x2160p30", "4096x2160p50", "4096x2160p59", "4096x2160p60", NULL }; + + uint8_t buffer[1024]; + struct spa_pod_builder b = { 0 }; + struct spa_pod_builder_state state; + struct spa_pod_frame f[2]; + uint32_t idx; struct spa_pod *pod; spa_pod_builder_init(&b, buffer, sizeof(buffer));