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
7c7c65de
Commit
7c7c65de
authored
5 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
simple-policy: allow configuring the default audio devices via module arguments
parent
1e7bcd89
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
+25
-6
25 additions, 6 deletions
modules/module-simple-policy.c
with
25 additions
and
6 deletions
modules/module-simple-policy.c
+
25
−
6
View file @
7c7c65de
...
@@ -18,6 +18,8 @@ struct _WpSimplePolicy
...
@@ -18,6 +18,8 @@ struct _WpSimplePolicy
WpPolicy
parent
;
WpPolicy
parent
;
WpEndpoint
*
selected
[
2
];
WpEndpoint
*
selected
[
2
];
guint32
selected_ctl_id
[
2
];
guint32
selected_ctl_id
[
2
];
gchar
*
default_playback
;
gchar
*
default_capture
;
};
};
G_DECLARE_FINAL_TYPE
(
WpSimplePolicy
,
simple_policy
,
WP
,
SIMPLE_POLICY
,
WpPolicy
)
G_DECLARE_FINAL_TYPE
(
WpSimplePolicy
,
simple_policy
,
WP
,
SIMPLE_POLICY
,
WpPolicy
)
...
@@ -28,6 +30,17 @@ simple_policy_init (WpSimplePolicy *self)
...
@@ -28,6 +30,17 @@ simple_policy_init (WpSimplePolicy *self)
{
{
}
}
static
void
simple_policy_finalize
(
GObject
*
object
)
{
WpSimplePolicy
*
self
=
WP_SIMPLE_POLICY
(
object
);
g_free
(
self
->
default_playback
);
g_free
(
self
->
default_capture
);
G_OBJECT_CLASS
(
simple_policy_parent_class
)
->
finalize
(
object
);
}
static
void
static
void
endpoint_notify_control_value
(
WpEndpoint
*
ep
,
guint
control_id
,
endpoint_notify_control_value
(
WpEndpoint
*
ep
,
guint
control_id
,
WpSimplePolicy
*
self
)
WpSimplePolicy
*
self
)
...
@@ -82,7 +95,7 @@ static void
...
@@ -82,7 +95,7 @@ static void
select_endpoint
(
WpSimplePolicy
*
self
,
gint
direction
,
WpEndpoint
*
ep
,
select_endpoint
(
WpSimplePolicy
*
self
,
gint
direction
,
WpEndpoint
*
ep
,
guint32
control_id
)
guint32
control_id
)
{
{
g_
debug
(
"selecting %s %p (%s)"
,
g_
info
(
"selecting %s %p (%s)"
,
(
direction
==
DIRECTION_SINK
)
?
"sink"
:
"source"
,
(
direction
==
DIRECTION_SINK
)
?
"sink"
:
"source"
,
ep
,
wp_endpoint_get_name
(
ep
));
ep
,
wp_endpoint_get_name
(
ep
));
...
@@ -167,12 +180,13 @@ simple_policy_endpoint_added (WpPolicy *policy, WpEndpoint *ep)
...
@@ -167,12 +180,13 @@ simple_policy_endpoint_added (WpPolicy *policy, WpEndpoint *ep)
}
else
{
}
else
{
/* we already have a selected endpoint, but maybe this one is better... */
/* we already have a selected endpoint, but maybe this one is better... */
const
gchar
*
new_name
=
wp_endpoint_get_name
(
ep
);
const
gchar
*
new_name
=
wp_endpoint_get_name
(
ep
);
const
gchar
*
old_name
=
wp_endpoint_get_name
(
self
->
selected
[
direction
]);
const
gchar
*
default_dev
=
(
direction
==
DIRECTION_SINK
)
?
self
->
default_playback
:
self
->
default_capture
;
/* FIXME: this is a crude way of searching for properties;
/* FIXME: this is a crude way of searching for properties;
* we should have an API here */
* we should have an API here */
if
((
strstr
(
new_name
,
"hw:0,0"
)
&&
!
strstr
(
new_name
,
"Loopback"
))
||
if
((
default_dev
&&
strstr
(
new_name
,
default_dev
))
||
(
strstr
(
old_name
,
"Loopback"
)
&&
strstr
(
new_name
,
"hw:
1
,0"
)))
(
!
default_dev
&&
strstr
(
new_name
,
"hw:
0
,0"
)))
{
{
wp_endpoint_set_control_value
(
self
->
selected
[
direction
],
wp_endpoint_set_control_value
(
self
->
selected
[
direction
],
self
->
selected_ctl_id
[
direction
],
self
->
selected_ctl_id
[
direction
],
...
@@ -316,8 +330,11 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
...
@@ -316,8 +330,11 @@ simple_policy_find_endpoint (WpPolicy *policy, GVariant *props,
static
void
static
void
simple_policy_class_init
(
WpSimplePolicyClass
*
klass
)
simple_policy_class_init
(
WpSimplePolicyClass
*
klass
)
{
{
GObjectClass
*
object_class
=
(
GObjectClass
*
)
klass
;
WpPolicyClass
*
policy_class
=
(
WpPolicyClass
*
)
klass
;
WpPolicyClass
*
policy_class
=
(
WpPolicyClass
*
)
klass
;
object_class
->
finalize
=
simple_policy_finalize
;
policy_class
->
endpoint_added
=
simple_policy_endpoint_added
;
policy_class
->
endpoint_added
=
simple_policy_endpoint_added
;
policy_class
->
endpoint_removed
=
simple_policy_endpoint_removed
;
policy_class
->
endpoint_removed
=
simple_policy_endpoint_removed
;
policy_class
->
handle_endpoint
=
simple_policy_handle_endpoint
;
policy_class
->
handle_endpoint
=
simple_policy_handle_endpoint
;
...
@@ -327,8 +344,10 @@ simple_policy_class_init (WpSimplePolicyClass *klass)
...
@@ -327,8 +344,10 @@ simple_policy_class_init (WpSimplePolicyClass *klass)
void
void
wireplumber__module_init
(
WpModule
*
module
,
WpCore
*
core
,
GVariant
*
args
)
wireplumber__module_init
(
WpModule
*
module
,
WpCore
*
core
,
GVariant
*
args
)
{
{
WpPolicy
*
p
=
g_object_new
(
simple_policy_get_type
(),
Wp
Simple
Policy
*
p
=
g_object_new
(
simple_policy_get_type
(),
"rank"
,
WP_POLICY_RANK_UPSTREAM
,
"rank"
,
WP_POLICY_RANK_UPSTREAM
,
NULL
);
NULL
);
wp_policy_register
(
p
,
core
);
g_variant_lookup
(
args
,
"default-playback-device"
,
"s"
,
&
p
->
default_playback
);
g_variant_lookup
(
args
,
"default-capture-device"
,
"s"
,
&
p
->
default_capture
);
wp_policy_register
(
WP_POLICY
(
p
),
core
);
}
}
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