diff options
author | Wim Taymans <wtaymans@redhat.com> | 2020-07-06 12:51:38 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2020-07-06 12:51:38 +0200 |
commit | 0bbc25e3e223d7e7f514c8a16f67c65bbebcbbe2 (patch) | |
tree | 855fcd9842cdb38b3f650588d9bead912b36b1c7 | |
parent | 1612f5e4d215bd5edf7d649d220b53ff1ed7c098 (diff) |
media-session: add option to enable acp device
-rw-r--r-- | src/examples/media-session/alsa-monitor.c | 20 | ||||
-rw-r--r-- | src/examples/media-session/media-session.c | 29 |
2 files changed, 36 insertions, 13 deletions
diff --git a/src/examples/media-session/alsa-monitor.c b/src/examples/media-session/alsa-monitor.c index aaac6648..41a77774 100644 --- a/src/examples/media-session/alsa-monitor.c +++ b/src/examples/media-session/alsa-monitor.c @@ -115,6 +115,8 @@ struct impl { struct spa_source *jack_timeout; struct pw_proxy *jack_device; + + unsigned int use_acp:1; }; #undef NAME @@ -455,9 +457,13 @@ static int update_device_props(struct device *device) static void set_profile(struct device *device, int index) { + struct impl *impl = device->impl; char buf[1024]; struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf)); + if (impl->use_acp) + return; + pw_log_debug("%p: set profile %d id:%d", device, index, device->device_id); if (device->device_id != 0) { @@ -670,7 +676,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id, struct spa_handle *handle; int res; void *iface; - const char *card; + const char *card, *factory_name; pw_log_debug("new device %u", id); @@ -679,9 +685,13 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id, return NULL; } + if (impl->use_acp) + factory_name = SPA_NAME_API_ALSA_ACP_DEVICE; + else + factory_name = info->factory_name; + handle = pw_context_load_spa_handle(context, - info->factory_name, - info->props); + factory_name, info->props); if (handle == NULL) { res = -errno; pw_log_error("can't make factory instance: %m"); @@ -834,6 +844,7 @@ int sm_alsa_monitor_start(struct sm_media_session *session) struct pw_context *context = session->context; struct impl *impl; void *iface; + const char *str; int res; impl = calloc(1, sizeof(struct impl)); @@ -842,6 +853,9 @@ int sm_alsa_monitor_start(struct sm_media_session *session) impl->session = session; + if ((str = pw_properties_get(session->props, "alsa.use-acp")) != NULL) + impl->use_acp = pw_properties_parse_bool(str); + if (session->dbus_connection) impl->conn = spa_dbus_connection_get(session->dbus_connection); if (impl->conn == NULL) diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 6926169d..dffec7ce 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -1735,16 +1735,18 @@ static const struct { const char *name; const char *desc; int (*start)(struct sm_media_session *sess); + const char *props; } modules[] = { - { "alsa-seq", "alsa seq midi support", sm_alsa_midi_start }, - { "alsa-pcm", "alsa pcm udev detection", sm_alsa_monitor_start }, - { "v4l2", "video for linux udev detection", sm_v4l2_monitor_start }, - { "libcamera", "libcamera udev detection", sm_libcamera_monitor_start }, - { "bluez5", "bluetooth support", sm_bluez5_monitor_start }, - { "metadata", "export metadata API", sm_metadata_start }, - { "suspend-node", "suspend inactive nodes", sm_suspend_node_start }, - { "policy-node", "configure and link nodes", sm_policy_node_start }, + { "alsa-seq", "alsa seq midi support", sm_alsa_midi_start, NULL }, + { "alsa-pcm", "alsa pcm udev detection", sm_alsa_monitor_start, NULL }, + { "alsa-acp", "alsa card profile udev detection", sm_alsa_monitor_start, "alsa.use-acp=true" }, + { "v4l2", "video for linux udev detection", sm_v4l2_monitor_start, NULL }, + { "libcamera", "libcamera udev detection", sm_libcamera_monitor_start, NULL }, + { "bluez5", "bluetooth support", sm_bluez5_monitor_start, NULL }, + { "metadata", "export metadata API", sm_metadata_start, NULL }, + { "suspend-node", "suspend inactive nodes", sm_suspend_node_start, NULL }, + { "policy-node", "configure and link nodes", sm_policy_node_start, NULL }, }; static int opt_contains(const char *opt, const char *val) @@ -1833,9 +1835,8 @@ int main(int argc, char *argv[]) if (impl.this.props == NULL) return -1; - spa_dict_for_each(item, &impl.this.props->dict) { + spa_dict_for_each(item, &impl.this.props->dict) pw_log_info(" '%s' = '%s'", item->key, item->value); - } impl.loop = pw_main_loop_new(NULL); if (impl.loop == NULL) @@ -1882,6 +1883,14 @@ int main(int argc, char *argv[]) const char *name = modules[i].name; if (opt_contains(opt_enabled, name) && !opt_contains(opt_disabled, name)) { + if (modules[i].props) { + struct pw_properties *props; + props = pw_properties_new_string(modules[i].props); + if (props) { + pw_properties_update(impl.this.props, &props->dict); + pw_properties_free(props); + } + } pw_log_info("enable: %s", name); modules[i].start(&impl.this); } |