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

@ -98,7 +98,7 @@ struct global {
snd_ctl_pipewire_t *ctl; snd_ctl_pipewire_t *ctl;
struct global_info *ginfo; const struct global_info *ginfo;
uint32_t id; uint32_t id;
uint32_t permissions; uint32_t permissions;
@ -896,7 +896,7 @@ static const struct pw_device_events device_events = {
.param = device_event_param, .param = device_event_param,
}; };
struct global_info device_info = { static const struct global_info device_info = {
.type = PW_TYPE_INTERFACE_Device, .type = PW_TYPE_INTERFACE_Device,
.version = PW_VERSION_DEVICE, .version = PW_VERSION_DEVICE,
.events = &device_events, .events = &device_events,
@ -974,7 +974,7 @@ static const struct pw_node_events node_events = {
.param = node_event_param, .param = node_event_param,
}; };
struct global_info node_info = { static const struct global_info node_info = {
.type = PW_TYPE_INTERFACE_Node, .type = PW_TYPE_INTERFACE_Node,
.version = PW_VERSION_NODE, .version = PW_VERSION_NODE,
.events = &node_events, .events = &node_events,
@ -1044,7 +1044,7 @@ static const struct pw_metadata_events metadata_events = {
.property = metadata_property, .property = metadata_property,
}; };
struct global_info metadata_info = { static const struct global_info metadata_info = {
.type = PW_TYPE_INTERFACE_Metadata, .type = PW_TYPE_INTERFACE_Metadata,
.version = PW_VERSION_METADATA, .version = PW_VERSION_METADATA,
.events = &metadata_events, .events = &metadata_events,
@ -1076,7 +1076,7 @@ static void registry_event_global(void *data, uint32_t id,
const struct spa_dict *props) const struct spa_dict *props)
{ {
snd_ctl_pipewire_t *ctl = data; snd_ctl_pipewire_t *ctl = data;
struct global_info *info = NULL; const struct global_info *info = NULL;
struct pw_proxy *proxy; struct pw_proxy *proxy;
const char *str; const char *str;

View file

@ -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); 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, ACP_VERSION_CARD_EVENTS,
.props_changed = card_props_changed, .props_changed = card_props_changed,
.profile_changed = card_profile_changed, .profile_changed = card_profile_changed,

View file

@ -876,7 +876,7 @@ static void on_mute_changed(void *data, struct acp_device *dev)
spa_device_emit_event(&this->hooks, event); 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, ACP_VERSION_CARD_EVENTS,
.props_changed = card_props_changed, .props_changed = card_props_changed,
.profile_changed = card_profile_changed, .profile_changed = card_profile_changed,

View file

@ -591,7 +591,7 @@ static void fmt_input_port_info(void *data,
spa_node_emit_port_info(&this->hooks, direction, port, info); 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, SPA_VERSION_NODE_EVENTS,
.port_info = fmt_input_port_info, .port_info = fmt_input_port_info,
.result = on_node_result, .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); 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, SPA_VERSION_NODE_EVENTS,
.port_info = fmt_output_port_info, .port_info = fmt_output_port_info,
.result = on_node_result, .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); emit_node_info(this, false);
} }
static struct spa_node_events channelmix_events = { static const struct spa_node_events channelmix_events = {
SPA_VERSION_NODE_EVENTS, SPA_VERSION_NODE_EVENTS,
.info = on_channelmix_info, .info = on_channelmix_info,
.result = on_node_result, .result = on_node_result,
}; };
static struct spa_node_events resample_events = { static const struct spa_node_events resample_events = {
SPA_VERSION_NODE_EVENTS, SPA_VERSION_NODE_EVENTS,
.result = on_node_result, .result = on_node_result,
}; };

View file

@ -124,8 +124,8 @@ static void run_test(const char *name,
static void test_f32_u8(void) static void test_f32_u8(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 };
uint8_t out[] = { 128, 255, 0, 191, 64, 255, 0, }; 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), run_test("test_f32_u8", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, true, conv_f32_to_u8_c); true, true, conv_f32_to_u8_c);
@ -139,8 +139,8 @@ static void test_f32_u8(void)
static void test_u8_f32(void) static void test_u8_f32(void)
{ {
uint8_t in[] = { 128, 255, 0, 192, 64, }; static const uint8_t in[] = { 128, 255, 0, 192, 64, };
const float out[] = { 0.0f, 0.9921875f, -1.0f, 0.5f, -0.5f, }; 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), run_test("test_u8_f32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, true, conv_u8_to_f32_c); true, true, conv_u8_to_f32_c);
@ -154,8 +154,8 @@ static void test_u8_f32(void)
static void test_f32_s16(void) static void test_f32_s16(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 };
const int16_t out[] = { 0, 32767, -32767, 16383, -16383, 32767, -32767 }; 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), run_test("test_f32_s16", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, true, conv_f32_to_s16_c); true, true, conv_f32_to_s16_c);
@ -175,8 +175,8 @@ static void test_f32_s16(void)
static void test_s16_f32(void) static void test_s16_f32(void)
{ {
const int16_t in[] = { 0, 32767, -32767, 16383, -16383, }; static const int16_t in[] = { 0, 32767, -32767, 16383, -16383, };
const float out[] = { 0.0f, 1.0f, -1.0f, 0.4999847412f, -0.4999847412f }; 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), run_test("test_s16_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, false, conv_s16_to_f32d_c); true, false, conv_s16_to_f32d_c);
@ -196,8 +196,8 @@ static void test_s16_f32(void)
static void test_f32_s32(void) static void test_f32_s32(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 };
const int32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100, static const int32_t out[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100,
0x7fffff00, 0x80000100 }; 0x7fffff00, 0x80000100 };
run_test("test_f32_s32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), 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) static void test_s32_f32(void)
{ {
const int32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 }; static const int32_t in[] = { 0, 0x7fffff00, 0x80000100, 0x3fffff00, 0xc0000100 };
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_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), run_test("test_s32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, false, conv_s32_to_f32d_c); true, false, conv_s32_to_f32d_c);
@ -239,12 +239,12 @@ static void test_s32_f32(void)
static void test_f32_s24(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 #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 }; 0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x80 };
#else #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 }; 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x01 };
#endif #endif
@ -261,13 +261,13 @@ static void test_f32_s24(void)
static void test_s24_f32(void) static void test_s24_f32(void)
{ {
#if __BYTE_ORDER == __LITTLE_ENDIAN #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, }; 0xff, 0xff, 0x3f, 0x01, 0x00, 0xc0, };
#else #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, }; 0x3f, 0xff, 0xff, 0xc0, 0x00, 0x01, };
#endif #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), run_test("test_s24_f32d", in, 3, out, sizeof(out[0]), SPA_N_ELEMENTS(out),
true, false, conv_s24_to_f32d_c); true, false, conv_s24_to_f32d_c);
@ -299,8 +299,8 @@ static void test_s24_f32(void)
static void test_f32_s24_32(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 }; static 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 int32_t out[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001,
0x7fffff, 0xff800001 }; 0x7fffff, 0xff800001 };
run_test("test_f32_s24_32", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), 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) static void test_s24_32_f32(void)
{ {
const int32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 }; static const int32_t in[] = { 0, 0x7fffff, 0xff800001, 0x3fffff, 0xffc00001 };
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_32_f32d", in, sizeof(in[0]), out, sizeof(out[0]), SPA_N_ELEMENTS(out), 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); true, false, conv_s24_32_to_f32d_c);

View file

@ -61,7 +61,7 @@ struct impl {
static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags,
uint8_t caps[A2DP_MAX_CAPS_SIZE]) uint8_t caps[A2DP_MAX_CAPS_SIZE])
{ {
const a2dp_aac_t a2dp_aac = { static const a2dp_aac_t a2dp_aac = {
.object_type = .object_type =
/* NOTE: AAC Long Term Prediction and AAC Scalable are /* NOTE: AAC Long Term Prediction and AAC Scalable are
* not supported by the FDK-AAC library. */ * 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, .vbr = 1,
AAC_INIT_BITRATE(DEFAULT_AAC_BITRATE) AAC_INIT_BITRATE(DEFAULT_AAC_BITRATE)
}; };
memcpy(caps, &a2dp_aac, sizeof(a2dp_aac)); memcpy(caps, &a2dp_aac, sizeof(a2dp_aac));
return sizeof(a2dp_aac); return sizeof(a2dp_aac);
} }
static struct a2dp_codec_config static const struct a2dp_codec_config
aac_frequencies[] = { aac_frequencies[] = {
{ AAC_SAMPLING_FREQ_48000, 48000, 11 }, { AAC_SAMPLING_FREQ_48000, 48000, 11 },
{ AAC_SAMPLING_FREQ_44100, 44100, 10 }, { AAC_SAMPLING_FREQ_44100, 44100, 10 },
@ -106,7 +107,7 @@ aac_frequencies[] = {
{ AAC_SAMPLING_FREQ_8000, 8000, 0 }, { AAC_SAMPLING_FREQ_8000, 8000, 0 },
}; };
static struct a2dp_codec_config static const struct a2dp_codec_config
aac_channel_modes[] = { aac_channel_modes[] = {
{ AAC_CHANNELS_2, 2, 1 }, { AAC_CHANNELS_2, 2, 1 },
{ AAC_CHANNELS_1, 1, 0 }, { AAC_CHANNELS_1, 1, 0 },

View file

@ -76,7 +76,7 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags,
return actual_conf_size; return actual_conf_size;
} }
static struct a2dp_codec_config static const struct a2dp_codec_config
aptx_frequencies[] = { aptx_frequencies[] = {
{ APTX_SAMPLING_FREQ_48000, 48000, 3 }, { APTX_SAMPLING_FREQ_48000, 48000, 3 },
{ APTX_SAMPLING_FREQ_44100, 44100, 2 }, { APTX_SAMPLING_FREQ_44100, 44100, 2 },

View file

@ -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]) 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.vendor_id = LDAC_VENDOR_ID,
.info.codec_id = LDAC_CODEC_ID, .info.codec_id = LDAC_CODEC_ID,
.frequency = LDACBT_SAMPLING_FREQ_044100 | .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_DUAL_CHANNEL |
LDACBT_CHANNEL_MODE_STEREO, LDACBT_CHANNEL_MODE_STEREO,
}; };
memcpy(caps, &a2dp_ldac, sizeof(a2dp_ldac)); memcpy(caps, &a2dp_ldac, sizeof(a2dp_ldac));
return sizeof(a2dp_ldac); return sizeof(a2dp_ldac);
} }
static struct a2dp_codec_config static const struct a2dp_codec_config
ldac_frequencies[] = { ldac_frequencies[] = {
{ LDACBT_SAMPLING_FREQ_044100, 44100, 3 }, { LDACBT_SAMPLING_FREQ_044100, 44100, 3 },
{ LDACBT_SAMPLING_FREQ_048000, 48000, 2 }, { LDACBT_SAMPLING_FREQ_048000, 48000, 2 },
@ -104,7 +105,7 @@ ldac_frequencies[] = {
{ LDACBT_SAMPLING_FREQ_096000, 96000, 0 }, { LDACBT_SAMPLING_FREQ_096000, 96000, 0 },
}; };
static struct a2dp_codec_config static const struct a2dp_codec_config
ldac_channel_modes[] = { ldac_channel_modes[] = {
{ LDACBT_CHANNEL_MODE_STEREO, 2, 2 }, { LDACBT_CHANNEL_MODE_STEREO, 2, 2 },
{ LDACBT_CHANNEL_MODE_DUAL_CHANNEL, 2, 1 }, { LDACBT_CHANNEL_MODE_DUAL_CHANNEL, 2, 1 },

View file

@ -55,7 +55,7 @@ struct impl {
static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags, static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags,
uint8_t caps[A2DP_MAX_CAPS_SIZE]) uint8_t caps[A2DP_MAX_CAPS_SIZE])
{ {
const a2dp_sbc_t a2dp_sbc = { static const a2dp_sbc_t a2dp_sbc = {
.frequency = .frequency =
SBC_SAMPLING_FREQ_16000 | SBC_SAMPLING_FREQ_16000 |
SBC_SAMPLING_FREQ_32000 | 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, .min_bitpool = SBC_MIN_BITPOOL,
.max_bitpool = SBC_MAX_BITPOOL, .max_bitpool = SBC_MAX_BITPOOL,
}; };
memcpy(caps, &a2dp_sbc, sizeof(a2dp_sbc)); memcpy(caps, &a2dp_sbc, sizeof(a2dp_sbc));
return 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_frequencies[] = {
{ SBC_SAMPLING_FREQ_48000, 48000, 3 }, { SBC_SAMPLING_FREQ_48000, 48000, 3 },
{ SBC_SAMPLING_FREQ_44100, 44100, 2 }, { SBC_SAMPLING_FREQ_44100, 44100, 2 },
@ -129,13 +130,13 @@ sbc_frequencies[] = {
{ SBC_SAMPLING_FREQ_16000, 16000, 0 }, { SBC_SAMPLING_FREQ_16000, 16000, 0 },
}; };
static struct a2dp_codec_config static const struct a2dp_codec_config
sbc_xq_frequencies[] = { sbc_xq_frequencies[] = {
{ SBC_SAMPLING_FREQ_44100, 44100, 1 }, { SBC_SAMPLING_FREQ_44100, 44100, 1 },
{ SBC_SAMPLING_FREQ_48000, 48000, 0 }, { SBC_SAMPLING_FREQ_48000, 48000, 0 },
}; };
static struct a2dp_codec_config static const struct a2dp_codec_config
sbc_channel_modes[] = { sbc_channel_modes[] = {
{ SBC_CHANNEL_MODE_JOINT_STEREO, 2, 3 }, { SBC_CHANNEL_MODE_JOINT_STEREO, 2, 3 },
{ SBC_CHANNEL_MODE_STEREO, 2, 2 }, { SBC_CHANNEL_MODE_STEREO, 2, 2 },
@ -143,7 +144,7 @@ sbc_channel_modes[] = {
{ SBC_CHANNEL_MODE_MONO, 1, 0 }, { SBC_CHANNEL_MODE_MONO, 1, 0 },
}; };
static struct a2dp_codec_config static const struct a2dp_codec_config
sbc_xq_channel_modes[] = { sbc_xq_channel_modes[] = {
{ SBC_CHANNEL_MODE_DUAL_CHANNEL, 2, 2 }, { SBC_CHANNEL_MODE_DUAL_CHANNEL, 2, 2 },
{ SBC_CHANNEL_MODE_JOINT_STEREO, 2, 1 }, { 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; a2dp_sbc_t conf;
int bitpool, i; int bitpool, i;
size_t n; size_t n;
struct a2dp_codec_config * configs; const struct a2dp_codec_config *configs;
bool xq = false; bool xq = false;

View file

@ -134,7 +134,7 @@ extern struct a2dp_codec a2dp_codec_aptx;
extern struct a2dp_codec a2dp_codec_aptx_hd; extern struct a2dp_codec a2dp_codec_aptx_hd;
#endif #endif
const struct a2dp_codec *a2dp_codec_list[] = { static const struct a2dp_codec * const a2dp_codec_list[] = {
#if ENABLE_LDAC #if ENABLE_LDAC
&a2dp_codec_ldac, &a2dp_codec_ldac,
#endif #endif
@ -150,6 +150,7 @@ const struct a2dp_codec *a2dp_codec_list[] = {
#endif #endif
&a2dp_codec_sbc_xq, &a2dp_codec_sbc_xq,
&a2dp_codec_sbc, &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;

View file

@ -371,7 +371,7 @@ struct a2dp_codec {
int (*increase_bitpool) (void *data); 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 { struct a2dp_codec_config {
uint32_t config; uint32_t config;

View file

@ -698,9 +698,11 @@ static bool rfcomm_hfp_ag(struct spa_source *source, char* buf)
/* retrieve supported codecs */ /* retrieve supported codecs */
/* response has the form AT+BAC=<codecID1>,<codecID2>,<codecIDx> /* response has the form AT+BAC=<codecID1>,<codecID2>,<codecIDx>
strategy: split the string into tokens */ strategy: split the string into tokens */
static const char separators[] = "=,";
char* token; char* token;
char separators[] = "=,";
int cntr = 0; int cntr = 0;
token = strtok (buf, separators); token = strtok (buf, separators);
while (token != NULL) 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 bool rfcomm_hfp_hf(struct spa_source *source, char* buf)
{ {
static const char separators[] = "\r\n:";
struct rfcomm *rfcomm = source->data; struct rfcomm *rfcomm = source->data;
struct impl *backend = rfcomm->backend; struct impl *backend = rfcomm->backend;
unsigned int features; unsigned int features;
unsigned int gain; unsigned int gain;
unsigned int selected_codec; unsigned int selected_codec;
char* token; char* token;
char separators[] = "\r\n:";
token = strtok(buf, separators); token = strtok(buf, separators);
while (token != NULL) while (token != NULL)

View file

@ -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 */ /* 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_a2dp_codec_switch *sw;
struct spa_bt_remote_endpoint *ep; struct spa_bt_remote_endpoint *ep;

View file

@ -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) 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) for (c = a2dp_codecs; *c; ++c)
if ((*c)->id == id) 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)) { if (profile == DEVICE_PROFILE_A2DP && !(this->bt_dev->connected_profiles & SPA_BT_PROFILE_A2DP_SOURCE)) {
int ret; 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); a2dp_codec = get_a2dp_codec(codec);
if (a2dp_codec == NULL) { if (a2dp_codec == NULL) {

View file

@ -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_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_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_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); 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); 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); int spa_bt_device_ensure_hfp_codec(struct spa_bt_device *device, unsigned int codec);

View file

@ -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) static void emit_node_info(struct impl *this, bool full)
{ {
bool is_ag = (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); static const struct spa_dict_item hu_node_info_items[] = {
struct spa_dict_item ag_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_DEVICE_API, "bluez5" },
{ SPA_KEY_MEDIA_CLASS, "Stream/Input/Audio" }, { SPA_KEY_MEDIA_CLASS, "Stream/Input/Audio" },
{ "media.name", ((this->transport && this->transport->device->name) ? { "media.name", ((this->transport && this->transport->device->name) ?
this->transport->device->name : "HSP/HFP") }, this->transport->device->name : "HSP/HFP") },
}; };
struct spa_dict_item hu_node_info_items[] = { bool is_ag = (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY);
{ SPA_KEY_DEVICE_API, "bluez5" },
{ SPA_KEY_MEDIA_CLASS, "Audio/Sink" },
{ SPA_KEY_NODE_DRIVER, "true" },
};
uint64_t old = full ? this->info.change_mask : 0; uint64_t old = full ? this->info.change_mask : 0;
if (full) 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); 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_VERSION_HANDLE_FACTORY,
SPA_NAME_API_BLUEZ5_SCO_SINK, SPA_NAME_API_BLUEZ5_SCO_SINK,
&info, &info,

View file

@ -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) static void emit_node_info(struct impl *this, bool full)
{ {
bool is_ag = this->transport && (this->transport->profile & SPA_BT_PROFILE_HEADSET_AUDIO_GATEWAY); static const struct spa_dict_item hu_node_info_items[] = {
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[] = {
{ SPA_KEY_DEVICE_API, "bluez5" }, { SPA_KEY_DEVICE_API, "bluez5" },
{ SPA_KEY_MEDIA_CLASS, "Audio/Source" }, { SPA_KEY_MEDIA_CLASS, "Audio/Source" },
{ SPA_KEY_NODE_DRIVER, "true" }, { 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; uint64_t old = full ? this->info.change_mask : 0;
if (full) 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); 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_VERSION_HANDLE_FACTORY,
SPA_NAME_API_BLUEZ5_SCO_SOURCE, SPA_NAME_API_BLUEZ5_SCO_SOURCE,
&info, &info,

View file

@ -75,7 +75,7 @@ using namespace controls;
extern "C" { extern "C" {
static struct { static const struct {
spa_video_format video_format; spa_video_format video_format;
unsigned int drm_fourcc; unsigned int drm_fourcc;
} format_map[] = { } format_map[] = {

View file

@ -112,7 +112,7 @@ static uint32_t get_count(struct impl *this)
#else #else
static uint32_t get_count(struct impl *this) static uint32_t get_count(struct impl *this)
{ {
int mib[] = {CTL_HW, HW_NCPU}; static const int mib[] = {CTL_HW, HW_NCPU};
int r; int r;
size_t rSize = sizeof(r); size_t rSize = sizeof(r);
if(-1 == sysctl(mib, 2, &r, &rSize, 0, 0)) if(-1 == sysctl(mib, 2, &r, &rSize, 0, 0))

View file

@ -81,7 +81,7 @@ impl_log_logv(void *object,
char timestamp[15] = {0}; char timestamp[15] = {0};
char filename[64] = {0}; char filename[64] = {0};
char location[1000 + RESERVED_LENGTH], *p, *s; 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 = ""; const char *prefix = "", *suffix = "";
int size, len; int size, len;
bool do_trace; bool do_trace;

View file

@ -658,9 +658,11 @@ spa_v4l2_enum_format(struct impl *this, int seq,
goto exit; goto exit;
} }
if (filter) { if (filter) {
static const struct spa_rectangle step = {1, 1};
const struct spa_rectangle *values;
const struct spa_pod_prop *p; const struct spa_pod_prop *p;
struct spa_pod *val; struct spa_pod *val;
const struct spa_rectangle step = { 1, 1 }, *values;
uint32_t choice, i, n_values; uint32_t choice, i, n_values;
/* check if we have a fixed frame size */ /* check if we have a fixed frame size */
@ -749,10 +751,12 @@ spa_v4l2_enum_format(struct impl *this, int seq,
goto exit; goto exit;
} }
if (filter) { if (filter) {
static const struct spa_fraction step = {1, 1};
const struct spa_fraction *values;
const struct spa_pod_prop *p; const struct spa_pod_prop *p;
struct spa_pod *val; struct spa_pod *val;
uint32_t i, n_values, choice; 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))) if (!(p = spa_pod_find_prop(filter, NULL, SPA_FORMAT_VIDEO_framerate)))
goto have_framerate; goto have_framerate;

View file

@ -100,7 +100,7 @@ static int vkresult_to_errno(VkResult result)
static int createInstance(struct vulkan_state *s) static int createInstance(struct vulkan_state *s)
{ {
const VkApplicationInfo applicationInfo = { static const VkApplicationInfo applicationInfo = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pApplicationName = "PipeWire", .pApplicationName = "PipeWire",
.applicationVersion = 0, .applicationVersion = 0,
@ -108,10 +108,11 @@ static int createInstance(struct vulkan_state *s)
.engineVersion = 0, .engineVersion = 0,
.apiVersion = VK_API_VERSION_1_1 .apiVersion = VK_API_VERSION_1_1
}; };
const char *extensions[] = { static const char * const extensions[] = {
VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME
}; };
VkInstanceCreateInfo createInfo = {
const VkInstanceCreateInfo createInfo = {
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
.pApplicationInfo = &applicationInfo, .pApplicationInfo = &applicationInfo,
.enabledExtensionCount = 1, .enabledExtensionCount = 1,
@ -166,17 +167,18 @@ static int findPhysicalDevice(struct vulkan_state *s)
static int createDevice(struct vulkan_state *s) static int createDevice(struct vulkan_state *s)
{ {
VkDeviceQueueCreateInfo queueCreateInfo = {
const VkDeviceQueueCreateInfo queueCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
.queueFamilyIndex = s->queueFamilyIndex, .queueFamilyIndex = s->queueFamilyIndex,
.queueCount = 1, .queueCount = 1,
.pQueuePriorities = (const float[]) { 1.0f } .pQueuePriorities = (const float[]) { 1.0f }
}; };
const char *extensions[] = { static const char * const extensions[] = {
VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME
}; };
VkDeviceCreateInfo deviceCreateInfo = { const VkDeviceCreateInfo deviceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.queueCreateInfoCount = 1, .queueCreateInfoCount = 1,
.pQueueCreateInfos = &queueCreateInfo, .pQueueCreateInfos = &queueCreateInfo,
@ -188,7 +190,7 @@ static int createDevice(struct vulkan_state *s)
vkGetDeviceQueue(s->device, s->queueFamilyIndex, 0, &s->queue); vkGetDeviceQueue(s->device, s->queueFamilyIndex, 0, &s->queue);
VkFenceCreateInfo fenceCreateInfo = { static const VkFenceCreateInfo fenceCreateInfo = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
.flags = 0, .flags = 0,
}; };
@ -215,11 +217,11 @@ static uint32_t findMemoryType(struct vulkan_state *s,
static int createDescriptors(struct vulkan_state *s) static int createDescriptors(struct vulkan_state *s)
{ {
VkDescriptorPoolSize descriptorPoolSize = { static const VkDescriptorPoolSize descriptorPoolSize = {
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.descriptorCount = 1 .descriptorCount = 1
}; };
VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = { static const VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
.maxSets = 1, .maxSets = 1,
.poolSizeCount = 1, .poolSizeCount = 1,
@ -230,13 +232,13 @@ static int createDescriptors(struct vulkan_state *s)
&descriptorPoolCreateInfo, NULL, &descriptorPoolCreateInfo, NULL,
&s->descriptorPool)); &s->descriptorPool));
VkDescriptorSetLayoutBinding descriptorSetLayoutBinding = { static const VkDescriptorSetLayoutBinding descriptorSetLayoutBinding = {
.binding = 0, .binding = 0,
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
.descriptorCount = 1, .descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT
}; };
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = { static const VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
.bindingCount = 1, .bindingCount = 1,
.pBindings = &descriptorSetLayoutBinding .pBindings = &descriptorSetLayoutBinding
@ -245,7 +247,7 @@ static int createDescriptors(struct vulkan_state *s)
&descriptorSetLayoutCreateInfo, NULL, &descriptorSetLayoutCreateInfo, NULL,
&s->descriptorSetLayout)); &s->descriptorSetLayout));
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = { const VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
.descriptorPool = s->descriptorPool, .descriptorPool = s->descriptorPool,
.descriptorSetCount = 1, .descriptorSetCount = 1,
@ -260,7 +262,7 @@ static int createDescriptors(struct vulkan_state *s)
static int createBuffer(struct vulkan_state *s, uint32_t id) static int createBuffer(struct vulkan_state *s, uint32_t id)
{ {
VkBufferCreateInfo bufferCreateInfo = { const VkBufferCreateInfo bufferCreateInfo = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.size = s->bufferSize, .size = s->bufferSize,
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, .usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
@ -274,14 +276,14 @@ static int createBuffer(struct vulkan_state *s, uint32_t id)
vkGetBufferMemoryRequirements(s->device, vkGetBufferMemoryRequirements(s->device,
s->buffers[id].buffer, &memoryRequirements); s->buffers[id].buffer, &memoryRequirements);
VkMemoryAllocateInfo allocateInfo = { const VkMemoryAllocateInfo allocateInfo = {
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .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, VK_CHECK_RESULT(vkAllocateMemory(s->device,
&allocateInfo, NULL, &s->buffers[id].memory)); &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) if (s->current_buffer_id == buffer_id)
return 0; return 0;
VkDescriptorBufferInfo descriptorBufferInfo = { const VkDescriptorBufferInfo descriptorBufferInfo = {
.buffer = s->buffers[buffer_id].buffer, .buffer = s->buffers[buffer_id].buffer,
.offset = 0, .offset = 0,
.range = s->bufferSize, .range = s->bufferSize,
}; };
VkWriteDescriptorSet writeDescriptorSet = { const VkWriteDescriptorSet writeDescriptorSet = {
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.dstSet = s->descriptorSet, .dstSet = s->descriptorSet,
.dstBinding = 0, .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); 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, .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
.codeSize = stat.st_size, .codeSize = stat.st_size,
.pCode = data, .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) 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, .stageFlags = VK_PIPELINE_STAGE_VERTEX_SHADER_BIT,
.offset = 0, .offset = 0,
.size = sizeof(struct push_constants) .size = sizeof(struct push_constants)
}; };
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = { const VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 1, .setLayoutCount = 1,
.pSetLayouts = &s->descriptorSetLayout, .pSetLayouts = &s->descriptorSetLayout,
@ -376,13 +378,13 @@ static int createComputePipeline(struct vulkan_state *s, const char *shader_file
if (s->computeShaderModule == VK_NULL_HANDLE) if (s->computeShaderModule == VK_NULL_HANDLE)
return -ENOENT; return -ENOENT;
VkPipelineShaderStageCreateInfo shaderStageCreateInfo = { const VkPipelineShaderStageCreateInfo shaderStageCreateInfo = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_COMPUTE_BIT, .stage = VK_SHADER_STAGE_COMPUTE_BIT,
.module = s->computeShaderModule, .module = s->computeShaderModule,
.pName = "main", .pName = "main",
}; };
VkComputePipelineCreateInfo pipelineCreateInfo = { const VkComputePipelineCreateInfo pipelineCreateInfo = {
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
.stage = shaderStageCreateInfo, .stage = shaderStageCreateInfo,
.layout = s->pipelineLayout, .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) static int createCommandBuffer(struct vulkan_state *s)
{ {
VkCommandPoolCreateInfo commandPoolCreateInfo = { const VkCommandPoolCreateInfo commandPoolCreateInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, .flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
.queueFamilyIndex = s->queueFamilyIndex, .queueFamilyIndex = s->queueFamilyIndex,
@ -404,7 +406,7 @@ static int createCommandBuffer(struct vulkan_state *s)
&commandPoolCreateInfo, NULL, &commandPoolCreateInfo, NULL,
&s->commandPool)); &s->commandPool));
VkCommandBufferAllocateInfo commandBufferAllocateInfo = { const VkCommandBufferAllocateInfo commandBufferAllocateInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.commandPool = s->commandPool, .commandPool = s->commandPool,
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
@ -419,7 +421,7 @@ static int createCommandBuffer(struct vulkan_state *s)
static int runCommandBuffer(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, .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, .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)); VK_CHECK_RESULT(vkResetFences(s->device, 1, &s->fence));
VkSubmitInfo submitInfo = { const VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.commandBufferCount = 1, .commandBufferCount = 1,
.pCommandBuffers = &s->commandBuffer, .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++) { for (i = 0; i < n_buffers; i++) {
createBuffer(s, i); createBuffer(s, i);
VkMemoryGetFdInfoKHR getFdInfo = { const VkMemoryGetFdInfoKHR getFdInfo = {
.sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR, .sType = VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR,
.memory = s->buffers[i].memory, .memory = s->buffers[i].memory,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT

View file

@ -408,12 +408,7 @@ static int save_stream(struct stream *str)
static void update_stream(struct stream *str) static void update_stream(struct stream *str)
{ {
struct impl *impl = str->impl; static const char * const keys[] = {
uint32_t i;
const char *p;
char *key;
struct sm_object *obj = &str->obj->obj;
const char *keys[] = {
PW_KEY_MEDIA_ROLE, PW_KEY_MEDIA_ROLE,
PW_KEY_APP_ID, PW_KEY_APP_ID,
PW_KEY_APP_NAME, PW_KEY_APP_NAME,
@ -421,6 +416,12 @@ static void update_stream(struct stream *str)
PW_KEY_NODE_NAME, 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; key = NULL;
for (i = 0; i < SPA_N_ELEMENTS(keys); i++) { for (i = 0; i < SPA_N_ELEMENTS(keys); i++) {
if ((p = pw_properties_get(obj->props, 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; 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, PW_VERSION_CLIENT_NODE_METHODS,
.get_node = client_node_get_node, .get_node = client_node_get_node,
.update = client_node_update, .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, PW_VERSION_CLIENT_NODE0_METHODS,
.done = client_node0_done, .done = client_node0_done,
.update = client_node0_update, .update = client_node0_update,
@ -1303,12 +1303,13 @@ static const struct pw_resource_events resource_events = {
static void convert_properties(struct pw_properties *properties) static void convert_properties(struct pw_properties *properties)
{ {
struct { static const struct {
const char *from, *to; const char *from, *to;
} props[] = { } props[] = {
{ "pipewire.autoconnect", PW_KEY_NODE_AUTOCONNECT, }, { "pipewire.autoconnect", PW_KEY_NODE_AUTOCONNECT, },
{ "pipewire.target.node", PW_KEY_NODE_TARGET, } { "pipewire.target.node", PW_KEY_NODE_TARGET, }
}; };
uint32_t i; uint32_t i;
const char *str; 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, } [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_TYPE_INTERFACE_Registry,
PW_VERSION_REGISTRY, PW_VERSION_REGISTRY,
0, 0,
@ -2050,7 +2050,7 @@ pw_protocol_native_module_method_demarshal[PW_MODULE_METHOD_NUM] =
[PW_MODULE_METHOD_ADD_LISTENER] = { NULL, 0, }, [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_TYPE_INTERFACE_Module,
PW_VERSION_MODULE, PW_VERSION_MODULE,
0, 0,
@ -2084,7 +2084,7 @@ pw_protocol_native_factory_method_demarshal[PW_FACTORY_METHOD_NUM] =
[PW_FACTORY_METHOD_ADD_LISTENER] = { NULL, 0, }, [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_TYPE_INTERFACE_Factory,
PW_VERSION_FACTORY, PW_VERSION_FACTORY,
0, 0,

View file

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

View file

@ -220,7 +220,7 @@ enum {
SOURCE_FLAT_VOLUME = 0x0080U, SOURCE_FLAT_VOLUME = 0x0080U,
}; };
static const char *port_types[] = { static const char * const port_types[] = {
"unknown", "unknown",
"aux", "aux",
"speaker", "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_ANY] = "ANY",
[ENCODING_PCM] = "PCM", [ENCODING_PCM] = "PCM",
[ENCODING_AC3_IEC61937] = "AC3-IEC61937", [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) static void publish_service(struct service *s)
{ {
AvahiStringList *txt = NULL; static const char * const subtype_text[] = {
const char *t;
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
const char * const subtype_text[] = {
[SUBTYPE_HARDWARE] = "hardware", [SUBTYPE_HARDWARE] = "hardware",
[SUBTYPE_VIRTUAL] = "virtual", [SUBTYPE_VIRTUAL] = "virtual",
[SUBTYPE_MONITOR] = "monitor" [SUBTYPE_MONITOR] = "monitor"
}; };
AvahiStringList *txt = NULL;
const char *t;
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
spa_assert(s); spa_assert(s);
if (!s->userdata->client || avahi_client_get_state(s->userdata->client) != AVAHI_CLIENT_S_RUNNING) 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); client_cleanup(client);
} }
static struct pw_proxy_events core_proxy_events = { static const struct pw_proxy_events core_proxy_events = {
PW_VERSION_CORE_EVENTS, PW_VERSION_CORE_EVENTS,
.destroy = on_core_proxy_destroy, .destroy = on_core_proxy_destroy,
}; };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -650,9 +650,7 @@ SPA_EXPORT
int pw_impl_node_register(struct pw_impl_node *this, int pw_impl_node_register(struct pw_impl_node *this,
struct pw_properties *properties) struct pw_properties *properties)
{ {
struct pw_context *context = this->context; static const char * const keys[] = {
struct pw_impl_port *port;
const char *keys[] = {
PW_KEY_OBJECT_PATH, PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID, PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID, PW_KEY_FACTORY_ID,
@ -672,6 +670,9 @@ int pw_impl_node_register(struct pw_impl_node *this,
NULL NULL
}; };
struct pw_context *context = this->context;
struct pw_impl_port *port;
pw_log_debug(NAME" %p: register", this); pw_log_debug(NAME" %p: register", this);
if (this->registered) 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) static int update_properties(struct pw_impl_node *node, const struct spa_dict *dict, bool filter)
{ {
int changed; static const char * const ignored[] = {
const char *ignored[] = {
PW_KEY_OBJECT_ID, PW_KEY_OBJECT_ID,
PW_KEY_MODULE_ID, PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID, PW_KEY_FACTORY_ID,
@ -1283,6 +1283,8 @@ static int update_properties(struct pw_impl_node *node, const struct spa_dict *d
NULL NULL
}; };
int changed;
changed = pw_properties_update_ignore(node->properties, dict, filter ? ignored : NULL); changed = pw_properties_update_ignore(node->properties, dict, filter ? ignored : NULL);
node->info.props = &node->properties->dict; 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) static int update_properties(struct pw_impl_port *port, const struct spa_dict *dict, bool filter)
{ {
int changed; static const char * const ignored[] = {
const char *ignored[] = {
PW_KEY_OBJECT_ID, PW_KEY_OBJECT_ID,
PW_KEY_PORT_DIRECTION, PW_KEY_PORT_DIRECTION,
PW_KEY_PORT_CONTROL, PW_KEY_PORT_CONTROL,
@ -280,6 +279,8 @@ static int update_properties(struct pw_impl_port *port, const struct spa_dict *d
NULL NULL
}; };
int changed;
changed = pw_properties_update_ignore(port->properties, dict, filter ? ignored : NULL); changed = pw_properties_update_ignore(port->properties, dict, filter ? ignored : NULL);
port->info.props = &port->properties->dict; 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, int pw_impl_port_register(struct pw_impl_port *port,
struct pw_properties *properties) struct pw_properties *properties)
{ {
struct pw_impl_node *node = port->node; static const char * const keys[] = {
const char *keys[] = {
PW_KEY_OBJECT_PATH, PW_KEY_OBJECT_PATH,
PW_KEY_FORMAT_DSP, PW_KEY_FORMAT_DSP,
PW_KEY_NODE_ID, PW_KEY_NODE_ID,
@ -894,6 +894,8 @@ int pw_impl_port_register(struct pw_impl_port *port,
NULL NULL
}; };
struct pw_impl_node *node = port->node;
if (node == NULL || node->global == NULL) if (node == NULL || node->global == NULL)
return -EIO; return -EIO;

View file

@ -395,11 +395,12 @@ static void init_i18n(struct support *support)
static void *add_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, SPA_VERSION_I18N_METHODS,
.text = i18n_text, .text = i18n_text,
.ntext = i18n_ntext, .ntext = i18n_ntext,
}; };
support->i18n_iface = SPA_INTERFACE_INIT( support->i18n_iface = SPA_INTERFACE_INIT(
SPA_TYPE_INTERFACE_I18N, SPA_TYPE_INTERFACE_I18N,
SPA_VERSION_I18N, SPA_VERSION_I18N,

View file

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

View file

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

View file

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

View file

@ -36,13 +36,12 @@ do { \
static void test_abi(void) static void test_abi(void)
{ {
struct pw_stream_events ev; static const struct {
struct {
uint32_t version; uint32_t version;
void (*destroy) (void *data); void (*destroy) (void *data);
void (*state_changed) (void *data, enum pw_stream_state old, void (*state_changed) (void *data, enum pw_stream_state old,
enum pw_stream_state state, const char *error); 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 (*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 (*param_changed) (void *data, uint32_t id, const struct spa_pod *param);
void (*add_buffer) (void *data, struct pw_buffer *buffer); void (*add_buffer) (void *data, struct pw_buffer *buffer);
@ -51,6 +50,8 @@ static void test_abi(void)
void (*drained) (void *data); void (*drained) (void *data);
} test = { PW_VERSION_STREAM_EVENTS, NULL }; } test = { PW_VERSION_STREAM_EVENTS, NULL };
struct pw_stream_events ev;
TEST_FUNC(ev, test, destroy); TEST_FUNC(ev, test, destroy);
TEST_FUNC(ev, test, state_changed); TEST_FUNC(ev, test, state_changed);
TEST_FUNC(ev, test, control_info); 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; return 0;
} }
static const char *event_names[] = { static const char * const event_names[] = {
"Text", "Copyright", "Sequence/Track Name", "Text", "Copyright", "Sequence/Track Name",
"Instrument", "Lyric", "Marker", "Cue Point", "Instrument", "Lyric", "Marker", "Cue Point",
"Program Name", "Device (Port) Name" "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" "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)", [0] = "Bank Select (coarse)",
[1] = "Modulation Wheel (coarse)", [1] = "Modulation Wheel (coarse)",
[2] = "Breath controller (coarse)", [2] = "Breath controller (coarse)",
@ -541,7 +541,7 @@ static const char *controller_names[128] = {
[127] = "Poly Operation", [127] = "Poly Operation",
}; };
static const char *program_names[] = { static const char * const program_names[] = {
"Acoustic Grand", "Bright Acoustic", "Electric Grand", "Honky-Tonk", "Acoustic Grand", "Bright Acoustic", "Electric Grand", "Honky-Tonk",
"Electric Piano 1", "Electric Piano 2", "Harpsichord", "Clavinet", "Electric Piano 1", "Electric Piano 2", "Harpsichord", "Clavinet",
"Celesta", "Glockenspiel", "Music Box", "Vibraphone", "Marimba", "Celesta", "Glockenspiel", "Music Box", "Vibraphone", "Marimba",
@ -572,19 +572,19 @@ static const char *program_names[] = {
"Applause", "Gunshot" "Applause", "Gunshot"
}; };
static const char *smpte_rates[] = { static const char * const smpte_rates[] = {
"24 fps", "24 fps",
"25 fps", "25 fps",
"30 fps (drop frame)", "30 fps (drop frame)",
"30 fps (non 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", "Unknown major", "Fb", "Cb", "Gb", "Db", "Ab", "Eb", "Bb", "F",
"C", "G", "D", "A", "E", "B", "F#", "C#", "G#", "Unknown major" "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", "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" "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 int fill_properties(struct data *data)
{ {
static const char* table[] = { static const char * const table[] = {
[SF_STR_TITLE] = PW_KEY_MEDIA_TITLE, [SF_STR_TITLE] = PW_KEY_MEDIA_TITLE,
[SF_STR_COPYRIGHT] = PW_KEY_MEDIA_COPYRIGHT, [SF_STR_COPYRIGHT] = PW_KEY_MEDIA_COPYRIGHT,
[SF_STR_SOFTWARE] = PW_KEY_MEDIA_SOFTWARE, [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_COMMENT] = PW_KEY_MEDIA_COMMENT,
[SF_STR_DATE] = PW_KEY_MEDIA_DATE [SF_STR_DATE] = PW_KEY_MEDIA_DATE
}; };
SF_INFO sfi; SF_INFO sfi;
SF_FORMAT_INFO fi; SF_FORMAT_INFO fi;
int res; 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" #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 }, { "help", "h", "Show this help", do_help },
{ "load-module", "lm", "Load a module. <module-name> [<module-arguments>]", do_load_module }, { "load-module", "lm", "Load a module. <module-name> [<module-arguments>]", do_load_module },
{ "unload-module", "um", "Unload a module. <module-var>", do_not_implemented }, { "unload-module", "um", "Unload a module. <module-var>", do_not_implemented },
@ -2002,7 +2002,7 @@ enum dump_flags {
is_notype = BIT(3) is_notype = BIT(3)
}; };
static const char *dump_types[] = { static const char * const dump_types[] = {
PW_TYPE_INTERFACE_Core, PW_TYPE_INTERFACE_Core,
PW_TYPE_INTERFACE_Module, PW_TYPE_INTERFACE_Module,
PW_TYPE_INTERFACE_Device, 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), SPA_POD_CONTENTS(struct spa_pod, &b->child),
b->child.size); b->child.size);
} else { } else {
void *p; static const char * const range_labels[] = { "default", "min", "max", NULL };
static const char *range_labels[] = { "default", "min", "max", NULL }; static const char * const step_labels[] = { "default", "min", "max", "step", NULL };
static const char *step_labels[] = { "default", "min", "max", "step", NULL }; static const char * const enum_labels[] = { "default", "alt%u" };
static const char *enum_labels[] = { "default", "alt%u" }; static const char * const flags_labels[] = { "default", "flag%u" };
static const char *flags_labels[] = { "default", "flag%u" };
const char **labels, *label; const char * const *labels;
const char *label;
char buffer[64]; char buffer[64];
int max_labels, flags = 0; int max_labels, flags = 0;
void *p;
switch (b->type) { switch (b->type) {
case SPA_CHOICE_Range: case SPA_CHOICE_Range:
@ -512,7 +514,7 @@ struct flags_info {
}; };
static void put_flags(struct data *d, const char *key, 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; uint32_t i;
put_begin(d, key, "[", STATE_SIMPLE); put_begin(d, key, "[", STATE_SIMPLE);
@ -526,12 +528,14 @@ static void put_flags(struct data *d, const char *key,
/* core */ /* core */
static void core_dump(struct object *o) static void core_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_core_info *i = d->info;
struct flags_info fl[] = {
{ "props", PW_CORE_CHANGE_MASK_PROPS }, { "props", PW_CORE_CHANGE_MASK_PROPS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_core_info *i = d->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_int(d, "cookie", i->cookie); put_int(d, "cookie", i->cookie);
put_value(d, "user-name", i->user_name); put_value(d, "user-name", i->user_name);
@ -552,12 +556,14 @@ static const struct class core_class = {
/* client */ /* client */
static void client_dump(struct object *o) static void client_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_client_info *i = o->info;
struct flags_info fl[] = {
{ "props", PW_CLIENT_CHANGE_MASK_PROPS }, { "props", PW_CLIENT_CHANGE_MASK_PROPS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_client_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_flags(d, "change-mask", i->change_mask, fl); put_flags(d, "change-mask", i->change_mask, fl);
put_dict(d, "props", i->props); put_dict(d, "props", i->props);
@ -606,12 +612,14 @@ static const struct class client_class = {
/* module */ /* module */
static void module_dump(struct object *o) static void module_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_module_info *i = o->info;
struct flags_info fl[] = {
{ "props", PW_MODULE_CHANGE_MASK_PROPS }, { "props", PW_MODULE_CHANGE_MASK_PROPS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_module_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_value(d, "name", i->name); put_value(d, "name", i->name);
put_value(d, "filename", i->filename); put_value(d, "filename", i->filename);
@ -663,12 +671,14 @@ static const struct class module_class = {
/* factory */ /* factory */
static void factory_dump(struct object *o) static void factory_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_factory_info *i = o->info;
struct flags_info fl[] = {
{ "props", PW_FACTORY_CHANGE_MASK_PROPS }, { "props", PW_FACTORY_CHANGE_MASK_PROPS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_factory_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_value(d, "name", i->name); put_value(d, "name", i->name);
put_value(d, "type", i->type); put_value(d, "type", i->type);
@ -720,13 +730,15 @@ static const struct class factory_class = {
/* device */ /* device */
static void device_dump(struct object *o) static void device_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_device_info *i = o->info;
struct flags_info fl[] = {
{ "props", PW_DEVICE_CHANGE_MASK_PROPS }, { "props", PW_DEVICE_CHANGE_MASK_PROPS },
{ "params", PW_DEVICE_CHANGE_MASK_PARAMS }, { "params", PW_DEVICE_CHANGE_MASK_PARAMS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_device_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_flags(d, "change-mask", i->change_mask, fl); put_flags(d, "change-mask", i->change_mask, fl);
put_dict(d, "props", i->props); put_dict(d, "props", i->props);
@ -802,9 +814,7 @@ static const struct class device_class = {
/* node */ /* node */
static void node_dump(struct object *o) static void node_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_node_info *i = o->info;
struct flags_info fl[] = {
{ "input-ports", PW_NODE_CHANGE_MASK_INPUT_PORTS }, { "input-ports", PW_NODE_CHANGE_MASK_INPUT_PORTS },
{ "output-ports", PW_NODE_CHANGE_MASK_OUTPUT_PORTS }, { "output-ports", PW_NODE_CHANGE_MASK_OUTPUT_PORTS },
{ "state", PW_NODE_CHANGE_MASK_STATE }, { "state", PW_NODE_CHANGE_MASK_STATE },
@ -812,6 +822,10 @@ static void node_dump(struct object *o)
{ "params", PW_NODE_CHANGE_MASK_PARAMS }, { "params", PW_NODE_CHANGE_MASK_PARAMS },
{ NULL, 0 }, { NULL, 0 },
}; };
struct data *d = o->data;
struct pw_node_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_int(d, "max-input-ports", i->max_input_ports); put_int(d, "max-input-ports", i->max_input_ports);
put_int(d, "max-output-ports", i->max_output_ports); put_int(d, "max-output-ports", i->max_output_ports);
@ -896,13 +910,15 @@ static const struct class node_class = {
/* port */ /* port */
static void port_dump(struct object *o) static void port_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_port_info *i = o->info;
struct flags_info fl[] = {
{ "props", PW_PORT_CHANGE_MASK_PROPS }, { "props", PW_PORT_CHANGE_MASK_PROPS },
{ "params", PW_PORT_CHANGE_MASK_PARAMS }, { "params", PW_PORT_CHANGE_MASK_PARAMS },
{ NULL, }, { NULL, },
}; };
struct data *d = o->data;
struct pw_port_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_value(d, "direction", pw_direction_as_string(i->direction)); put_value(d, "direction", pw_direction_as_string(i->direction));
put_flags(d, "change-mask", i->change_mask, fl); put_flags(d, "change-mask", i->change_mask, fl);
@ -979,14 +995,16 @@ static const struct class port_class = {
/* link */ /* link */
static void link_dump(struct object *o) static void link_dump(struct object *o)
{ {
struct data *d = o->data; static const struct flags_info fl[] = {
struct pw_link_info *i = o->info;
struct flags_info fl[] = {
{ "state", PW_LINK_CHANGE_MASK_STATE }, { "state", PW_LINK_CHANGE_MASK_STATE },
{ "format", PW_LINK_CHANGE_MASK_FORMAT }, { "format", PW_LINK_CHANGE_MASK_FORMAT },
{ "props", PW_LINK_CHANGE_MASK_PROPS }, { "props", PW_LINK_CHANGE_MASK_PROPS },
{ NULL, }, { NULL, },
}; };
struct data *d = o->data;
struct pw_link_info *i = o->info;
put_begin(d, "info", "{", 0); put_begin(d, "info", "{", 0);
put_int(d, "output-node-id", i->output_node_id); put_int(d, "output-node-id", i->output_node_id);
put_int(d, "output-port-id", i->output_port_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) static void dump_objects(struct data *d)
{ {
struct object *o; static const struct flags_info fl[] = {
struct flags_info fl[] = {
{ "r", PW_PERM_R }, { "r", PW_PERM_R },
{ "w", PW_PERM_W }, { "w", PW_PERM_W },
{ "x", PW_PERM_X }, { "x", PW_PERM_X },
{ "m", PW_PERM_M }, { "m", PW_PERM_M },
{ NULL, }, { NULL, },
}; };
struct object *o;
d->state = STATE_FIRST; d->state = STATE_FIRST;
spa_list_for_each(o, &d->object_list, link) { spa_list_for_each(o, &d->object_list, link) {
if (d->id != SPA_ID_INVALID && d->id != o->id) if (d->id != SPA_ID_INVALID && d->id != o->id)

View file

@ -220,11 +220,7 @@ PWTEST(context_properties)
PWTEST(context_support) PWTEST(context_support)
{ {
struct pw_main_loop *loop; static const char * const types[] = {
struct pw_context *context;
const struct spa_support *support;
uint32_t n_support;
const char * types[] = {
SPA_TYPE_INTERFACE_DataSystem, SPA_TYPE_INTERFACE_DataSystem,
SPA_TYPE_INTERFACE_DataLoop, SPA_TYPE_INTERFACE_DataLoop,
SPA_TYPE_INTERFACE_System, SPA_TYPE_INTERFACE_System,
@ -234,6 +230,11 @@ PWTEST(context_support)
SPA_TYPE_INTERFACE_DBus, SPA_TYPE_INTERFACE_DBus,
SPA_TYPE_INTERFACE_CPU 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; size_t i;
pw_init(0, NULL); pw_init(0, NULL);

View file

@ -1570,12 +1570,7 @@ PWTEST(pod_static)
PWTEST(pod_overflow) PWTEST(pod_overflow)
{ {
uint8_t buffer[1024]; static const char * const labels[] = {
struct spa_pod_builder b = { 0 };
struct spa_pod_builder_state state;
struct spa_pod_frame f[2];
uint32_t idx;
const char *labels[] = {
"640x480p59", "720x480i29", "720x480p59", "720x576i25", "720x576p50", "640x480p59", "720x480i29", "720x480p59", "720x576i25", "720x576p50",
"1280x720p24", "1280x720p25", "1280x720p30", "1280x720p50", "1280x720p60", "1280x720p24", "1280x720p25", "1280x720p30", "1280x720p50", "1280x720p60",
"1920x1080p24", "1920x1080p25", "1920x1080p30", "1920x1080i25", "1920x1080p50", "1920x1080p24", "1920x1080p25", "1920x1080p30", "1920x1080i25", "1920x1080p50",
@ -1599,6 +1594,12 @@ PWTEST(pod_overflow)
"3840x2160p24", "3840x2160p25", "3840x2160p30", "3840x2160p50", "3840x2160p60", "3840x2160p24", "3840x2160p25", "3840x2160p30", "3840x2160p50", "3840x2160p60",
"4096x2160p24", "4096x2160p25", "4096x2160p30", "4096x2160p50", "4096x2160p59", "4096x2160p24", "4096x2160p25", "4096x2160p30", "4096x2160p50", "4096x2160p59",
"4096x2160p60", NULL }; "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; struct spa_pod *pod;
spa_pod_builder_init(&b, buffer, sizeof(buffer)); spa_pod_builder_init(&b, buffer, sizeof(buffer));