From 66cf4e68d5fed8d57d9161cdbfef8acb521be551 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 27 Oct 2020 15:42:48 +0100 Subject: [PATCH] pulse-server: use EnumFormat as fallback Use a fixated format and position from EnumFormat as a fallback. --- src/modules/module-protocol-pulse/format.c | 23 ++++---- src/modules/module-protocol-pulse/manager.c | 3 +- .../module-protocol-pulse/pulse-server.c | 52 +++++++++++++++++-- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index 7a99aa6a0..a6fd9a2c4 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -326,18 +326,19 @@ static int format_parse_param(const struct spa_pod *param, struct sample_spec *s !SPA_AUDIO_FORMAT_IS_INTERLEAVED(info.info.raw.format)) { return -ENOTSUP; } + if (ss) { + ss->format = format_id2pa(info.info.raw.format); + if (ss->format == SAMPLE_INVALID) + return -ENOTSUP; - ss->format = format_id2pa(info.info.raw.format); - if (ss->format == SAMPLE_INVALID) - return -ENOTSUP; - - ss->rate = info.info.raw.rate; - ss->channels = info.info.raw.channels; - - map->channels = info.info.raw.channels; - for (i = 0; i < map->channels; i++) - map->map[i] = channel_id2pa(info.info.raw.position[i], &aux); - + ss->rate = info.info.raw.rate; + ss->channels = info.info.raw.channels; + } + if (map) { + map->channels = info.info.raw.channels; + for (i = 0; i < map->channels; i++) + map->map[i] = channel_id2pa(info.info.raw.position[i], &aux); + } return 0; } diff --git a/src/modules/module-protocol-pulse/manager.c b/src/modules/module-protocol-pulse/manager.c index ce809c0af..6f5e95faa 100644 --- a/src/modules/module-protocol-pulse/manager.c +++ b/src/modules/module-protocol-pulse/manager.c @@ -529,8 +529,6 @@ struct pw_manager *pw_manager_new(struct pw_core *core) &m->registry_listener, ®istry_events, m); - core_sync(m); - return &m->this; } @@ -540,6 +538,7 @@ void pw_manager_add_listener(struct pw_manager *manager, { struct manager *m = SPA_CONTAINER_OF(manager, struct manager, this); spa_hook_list_append(&m->hooks, listener, events, data); + core_sync(m); } struct pw_manager_object *pw_manager_find_object(struct pw_manager *manager, diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index df65052e9..9f689c79c 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -1067,7 +1067,6 @@ static int reply_create_playback_stream(struct stream *stream) peer_name = NULL; peer_suspended = false; } - pw_log_info("peer:%p id:%d name:%s", peer, peer_id, peer_name); if (client->version >= 9) { message_put(reply, @@ -1179,7 +1178,6 @@ static int reply_create_record_stream(struct stream *stream) peer_name = NULL; peer_suspended = false; } - pw_log_info("peer:%p id:%d name:%s", peer, peer_id, peer_name); if (client->version >= 9) { message_put(reply, @@ -1928,8 +1926,6 @@ static int do_create_record_stream(struct client *client, uint32_t command, uint if (no_move) flags |= PW_STREAM_FLAG_DONT_RECONNECT; - pw_log_info("direct %u", direct_on_input_idx); - if (direct_on_input_idx != SPA_ID_INVALID) { source_index = direct_on_input_idx; } else if (source_name != NULL) { @@ -2917,11 +2913,23 @@ static int fill_sink_info(struct client *client, struct message *m, spa_list_for_each(p, &o->param_list, link) { switch (p->id) { + case SPA_PARAM_EnumFormat: + { + struct spa_pod *copy = spa_pod_copy(p->param); + spa_pod_fixate(copy); + format_parse_param(copy, &ss, &map); + free(copy); + break; + } case SPA_PARAM_Format: format_parse_param(p->param, &ss, &map); break; } } + if (ss.channels != map.channels) + ss.channels = map.channels; + if (volume_info.volume.channels != map.channels) + volume_info.volume.channels = map.channels; message_put(m, TAG_U32, o->id, /* sink index */ @@ -3010,11 +3018,23 @@ static int fill_source_info(struct client *client, struct message *m, spa_list_for_each(p, &o->param_list, link) { switch (p->id) { + case SPA_PARAM_EnumFormat: + { + struct spa_pod *copy = spa_pod_copy(p->param); + spa_pod_fixate(copy); + format_parse_param(copy, &ss, &map); + free(copy); + break; + } case SPA_PARAM_Format: format_parse_param(p->param, &ss, &map); break; } } + if (ss.channels != map.channels) + ss.channels = map.channels; + if (volume_info.volume.channels != map.channels) + volume_info.volume.channels = map.channels; message_put(m, TAG_U32, is_monitor ? o->id | 0x10000 : o->id, /* source index */ @@ -3088,6 +3108,14 @@ static int fill_sink_input_info(struct client *client, struct message *m, spa_list_for_each(p, &o->param_list, link) { switch (p->id) { + case SPA_PARAM_EnumFormat: + { + struct spa_pod *copy = spa_pod_copy(p->param); + spa_pod_fixate(copy); + format_parse_param(copy, &ss, &map); + free(copy); + break; + } case SPA_PARAM_Format: format_parse_param(p->param, &ss, &map); break; @@ -3096,6 +3124,10 @@ static int fill_sink_input_info(struct client *client, struct message *m, break; } } + if (ss.channels != map.channels) + ss.channels = map.channels; + if (volume_info.volume.channels != map.channels) + volume_info.volume.channels = map.channels; peer = find_linked(client, o->id, PW_DIRECTION_OUTPUT); @@ -3164,6 +3196,14 @@ static int fill_source_output_info(struct client *client, struct message *m, spa_list_for_each(p, &o->param_list, link) { switch (p->id) { + case SPA_PARAM_EnumFormat: + { + struct spa_pod *copy = spa_pod_copy(p->param); + spa_pod_fixate(copy); + format_parse_param(copy, &ss, &map); + free(copy); + break; + } case SPA_PARAM_Format: format_parse_param(p->param, &ss, &map); break; @@ -3172,6 +3212,10 @@ static int fill_source_output_info(struct client *client, struct message *m, break; } } + if (ss.channels != map.channels) + ss.channels = map.channels; + if (volume_info.volume.channels != map.channels) + volume_info.volume.channels = map.channels; peer = find_linked(client, o->id, PW_DIRECTION_INPUT); if (peer && is_source_or_monitor(peer)) {