Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
700f5567
Commit
700f5567
authored
5 years ago
by
George Kiagiadakis
Committed by
Julian Bouzas
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
simple-policy: match the requested role to a stream in find_endpoint
... and simplify some code there
parent
2a397faa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/module-simple-policy.c
+27
-26
27 additions, 26 deletions
modules/module-simple-policy.c
with
27 additions
and
26 deletions
modules/module-simple-policy.c
+
27
−
26
View file @
700f5567
...
...
@@ -316,44 +316,45 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
if
(
!
ptr_array
)
return
NULL
;
/* TODO: for now we statically return the first stream
* we should be looking into the media.role eventually */
g_variant_lookup
(
props
,
"media.role"
,
"&s"
,
&
role
);
if
(
!
g_strcmp0
(
action
,
"mixer"
)
&&
!
g_strcmp0
(
role
,
"Master"
))
*
stream_id
=
WP_STREAM_ID_NONE
;
else
*
stream_id
=
0
;
/* Find and return the "selected" endpoint */
/* FIXME: fix the endpoint API, this is terrible */
for
(
i
=
0
;
i
<
ptr_array
->
len
;
i
++
)
{
ep
=
g_ptr_array_index
(
ptr_array
,
i
);
GVariantIter
iter
;
g_autoptr
(
GVariant
)
controls
=
NULL
;
g_autoptr
(
GVariant
)
value
=
NULL
;
const
gchar
*
name
;
guint
id
;
controls
=
wp_endpoint_list_controls
(
ep
);
g_variant_iter_init
(
&
iter
,
controls
);
while
((
value
=
g_variant_iter_next_value
(
&
iter
)))
{
if
(
!
g_variant_lookup
(
value
,
"name"
,
"&s"
,
&
name
)
||
!
g_str_equal
(
name
,
"selected"
))
{
g_variant_unref
(
value
);
continue
;
}
g_variant_lookup
(
value
,
"id"
,
"u"
,
&
id
);
g_variant_unref
(
value
);
}
id
=
wp_endpoint_find_control
(
ep
,
WP_STREAM_ID_NONE
,
"selected"
);
if
(
id
==
WP_CONTROL_ID_NONE
)
continue
;
value
=
wp_endpoint_get_control_value
(
ep
,
id
);
if
(
value
&&
g_variant_get_boolean
(
value
))
return
g_object_ref
(
ep
);
if
(
value
&&
g_variant_get_boolean
(
value
))
{
g_object_ref
(
ep
);
goto
select_stream
;
}
}
/* If not found, return the first endpoint */
return
(
ptr_array
->
len
>
1
)
?
ep
=
(
ptr_array
->
len
>
1
)
?
g_object_ref
(
g_ptr_array_index
(
ptr_array
,
0
))
:
NULL
;
select_stream:
g_variant_lookup
(
props
,
"media.role"
,
"&s"
,
&
role
);
if
(
!
g_strcmp0
(
action
,
"mixer"
)
&&
!
g_strcmp0
(
role
,
"Master"
))
*
stream_id
=
WP_STREAM_ID_NONE
;
else
if
(
ep
)
{
/* the default role is "Multimedia" */
if
(
!
role
)
role
=
"Multimedia"
;
*
stream_id
=
wp_endpoint_find_stream
(
ep
,
role
);
/* role not found, try the first stream */
if
(
*
stream_id
==
WP_STREAM_ID_NONE
)
{
g_warning
(
"role '%s' not found in endpoint"
,
role
);
*
stream_id
=
0
;
}
}
return
ep
;
}
static
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment