mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	bluez5: replace codec->bap/asha flags with codec->kind enum
Indicate codec type with enum instead of bool flags. This is in preparation of moving also HFP to media codecs.
This commit is contained in:
		
							parent
							
								
									83c644fe09
								
							
						
					
					
						commit
						4e0d0c5f0b
					
				
					 17 changed files with 97 additions and 46 deletions
				
			
		| 
						 | 
					@ -683,6 +683,7 @@ static void codec_set_log(struct spa_log *global_log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_aac = {
 | 
					const struct media_codec a2dp_codec_aac = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_AAC,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_AAC,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_MPEG24,
 | 
						.codec_id = A2DP_CODEC_MPEG24,
 | 
				
			||||||
	.name = "aac",
 | 
						.name = "aac",
 | 
				
			||||||
	.description = "AAC",
 | 
						.description = "AAC",
 | 
				
			||||||
| 
						 | 
					@ -708,6 +709,7 @@ const struct media_codec a2dp_codec_aac = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_aac_eld = {
 | 
					const struct media_codec a2dp_codec_aac_eld = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_AAC_ELD,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_AAC_ELD,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_MPEG24,
 | 
						.codec_id = A2DP_CODEC_MPEG24,
 | 
				
			||||||
	.name = "aac_eld",
 | 
						.name = "aac_eld",
 | 
				
			||||||
	.description = "AAC-ELD",
 | 
						.description = "AAC-ELD",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -617,6 +617,7 @@ static int msbc_decode(void *data,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_aptx = {
 | 
					const struct media_codec a2dp_codec_aptx = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_APTX,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_APTX,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,
 | 
						.codec_id = A2DP_CODEC_VENDOR,
 | 
				
			||||||
	.vendor = { .vendor_id = APTX_VENDOR_ID,
 | 
						.vendor = { .vendor_id = APTX_VENDOR_ID,
 | 
				
			||||||
		.codec_id = APTX_CODEC_ID },
 | 
							.codec_id = APTX_CODEC_ID },
 | 
				
			||||||
| 
						 | 
					@ -641,6 +642,7 @@ const struct media_codec a2dp_codec_aptx = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_aptx_hd = {
 | 
					const struct media_codec a2dp_codec_aptx_hd = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_HD,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_APTX_HD,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,
 | 
						.codec_id = A2DP_CODEC_VENDOR,
 | 
				
			||||||
	.vendor = { .vendor_id = APTX_HD_VENDOR_ID,
 | 
						.vendor = { .vendor_id = APTX_HD_VENDOR_ID,
 | 
				
			||||||
		.codec_id = APTX_HD_CODEC_ID },
 | 
							.codec_id = APTX_HD_CODEC_ID },
 | 
				
			||||||
| 
						 | 
					@ -663,6 +665,7 @@ const struct media_codec a2dp_codec_aptx_hd = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define APTX_LL_COMMON_DEFS				\
 | 
					#define APTX_LL_COMMON_DEFS				\
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,			\
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,			\
 | 
						.codec_id = A2DP_CODEC_VENDOR,			\
 | 
				
			||||||
	.description = "aptX-LL",			\
 | 
						.description = "aptX-LL",			\
 | 
				
			||||||
	.fill_caps = codec_fill_caps,			\
 | 
						.fill_caps = codec_fill_caps,			\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -584,6 +584,7 @@ static const struct media_codec duplex_codec = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define FASTSTREAM_COMMON_DEFS				\
 | 
					#define FASTSTREAM_COMMON_DEFS				\
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,			\
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,			\
 | 
						.codec_id = A2DP_CODEC_VENDOR,			\
 | 
				
			||||||
	.vendor = { .vendor_id = FASTSTREAM_VENDOR_ID,	\
 | 
						.vendor = { .vendor_id = FASTSTREAM_VENDOR_ID,	\
 | 
				
			||||||
		.codec_id = FASTSTREAM_CODEC_ID },	\
 | 
							.codec_id = FASTSTREAM_CODEC_ID },	\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -740,6 +740,7 @@ static int codec_increase_bitpool(void *data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_lc3plus_hr = {
 | 
					const struct media_codec a2dp_codec_lc3plus_hr = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_LC3PLUS_HR,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_LC3PLUS_HR,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.name = "lc3plus_hr",
 | 
						.name = "lc3plus_hr",
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,
 | 
						.codec_id = A2DP_CODEC_VENDOR,
 | 
				
			||||||
	.vendor = { .vendor_id = LC3PLUS_HR_VENDOR_ID,
 | 
						.vendor = { .vendor_id = LC3PLUS_HR_VENDOR_ID,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -748,6 +748,7 @@ static void codec_set_log(struct spa_log *global_log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_ldac = {
 | 
					const struct media_codec a2dp_codec_ldac = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_LDAC,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_LDAC,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,
 | 
						.codec_id = A2DP_CODEC_VENDOR,
 | 
				
			||||||
	.vendor = { .vendor_id = LDAC_VENDOR_ID,
 | 
						.vendor = { .vendor_id = LDAC_VENDOR_ID,
 | 
				
			||||||
		.codec_id = LDAC_CODEC_ID },
 | 
							.codec_id = LDAC_CODEC_ID },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -512,6 +512,7 @@ static void codec_set_log(struct spa_log *global_log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_opus_g = {
 | 
					const struct media_codec a2dp_codec_opus_g = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_G,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_OPUS_G,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,
 | 
						.codec_id = A2DP_CODEC_VENDOR,
 | 
				
			||||||
	.vendor = { .vendor_id = OPUS_G_VENDOR_ID,
 | 
						.vendor = { .vendor_id = OPUS_G_VENDOR_ID,
 | 
				
			||||||
			.codec_id = OPUS_G_CODEC_ID },
 | 
								.codec_id = OPUS_G_CODEC_ID },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1349,6 +1349,7 @@ static void codec_set_log(struct spa_log *global_log)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define OPUS_05_COMMON_DEFS					\
 | 
					#define OPUS_05_COMMON_DEFS					\
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,				\
 | 
				
			||||||
	.codec_id = A2DP_CODEC_VENDOR,				\
 | 
						.codec_id = A2DP_CODEC_VENDOR,				\
 | 
				
			||||||
	.vendor = { .vendor_id = OPUS_05_VENDOR_ID,		\
 | 
						.vendor = { .vendor_id = OPUS_05_VENDOR_ID,		\
 | 
				
			||||||
			.codec_id = OPUS_05_CODEC_ID },		\
 | 
								.codec_id = OPUS_05_CODEC_ID },		\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -634,6 +634,7 @@ static void codec_get_delay(void *data, uint32_t *encoder, uint32_t *decoder)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_sbc = {
 | 
					const struct media_codec a2dp_codec_sbc = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_SBC,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_SBC,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_SBC,
 | 
						.codec_id = A2DP_CODEC_SBC,
 | 
				
			||||||
	.name = "sbc",
 | 
						.name = "sbc",
 | 
				
			||||||
	.description = "SBC",
 | 
						.description = "SBC",
 | 
				
			||||||
| 
						 | 
					@ -657,6 +658,7 @@ const struct media_codec a2dp_codec_sbc = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec a2dp_codec_sbc_xq = {
 | 
					const struct media_codec a2dp_codec_sbc_xq = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_SBC_XQ,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_A2DP,
 | 
				
			||||||
	.codec_id = A2DP_CODEC_SBC,
 | 
						.codec_id = A2DP_CODEC_SBC,
 | 
				
			||||||
	.name = "sbc_xq",
 | 
						.name = "sbc_xq",
 | 
				
			||||||
	.description = "SBC-XQ",
 | 
						.description = "SBC-XQ",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,9 +155,9 @@ static void codec_set_log(struct spa_log *global_log)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec asha_codec_g722 = {
 | 
					const struct media_codec asha_codec_g722 = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_G722,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_G722,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_ASHA,
 | 
				
			||||||
	.codec_id = ASHA_CODEC_G722,
 | 
						.codec_id = ASHA_CODEC_G722,
 | 
				
			||||||
	.name = "g722",
 | 
						.name = "g722",
 | 
				
			||||||
	.asha = true,
 | 
					 | 
				
			||||||
	.description = "G722",
 | 
						.description = "G722",
 | 
				
			||||||
	.fill_caps = NULL,
 | 
						.fill_caps = NULL,
 | 
				
			||||||
	.enum_config = codec_enum_config,
 | 
						.enum_config = codec_enum_config,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1401,9 +1401,9 @@ static int codec_get_bis_config(const struct media_codec *codec, uint8_t *caps,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct media_codec bap_codec_lc3 = {
 | 
					const struct media_codec bap_codec_lc3 = {
 | 
				
			||||||
	.id = SPA_BLUETOOTH_AUDIO_CODEC_LC3,
 | 
						.id = SPA_BLUETOOTH_AUDIO_CODEC_LC3,
 | 
				
			||||||
 | 
						.kind = MEDIA_CODEC_BAP,
 | 
				
			||||||
	.name = "lc3",
 | 
						.name = "lc3",
 | 
				
			||||||
	.codec_id = BAP_CODEC_LC3,
 | 
						.codec_id = BAP_CODEC_LC3,
 | 
				
			||||||
	.bap = true,
 | 
					 | 
				
			||||||
	.description = "LC3",
 | 
						.description = "LC3",
 | 
				
			||||||
	.fill_caps = codec_fill_caps,
 | 
						.fill_caps = codec_fill_caps,
 | 
				
			||||||
	.select_config = codec_select_config,
 | 
						.select_config = codec_select_config,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -458,9 +458,9 @@ static int media_codec_to_endpoint(const struct media_codec *codec,
 | 
				
			||||||
	const char * endpoint;
 | 
						const char * endpoint;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (direction == SPA_BT_MEDIA_SOURCE)
 | 
						if (direction == SPA_BT_MEDIA_SOURCE)
 | 
				
			||||||
		endpoint = codec->bap ? BAP_SOURCE_ENDPOINT : A2DP_SOURCE_ENDPOINT;
 | 
							endpoint = codec->kind == MEDIA_CODEC_BAP ? BAP_SOURCE_ENDPOINT : A2DP_SOURCE_ENDPOINT;
 | 
				
			||||||
	else if (direction == SPA_BT_MEDIA_SINK)
 | 
						else if (direction == SPA_BT_MEDIA_SINK)
 | 
				
			||||||
		endpoint = codec->bap ? BAP_SINK_ENDPOINT : A2DP_SINK_ENDPOINT;
 | 
							endpoint = codec->kind == MEDIA_CODEC_BAP ? BAP_SINK_ENDPOINT : A2DP_SINK_ENDPOINT;
 | 
				
			||||||
	else if (direction == SPA_BT_MEDIA_SOURCE_BROADCAST)
 | 
						else if (direction == SPA_BT_MEDIA_SOURCE_BROADCAST)
 | 
				
			||||||
		endpoint = BAP_BROADCAST_SOURCE_ENDPOINT;
 | 
							endpoint = BAP_BROADCAST_SOURCE_ENDPOINT;
 | 
				
			||||||
	else if (direction == SPA_BT_MEDIA_SINK_BROADCAST)
 | 
						else if (direction == SPA_BT_MEDIA_SINK_BROADCAST)
 | 
				
			||||||
| 
						 | 
					@ -568,11 +568,14 @@ static enum spa_bt_profile get_codec_profile(const struct media_codec *codec,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	switch (direction) {
 | 
						switch (direction) {
 | 
				
			||||||
	case SPA_BT_MEDIA_SOURCE:
 | 
						case SPA_BT_MEDIA_SOURCE:
 | 
				
			||||||
		return codec->bap ? SPA_BT_PROFILE_BAP_SOURCE : SPA_BT_PROFILE_A2DP_SOURCE;
 | 
							return codec->kind == MEDIA_CODEC_BAP ? SPA_BT_PROFILE_BAP_SOURCE : SPA_BT_PROFILE_A2DP_SOURCE;
 | 
				
			||||||
	case SPA_BT_MEDIA_SINK:
 | 
						case SPA_BT_MEDIA_SINK:
 | 
				
			||||||
		if (codec->asha)
 | 
							if (codec->kind == MEDIA_CODEC_ASHA)
 | 
				
			||||||
			return SPA_BT_PROFILE_ASHA_SINK;
 | 
								return SPA_BT_PROFILE_ASHA_SINK;
 | 
				
			||||||
		return codec->bap ? SPA_BT_PROFILE_BAP_SINK : SPA_BT_PROFILE_A2DP_SINK;
 | 
							else if (codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
 | 
								return SPA_BT_PROFILE_BAP_SINK;
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								return SPA_BT_PROFILE_A2DP_SINK;
 | 
				
			||||||
	case SPA_BT_MEDIA_SOURCE_BROADCAST:
 | 
						case SPA_BT_MEDIA_SOURCE_BROADCAST:
 | 
				
			||||||
		return SPA_BT_PROFILE_BAP_BROADCAST_SOURCE;
 | 
							return SPA_BT_PROFILE_BAP_BROADCAST_SOURCE;
 | 
				
			||||||
	case SPA_BT_MEDIA_SINK_BROADCAST:
 | 
						case SPA_BT_MEDIA_SINK_BROADCAST:
 | 
				
			||||||
| 
						 | 
					@ -971,7 +974,7 @@ static DBusHandlerResult endpoint_select_properties(DBusConnection *conn, DBusMe
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	codec = media_endpoint_to_codec(monitor, path, &sink, NULL);
 | 
						codec = media_endpoint_to_codec(monitor, path, &sink, NULL);
 | 
				
			||||||
	spa_log_debug(monitor->log, "%p: %s codec:%s", monitor, path, codec ? codec->name : "<null>");
 | 
						spa_log_debug(monitor->log, "%p: %s codec:%s", monitor, path, codec ? codec->name : "<null>");
 | 
				
			||||||
	if (!codec || !codec->bap || !codec->get_qos) {
 | 
						if (!codec || codec->kind != MEDIA_CODEC_BAP || !codec->get_qos) {
 | 
				
			||||||
		spa_log_error(monitor->log, "Unsupported codec");
 | 
							spa_log_error(monitor->log, "Unsupported codec");
 | 
				
			||||||
		err_msg = "Unsupported codec";
 | 
							err_msg = "Unsupported codec";
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
| 
						 | 
					@ -2537,7 +2540,7 @@ bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const stru
 | 
				
			||||||
		{ SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX },
 | 
							{ SPA_BLUETOOTH_AUDIO_CODEC_APTX_LL_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX },
 | 
				
			||||||
		{ SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX },
 | 
							{ SPA_BLUETOOTH_AUDIO_CODEC_FASTSTREAM_DUPLEX, SPA_BT_FEATURE_A2DP_DUPLEX },
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	bool is_a2dp = !codec->bap && !codec->asha;
 | 
						bool is_a2dp = codec->kind == MEDIA_CODEC_A2DP;
 | 
				
			||||||
	size_t i;
 | 
						size_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!is_media_codec_enabled(device->monitor, codec))
 | 
						if (!is_media_codec_enabled(device->monitor, codec))
 | 
				
			||||||
| 
						 | 
					@ -2548,7 +2551,7 @@ bool spa_bt_device_supports_media_codec(struct spa_bt_device *device, const stru
 | 
				
			||||||
		return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc") &&
 | 
							return (codec->codec_id == A2DP_CODEC_SBC && spa_streq(codec->name, "sbc") &&
 | 
				
			||||||
				device->adapter->legacy_endpoints_registered);
 | 
									device->adapter->legacy_endpoints_registered);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!device->adapter->bap_application_registered && codec->bap)
 | 
						if (!device->adapter->bap_application_registered && codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check codec quirks */
 | 
						/* Check codec quirks */
 | 
				
			||||||
| 
						 | 
					@ -4178,7 +4181,7 @@ static int setup_asha_transport(struct spa_bt_remote_endpoint *remote_endpoint,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 0; media_codecs[i]; i++) {
 | 
						for (int i = 0; media_codecs[i]; i++) {
 | 
				
			||||||
		const struct media_codec *mcodec = media_codecs[i];
 | 
							const struct media_codec *mcodec = media_codecs[i];
 | 
				
			||||||
		if (!mcodec->asha)
 | 
							if (mcodec->kind != MEDIA_CODEC_ASHA)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (!spa_streq(mcodec->name, "g722"))
 | 
							if (!spa_streq(mcodec->name, "g722"))
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
| 
						 | 
					@ -4577,7 +4580,7 @@ static int media_codec_switch_cmp(const void *a, const void *b)
 | 
				
			||||||
	else if (ep2 == NULL)
 | 
						else if (ep2 == NULL)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (codec->bap)
 | 
						if (codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
		flags = spa_streq(ep1->uuid, SPA_BT_UUID_BAP_SOURCE) ? MEDIA_CODEC_FLAG_SINK : 0;
 | 
							flags = spa_streq(ep1->uuid, SPA_BT_UUID_BAP_SOURCE) ? MEDIA_CODEC_FLAG_SINK : 0;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		flags = spa_streq(ep1->uuid, SPA_BT_UUID_A2DP_SOURCE) ? MEDIA_CODEC_FLAG_SINK : 0;
 | 
							flags = spa_streq(ep1->uuid, SPA_BT_UUID_A2DP_SOURCE) ? MEDIA_CODEC_FLAG_SINK : 0;
 | 
				
			||||||
| 
						 | 
					@ -5178,10 +5181,9 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *
 | 
				
			||||||
			uint8_t caps[A2DP_MAX_CAPS_SIZE];
 | 
								uint8_t caps[A2DP_MAX_CAPS_SIZE];
 | 
				
			||||||
			int caps_size, ret;
 | 
								int caps_size, ret;
 | 
				
			||||||
			uint16_t codec_id = codec->codec_id;
 | 
								uint16_t codec_id = codec->codec_id;
 | 
				
			||||||
 | 
								enum media_codec_kind kind = is_bap ? MEDIA_CODEC_BAP : MEDIA_CODEC_A2DP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (codec->bap != is_bap)
 | 
								if (codec->kind != kind)
 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
			if (codec->asha)
 | 
					 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (!is_media_codec_enabled(monitor, codec))
 | 
								if (!is_media_codec_enabled(monitor, codec))
 | 
				
			||||||
| 
						 | 
					@ -5197,7 +5199,7 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *
 | 
				
			||||||
				if (ret == 0) {
 | 
									if (ret == 0) {
 | 
				
			||||||
					spa_log_info(monitor->log, "register media sink codec %s: %s", media_codecs[i]->name, endpoint);
 | 
										spa_log_info(monitor->log, "register media sink codec %s: %s", media_codecs[i]->name, endpoint);
 | 
				
			||||||
					append_media_object(monitor, &array, endpoint,
 | 
										append_media_object(monitor, &array, endpoint,
 | 
				
			||||||
					        codec->bap ? SPA_BT_UUID_BAP_SINK : SPA_BT_UUID_A2DP_SINK,
 | 
										        is_bap ? SPA_BT_UUID_BAP_SINK : SPA_BT_UUID_A2DP_SINK,
 | 
				
			||||||
							codec_id, caps, caps_size);
 | 
												codec_id, caps, caps_size);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -5212,12 +5214,12 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *
 | 
				
			||||||
				if (ret == 0) {
 | 
									if (ret == 0) {
 | 
				
			||||||
					spa_log_info(monitor->log, "register media source codec %s: %s", media_codecs[i]->name, endpoint);
 | 
										spa_log_info(monitor->log, "register media source codec %s: %s", media_codecs[i]->name, endpoint);
 | 
				
			||||||
					append_media_object(monitor, &array, endpoint,
 | 
										append_media_object(monitor, &array, endpoint,
 | 
				
			||||||
					        codec->bap ? SPA_BT_UUID_BAP_SOURCE : SPA_BT_UUID_A2DP_SOURCE,
 | 
										        is_bap ? SPA_BT_UUID_BAP_SOURCE : SPA_BT_UUID_A2DP_SOURCE,
 | 
				
			||||||
							codec_id, caps, caps_size);
 | 
												codec_id, caps, caps_size);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (codec->bap && register_bcast) {
 | 
								if (is_bap && register_bcast) {
 | 
				
			||||||
				if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST)) {
 | 
									if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST)) {
 | 
				
			||||||
					caps_size = codec->fill_caps(codec, 0, &monitor->global_settings, caps);
 | 
										caps_size = codec->fill_caps(codec, 0, &monitor->global_settings, caps);
 | 
				
			||||||
					if (caps_size < 0)
 | 
										if (caps_size < 0)
 | 
				
			||||||
| 
						 | 
					@ -5375,7 +5377,7 @@ static int register_media_application(struct spa_bt_monitor * monitor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE);
 | 
							register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE);
 | 
				
			||||||
		register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK);
 | 
							register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK);
 | 
				
			||||||
		if (codec->bap) {
 | 
							if (codec->kind == MEDIA_CODEC_BAP) {
 | 
				
			||||||
			register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST);
 | 
								register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST);
 | 
				
			||||||
			register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK_BROADCAST);
 | 
								register_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK_BROADCAST);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -5411,7 +5413,7 @@ static void unregister_media_application(struct spa_bt_monitor * monitor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE);
 | 
							unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE);
 | 
				
			||||||
		unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK);
 | 
							unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK);
 | 
				
			||||||
		if (codec->bap) {
 | 
							if (codec->kind == MEDIA_CODEC_BAP) {
 | 
				
			||||||
			unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST);
 | 
								unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SOURCE_BROADCAST);
 | 
				
			||||||
			unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK_BROADCAST);
 | 
								unregister_media_endpoint(monitor, codec, SPA_BT_MEDIA_SINK_BROADCAST);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -5428,8 +5430,9 @@ static bool have_codec_endpoints(struct spa_bt_monitor *monitor, bool bap)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; media_codecs[i]; i++) {
 | 
						for (i = 0; media_codecs[i]; i++) {
 | 
				
			||||||
		const struct media_codec *codec = media_codecs[i];
 | 
							const struct media_codec *codec = media_codecs[i];
 | 
				
			||||||
 | 
							enum media_codec_kind kind = bap ? MEDIA_CODEC_BAP : MEDIA_CODEC_A2DP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (codec->bap != bap)
 | 
							if (codec->kind != kind)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SINK) ||
 | 
							if (endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SINK) ||
 | 
				
			||||||
				endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE) ||
 | 
									endpoint_should_be_registered(monitor, codec, SPA_BT_MEDIA_SOURCE) ||
 | 
				
			||||||
| 
						 | 
					@ -5779,7 +5782,7 @@ static void interface_added(struct spa_bt_monitor *monitor,
 | 
				
			||||||
			/* get local endpoint */
 | 
								/* get local endpoint */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for (i = 0; monitor->media_codecs[i]; i++) {
 | 
								for (i = 0; monitor->media_codecs[i]; i++) {
 | 
				
			||||||
				if (!monitor->media_codecs[i]->bap)
 | 
									if (monitor->media_codecs[i]->kind != MEDIA_CODEC_BAP)
 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
				if (!is_media_codec_enabled(monitor, monitor->media_codecs[i]))
 | 
									if (!is_media_codec_enabled(monitor, monitor->media_codecs[i]))
 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -120,6 +120,17 @@ static int load_media_codecs_from(struct impl *impl, const char *factory_name, c
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							switch (c->kind) {
 | 
				
			||||||
 | 
							case MEDIA_CODEC_A2DP:
 | 
				
			||||||
 | 
							case MEDIA_CODEC_BAP:
 | 
				
			||||||
 | 
							case MEDIA_CODEC_ASHA:
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								spa_log_warn(impl->log, "codec plugin %s: unknown codec %s kind %d",
 | 
				
			||||||
 | 
										factory_name, c->name, c->kind);
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Don't load duplicate endpoints */
 | 
							/* Don't load duplicate endpoints */
 | 
				
			||||||
		for (j = 0; j < impl->n_codecs; ++j) {
 | 
							for (j = 0; j < impl->n_codecs; ++j) {
 | 
				
			||||||
			const struct media_codec *c2 = impl->codecs[j];
 | 
								const struct media_codec *c2 = impl->codecs[j];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -417,7 +417,7 @@ static struct stream *stream_create(struct spa_bt_transport *t, struct group *gr
 | 
				
			||||||
		sink = false;
 | 
							sink = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!t->media_codec->bap || !t->media_codec->get_interval) {
 | 
						if (t->media_codec->kind != MEDIA_CODEC_BAP || !t->media_codec->get_interval) {
 | 
				
			||||||
		res = -EINVAL;
 | 
							res = -EINVAL;
 | 
				
			||||||
		goto fail;
 | 
							goto fail;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ bool media_codec_check_caps(const struct media_codec *codec, unsigned int codec_
 | 
				
			||||||
	if (res < 0)
 | 
						if (res < 0)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (codec->bap)
 | 
						if (codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return ((size_t)res == caps_size);
 | 
							return ((size_t)res == caps_size);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SPA_TYPE_INTERFACE_Bluez5CodecMedia	SPA_TYPE_INFO_INTERFACE_BASE "Bluez5:Codec:Media:Private"
 | 
					#define SPA_TYPE_INTERFACE_Bluez5CodecMedia	SPA_TYPE_INFO_INTERFACE_BASE "Bluez5:Codec:Media:Private"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SPA_VERSION_BLUEZ5_CODEC_MEDIA		13
 | 
					#define SPA_VERSION_BLUEZ5_CODEC_MEDIA		14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct spa_bluez5_codec_a2dp {
 | 
					struct spa_bluez5_codec_a2dp {
 | 
				
			||||||
	struct spa_interface iface;
 | 
						struct spa_interface iface;
 | 
				
			||||||
| 
						 | 
					@ -60,6 +60,13 @@ enum {
 | 
				
			||||||
	NEED_FLUSH_FRAGMENT = 2,
 | 
						NEED_FLUSH_FRAGMENT = 2,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum media_codec_kind {
 | 
				
			||||||
 | 
					        MEDIA_CODEC_A2DP,
 | 
				
			||||||
 | 
					        MEDIA_CODEC_BAP,
 | 
				
			||||||
 | 
					        MEDIA_CODEC_ASHA,
 | 
				
			||||||
 | 
					        MEDIA_CODEC_HFP,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct media_codec_audio_info {
 | 
					struct media_codec_audio_info {
 | 
				
			||||||
	uint32_t rate;
 | 
						uint32_t rate;
 | 
				
			||||||
	uint32_t channels;
 | 
						uint32_t channels;
 | 
				
			||||||
| 
						 | 
					@ -67,12 +74,11 @@ struct media_codec_audio_info {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct media_codec {
 | 
					struct media_codec {
 | 
				
			||||||
	enum spa_bluetooth_audio_codec id;
 | 
						enum spa_bluetooth_audio_codec id;
 | 
				
			||||||
 | 
						enum media_codec_kind kind;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint8_t codec_id;
 | 
						uint8_t codec_id;
 | 
				
			||||||
	a2dp_vendor_codec_t vendor;
 | 
						a2dp_vendor_codec_t vendor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool bap;
 | 
					 | 
				
			||||||
	bool asha;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
	const char *description;
 | 
						const char *description;
 | 
				
			||||||
	const char *endpoint_name;	/**< Endpoint name. If NULL, same as name */
 | 
						const char *endpoint_name;	/**< Endpoint name. If NULL, same as name */
 | 
				
			||||||
| 
						 | 
					@ -219,6 +225,21 @@ struct media_codec_config {
 | 
				
			||||||
	unsigned int priority;
 | 
						unsigned int priority;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline const char *media_codec_kind_str(const struct media_codec *codec)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (codec->kind) {
 | 
				
			||||||
 | 
						case MEDIA_CODEC_A2DP:
 | 
				
			||||||
 | 
							return "A2DP";
 | 
				
			||||||
 | 
						case MEDIA_CODEC_BAP:
 | 
				
			||||||
 | 
							return "BAP";
 | 
				
			||||||
 | 
						case MEDIA_CODEC_ASHA:
 | 
				
			||||||
 | 
							return "ASHA";
 | 
				
			||||||
 | 
						case MEDIA_CODEC_HFP:
 | 
				
			||||||
 | 
							return "HFP";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "unknown";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int media_codec_select_config(const struct media_codec_config configs[], size_t n,
 | 
					int media_codec_select_config(const struct media_codec_config configs[], size_t n,
 | 
				
			||||||
	uint32_t cap, int preferred_value);
 | 
						uint32_t cap, int preferred_value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -649,8 +649,12 @@ static int reset_buffer(struct impl *this)
 | 
				
			||||||
	this->need_flush = 0;
 | 
						this->need_flush = 0;
 | 
				
			||||||
	this->block_count = 0;
 | 
						this->block_count = 0;
 | 
				
			||||||
	this->fragment = false;
 | 
						this->fragment = false;
 | 
				
			||||||
	this->timestamp = (this->codec->bap || this->codec->asha) ? (get_reference_time(this, NULL) / SPA_NSEC_PER_USEC)
 | 
					
 | 
				
			||||||
		: this->sample_count;
 | 
						if (this->codec->kind == MEDIA_CODEC_BAP || this->codec->kind == MEDIA_CODEC_ASHA)
 | 
				
			||||||
 | 
							this->timestamp = get_reference_time(this, NULL) / SPA_NSEC_PER_USEC;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							this->timestamp = this->sample_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->buffer_used = this->codec->start_encode(this->codec_data,
 | 
						this->buffer_used = this->codec->start_encode(this->codec_data,
 | 
				
			||||||
			this->buffer, sizeof(this->buffer),
 | 
								this->buffer, sizeof(this->buffer),
 | 
				
			||||||
			++this->seqnum, this->timestamp);
 | 
								++this->seqnum, this->timestamp);
 | 
				
			||||||
| 
						 | 
					@ -865,7 +869,7 @@ static void enable_flush_timer(struct impl *this, bool enabled)
 | 
				
			||||||
static int flush_data(struct impl *this, uint64_t now_time)
 | 
					static int flush_data(struct impl *this, uint64_t now_time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct port *port = &this->port;
 | 
						struct port *port = &this->port;
 | 
				
			||||||
	bool is_asha = this->codec->asha;
 | 
						bool is_asha = this->codec->kind == MEDIA_CODEC_ASHA;
 | 
				
			||||||
	uint32_t total_frames;
 | 
						uint32_t total_frames;
 | 
				
			||||||
	int written;
 | 
						int written;
 | 
				
			||||||
	int unsent_buffer;
 | 
						int unsent_buffer;
 | 
				
			||||||
| 
						 | 
					@ -1447,7 +1451,7 @@ static int transport_start(struct impl *this)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conf = this->transport->configuration;
 | 
						conf = this->transport->configuration;
 | 
				
			||||||
	size = this->transport->configuration_len;
 | 
						size = this->transport->configuration_len;
 | 
				
			||||||
	is_asha = this->codec->asha;
 | 
						is_asha = this->codec->kind == MEDIA_CODEC_ASHA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_debug(this->log, "Transport configuration:");
 | 
						spa_log_debug(this->log, "Transport configuration:");
 | 
				
			||||||
	spa_debug_log_mem(this->log, SPA_LOG_LEVEL_DEBUG, 2, conf, (size_t)size);
 | 
						spa_debug_log_mem(this->log, SPA_LOG_LEVEL_DEBUG, 2, conf, (size_t)size);
 | 
				
			||||||
| 
						 | 
					@ -1478,7 +1482,7 @@ static int transport_start(struct impl *this)
 | 
				
			||||||
	if (this->codec->get_delay)
 | 
						if (this->codec->get_delay)
 | 
				
			||||||
		this->codec->get_delay(this->codec_data, &this->encoder_delay, NULL);
 | 
							this->codec->get_delay(this->codec_data, &this->encoder_delay, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *codec_profile = this->codec->asha ? "ASHA" : (this->codec->bap ? "BAP" : "A2DP");
 | 
						const char *codec_profile = media_codec_kind_str(this->codec);
 | 
				
			||||||
	spa_log_info(this->log, "%p: using %s codec %s, delay:%.2f ms, codec-delay:%.2f ms", this,
 | 
						spa_log_info(this->log, "%p: using %s codec %s, delay:%.2f ms, codec-delay:%.2f ms", this,
 | 
				
			||||||
			codec_profile, this->codec->description,
 | 
								codec_profile, this->codec->description,
 | 
				
			||||||
			(double)spa_bt_transport_get_delay_nsec(this->transport) / SPA_NSEC_PER_MSEC,
 | 
								(double)spa_bt_transport_get_delay_nsec(this->transport) / SPA_NSEC_PER_MSEC,
 | 
				
			||||||
| 
						 | 
					@ -1653,7 +1657,7 @@ static int do_remove_transport_source(struct spa_loop *loop,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->flush_timer_source.loop)
 | 
						if (this->flush_timer_source.loop)
 | 
				
			||||||
		spa_loop_remove_source(this->data_loop, &this->flush_timer_source);
 | 
							spa_loop_remove_source(this->data_loop, &this->flush_timer_source);
 | 
				
			||||||
	if (this->codec->asha) {
 | 
						if (this->codec->kind == MEDIA_CODEC_ASHA) {
 | 
				
			||||||
		if (this->asha->timer_source.loop)
 | 
							if (this->asha->timer_source.loop)
 | 
				
			||||||
			spa_loop_remove_source(this->data_loop, &this->asha->timer_source);
 | 
								spa_loop_remove_source(this->data_loop, &this->asha->timer_source);
 | 
				
			||||||
		if (this->asha->flush_source.loop)
 | 
							if (this->asha->flush_source.loop)
 | 
				
			||||||
| 
						 | 
					@ -1761,7 +1765,7 @@ static void emit_node_info(struct impl *this, bool full)
 | 
				
			||||||
		node_group = node_group_buf;
 | 
							node_group = node_group_buf;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *codec_profile = this->codec->asha ? "ASHA" : (this->codec->bap ? "BAP" : "A2DP");
 | 
						const char *codec_profile = media_codec_kind_str(this->codec);
 | 
				
			||||||
	struct spa_dict_item node_info_items[] = {
 | 
						struct spa_dict_item node_info_items[] = {
 | 
				
			||||||
		{ SPA_KEY_DEVICE_API, "bluez5" },
 | 
							{ SPA_KEY_DEVICE_API, "bluez5" },
 | 
				
			||||||
		{ SPA_KEY_MEDIA_CLASS, this->is_internal ? "Audio/Sink/Internal" :
 | 
							{ SPA_KEY_MEDIA_CLASS, this->is_internal ? "Audio/Sink/Internal" :
 | 
				
			||||||
| 
						 | 
					@ -1945,7 +1949,7 @@ impl_node_port_enum_params(void *object, int seq,
 | 
				
			||||||
				SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers)));
 | 
									SPA_PARAM_IO_size, SPA_POD_Int(sizeof(struct spa_io_buffers)));
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case 1:
 | 
							case 1:
 | 
				
			||||||
			if (!this->codec->bap)
 | 
								if (this->codec->kind != MEDIA_CODEC_BAP)
 | 
				
			||||||
				return 0;
 | 
									return 0;
 | 
				
			||||||
			param = spa_pod_builder_add_object(&b,
 | 
								param = spa_pod_builder_add_object(&b,
 | 
				
			||||||
				SPA_TYPE_OBJECT_ParamIO, id,
 | 
									SPA_TYPE_OBJECT_ParamIO, id,
 | 
				
			||||||
| 
						 | 
					@ -2158,7 +2162,7 @@ impl_node_port_set_io(void *object,
 | 
				
			||||||
		port->io = data;
 | 
							port->io = data;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case SPA_IO_RateMatch:
 | 
						case SPA_IO_RateMatch:
 | 
				
			||||||
		if (!this->codec->bap)
 | 
							if (this->codec->kind != MEDIA_CODEC_BAP)
 | 
				
			||||||
			return -ENOENT;
 | 
								return -ENOENT;
 | 
				
			||||||
		port->rate_match = data;
 | 
							port->rate_match = data;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
| 
						 | 
					@ -2244,7 +2248,7 @@ static int impl_node_process(void *object)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setup_matching(this);
 | 
						setup_matching(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->codec->asha && !this->asha->set_timer) {
 | 
						if (this->codec->kind == MEDIA_CODEC_ASHA && !this->asha->set_timer) {
 | 
				
			||||||
		struct impl *other = find_other_asha(this);
 | 
							struct impl *other = find_other_asha(this);
 | 
				
			||||||
		if (other && other->asha->ref_t0 != 0) {
 | 
							if (other && other->asha->ref_t0 != 0) {
 | 
				
			||||||
			this->asha->ref_t0 = other->asha->ref_t0;
 | 
								this->asha->ref_t0 = other->asha->ref_t0;
 | 
				
			||||||
| 
						 | 
					@ -2390,7 +2394,7 @@ static int impl_clear(struct spa_handle *handle)
 | 
				
			||||||
		spa_hook_remove(&this->transport_listener);
 | 
							spa_hook_remove(&this->transport_listener);
 | 
				
			||||||
	spa_system_close(this->data_system, this->timerfd);
 | 
						spa_system_close(this->data_system, this->timerfd);
 | 
				
			||||||
	spa_system_close(this->data_system, this->flush_timerfd);
 | 
						spa_system_close(this->data_system, this->flush_timerfd);
 | 
				
			||||||
	if (this->codec->asha) {
 | 
						if (this->codec->kind == MEDIA_CODEC_ASHA) {
 | 
				
			||||||
		spa_system_close(this->data_system, this->asha->timerfd);
 | 
							spa_system_close(this->data_system, this->asha->timerfd);
 | 
				
			||||||
		free(this->asha);
 | 
							free(this->asha);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -2519,7 +2523,7 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
					this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0,
 | 
										this->is_duplex ? MEDIA_CODEC_FLAG_SINK : 0,
 | 
				
			||||||
					this->transport->device->settings);
 | 
										this->transport->device->settings);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->codec->bap)
 | 
						if (this->codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
		this->is_output = this->transport->bap_initiator;
 | 
							this->is_output = this->transport->bap_initiator;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		this->is_output = true;
 | 
							this->is_output = true;
 | 
				
			||||||
| 
						 | 
					@ -2537,7 +2541,7 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
	this->flush_timerfd = spa_system_timerfd_create(this->data_system,
 | 
						this->flush_timerfd = spa_system_timerfd_create(this->data_system,
 | 
				
			||||||
			CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
 | 
								CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->codec->asha) {
 | 
						if (this->codec->kind == MEDIA_CODEC_ASHA) {
 | 
				
			||||||
		this->asha = calloc(1, sizeof(struct spa_bt_asha));
 | 
							this->asha = calloc(1, sizeof(struct spa_bt_asha));
 | 
				
			||||||
		if (this->asha == NULL)
 | 
							if (this->asha == NULL)
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -324,7 +324,7 @@ static void emit_node_info(struct impl *this, bool full);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_latency(struct impl *this, bool emit_latency)
 | 
					static void set_latency(struct impl *this, bool emit_latency)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (this->codec->bap && !this->is_input && this->transport &&
 | 
						if (this->codec->kind == MEDIA_CODEC_BAP && !this->is_input && this->transport &&
 | 
				
			||||||
			this->transport->delay_us != SPA_BT_UNKNOWN_DELAY) {
 | 
								this->transport->delay_us != SPA_BT_UNKNOWN_DELAY) {
 | 
				
			||||||
		struct port *port = &this->port;
 | 
							struct port *port = &this->port;
 | 
				
			||||||
		unsigned int node_latency = 2048;
 | 
							unsigned int node_latency = 2048;
 | 
				
			||||||
| 
						 | 
					@ -751,7 +751,7 @@ static int transport_start(struct impl *this)
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_log_info(this->log, "%p: using %s codec %s", this,
 | 
						spa_log_info(this->log, "%p: using %s codec %s", this,
 | 
				
			||||||
	             this->codec->bap ? "BAP" : "A2DP", this->codec->description);
 | 
								media_codec_kind_str(this->codec), this->codec->description);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * If the link is bidirectional, media-sink may also be polling the same FD,
 | 
						 * If the link is bidirectional, media-sink may also be polling the same FD,
 | 
				
			||||||
| 
						 | 
					@ -983,7 +983,7 @@ static void emit_node_info(struct impl *this, bool full)
 | 
				
			||||||
		sizeof(media_name),
 | 
							sizeof(media_name),
 | 
				
			||||||
		"%s (codec %s)",
 | 
							"%s (codec %s)",
 | 
				
			||||||
		((this->transport && this->transport->device->name) ?
 | 
							((this->transport && this->transport->device->name) ?
 | 
				
			||||||
			this->transport->device->name : this->codec->bap ? "BAP" : "A2DP"),
 | 
								this->transport->device->name : media_codec_kind_str(this->codec)),
 | 
				
			||||||
		this->codec->description
 | 
							this->codec->description
 | 
				
			||||||
	);
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1465,7 +1465,7 @@ static void update_target_latency(struct impl *this)
 | 
				
			||||||
	if (this->transport == NULL || !port->have_format)
 | 
						if (this->transport == NULL || !port->have_format)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!this->codec->bap || this->is_input ||
 | 
						if (this->codec->kind != MEDIA_CODEC_BAP || this->is_input ||
 | 
				
			||||||
			this->transport->delay_us == SPA_BT_UNKNOWN_DELAY)
 | 
								this->transport->delay_us == SPA_BT_UNKNOWN_DELAY)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1905,7 +1905,7 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
		this->is_input = true;
 | 
							this->is_input = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->codec->bap)
 | 
						if (this->codec->kind == MEDIA_CODEC_BAP)
 | 
				
			||||||
		this->is_input = this->transport->bap_initiator;
 | 
							this->is_input = this->transport->bap_initiator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->codec->init_props != NULL)
 | 
						if (this->codec->init_props != NULL)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue