mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
treewide: mark things static and const
Mark some structures, arrays static/const at various places. In some cases this prevents unnecessary initialization when a function is entered. All in all, the text segments across all shared libraries are reduced by about 2 KiB. However, the total size increases by about 2 KiB as well.
This commit is contained in:
parent
48dbb4da3c
commit
f5d51162c4
54 changed files with 303 additions and 241 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -698,9 +698,11 @@ static bool rfcomm_hfp_ag(struct spa_source *source, char* buf)
|
|||
/* retrieve supported codecs */
|
||||
/* response has the form AT+BAC=<codecID1>,<codecID2>,<codecIDx>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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[] = {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue