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
7d4c9fa6
Commit
7d4c9fa6
authored
5 years ago
by
Julian Bouzas
Browse files
Options
Downloads
Patches
Plain Diff
simple-policy: select the client's target name endpoint
parent
d49ed2b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/module-simple-policy.c
+30
-14
30 additions, 14 deletions
modules/module-simple-policy.c
with
30 additions
and
14 deletions
modules/module-simple-policy.c
+
30
−
14
View file @
7d4c9fa6
...
...
@@ -273,7 +273,7 @@ handle_client (WpPolicy *policy, WpEndpoint *ep)
g_autoptr
(
WpEndpoint
)
target
=
NULL
;
guint32
stream_id
;
gboolean
is_capture
=
FALSE
;
g_autofree
gchar
*
role
=
NULL
;
g_autofree
gchar
*
role
,
*
target_name
=
NULL
;
/* Detect if the client is doing capture or playback */
is_capture
=
g_str_has_prefix
(
media_class
,
"Stream/Input"
);
...
...
@@ -288,12 +288,18 @@ handle_client (WpPolicy *policy, WpEndpoint *ep)
if
(
role
)
g_variant_dict_insert
(
&
d
,
"media.role"
,
"s"
,
role
);
g_object_get
(
ep
,
"target"
,
&
target_name
,
NULL
);
if
(
target_name
)
g_variant_dict_insert
(
&
d
,
"media.name"
,
"s"
,
target_name
);
/* TODO: more properties are needed here */
core
=
wp_policy_get_core
(
policy
);
target
=
wp_policy_find_endpoint
(
core
,
g_variant_dict_end
(
&
d
),
&
stream_id
);
if
(
!
target
)
if
(
!
target
)
{
g_warning
(
"Could not find target endpoint"
);
return
;
}
/* if the client is already linked... */
if
(
wp_endpoint_is_linked
(
ep
))
{
...
...
@@ -454,6 +460,7 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
g_autoptr
(
WpCore
)
core
=
NULL
;
g_autoptr
(
GPtrArray
)
ptr_array
=
NULL
;
const
char
*
action
=
NULL
;
const
char
*
name
=
NULL
;
const
char
*
media_class
=
NULL
;
const
char
*
role
=
NULL
;
WpEndpoint
*
ep
;
...
...
@@ -462,6 +469,7 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
core
=
wp_policy_get_core
(
policy
);
g_variant_lookup
(
props
,
"action"
,
"&s"
,
&
action
);
g_variant_lookup
(
props
,
"media.name"
,
"&s"
,
&
name
);
/* Get all the endpoints with the specific media class*/
g_variant_lookup
(
props
,
"media.class"
,
"&s"
,
&
media_class
);
...
...
@@ -469,20 +477,28 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
if
(
!
ptr_array
)
return
NULL
;
/* Find and return the "selected" endpoint */
/* Find the endpoint with the matching name, otherwise get the one with the
* "selected" flag */
for
(
i
=
0
;
i
<
ptr_array
->
len
;
i
++
)
{
ep
=
g_ptr_array_index
(
ptr_array
,
i
);
g_autoptr
(
GVariant
)
value
=
NULL
;
guint
id
;
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
))
{
g_object_ref
(
ep
);
goto
select_stream
;
if
(
name
)
{
if
(
g_str_has_prefix
(
wp_endpoint_get_name
(
ep
),
name
))
{
g_object_ref
(
ep
);
goto
select_stream
;
}
}
else
{
g_autoptr
(
GVariant
)
value
=
NULL
;
guint
id
;
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
))
{
g_object_ref
(
ep
);
goto
select_stream
;
}
}
}
...
...
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