summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2020-08-17 11:15:44 +0200
committerWim Taymans <wtaymans@redhat.com>2020-08-17 11:15:44 +0200
commit31a3fab554eb653857d7bf7966d7c0a66b5a5310 (patch)
tree9eecd6f020a0560fb3fac154438eda046c3fdeb6
parent05416b497c734eb00f62d4f4949d7fccfaf4b935 (diff)
media-session: use name from Profile param
-rw-r--r--src/examples/media-session/default-profile.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/examples/media-session/default-profile.c b/src/examples/media-session/default-profile.c
index ebdb45f5..13ba0cba 100644
--- a/src/examples/media-session/default-profile.c
+++ b/src/examples/media-session/default-profile.c
@@ -124,26 +124,6 @@ static void session_destroy(void *data)
free(impl);
}
-static const char *find_profile_name(struct device *dev, uint32_t index)
-{
- struct sm_param *p;
- spa_list_for_each(p, &dev->obj->param_list, link) {
- const char *n;
- uint32_t id;
-
- if (p->id != SPA_PARAM_EnumProfile ||
- spa_pod_parse_object(p->param,
- SPA_TYPE_OBJECT_ParamProfile, NULL,
- SPA_PARAM_PROFILE_index, SPA_POD_Int(&id),
- SPA_PARAM_PROFILE_name, SPA_POD_String(&n)) < 0) {
- continue;
- }
- if (id == index)
- return n;
- }
- return NULL;
-}
-
static uint32_t find_profile_id(struct device *dev, const char *name)
{
struct sm_param *p;
@@ -205,7 +185,8 @@ static int handle_profile(struct device *dev, struct sm_param *p)
const char *name;
if ((res = spa_pod_parse_object(p->param,
SPA_TYPE_OBJECT_ParamProfile, NULL,
- SPA_PARAM_PROFILE_index, SPA_POD_Int(&index))) < 0) {
+ SPA_PARAM_PROFILE_index, SPA_POD_Int(&index),
+ SPA_PARAM_PROFILE_name, SPA_POD_String(&name))) < 0) {
pw_log_warn("device %d: can't parse profile: %s", dev->id, spa_strerror(res));
return res;
}
@@ -213,12 +194,9 @@ static int handle_profile(struct device *dev, struct sm_param *p)
return 0;
dev->active_profile = index;
- name = find_profile_name(dev, index);
- if (name) {
- pw_log_debug("device %d: current profile %d %s", dev->id, index, name);
- pw_properties_set(impl->properties, dev->name, name);
- add_idle_timeout(impl);
- }
+ pw_log_debug("device %d: current profile %d %s", dev->id, index, name);
+ pw_properties_set(impl->properties, dev->name, name);
+ add_idle_timeout(impl);
}
return 0;
}