Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marijn Suijten
pulseaudio
Commits
63402d1c
Commit
63402d1c
authored
Jan 24, 2021
by
Marijn Suijten
🦀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIXUP: "delay absolute volume setup": unconditionally set for source
See code comments why
parent
ae78e131
Pipeline
#275495
passed with stages
in 5 minutes and 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
39 deletions
+34
-39
src/modules/bluetooth/bluez5-util.c
src/modules/bluetooth/bluez5-util.c
+5
-2
src/modules/bluetooth/bluez5-util.h
src/modules/bluetooth/bluez5-util.h
+1
-1
src/modules/bluetooth/module-bluez5-device.c
src/modules/bluetooth/module-bluez5-device.c
+28
-36
No files found.
src/modules/bluetooth/bluez5-util.c
View file @
63402d1c
...
...
@@ -741,12 +741,15 @@ static void bluez5_transport_request_volume(pa_bluetooth_transport *t) {
send_and_add_to_pending
(
t
->
device
->
discovery
,
m
,
request_volume_reply
,
t
);
}
void
pa_bluetooth_transport_
setup
_a2dp_
absolute
_volume
(
pa_bluetooth_transport
*
t
)
{
void
pa_bluetooth_transport_
load
_a2dp_
sink
_volume
(
pa_bluetooth_transport
*
t
)
{
pa_assert
(
t
);
if
(
t
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SINK
||
t
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SOURCE
)
if
(
t
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SINK
)
/* A2DP Absolute Volume control (AVRCP 1.4) is optional */
bluez5_transport_request_volume
(
t
);
else
pa_assert_not_reached
();
}
bool
pa_bluetooth_device_any_transport_connected
(
const
pa_bluetooth_device
*
d
)
{
...
...
src/modules/bluetooth/bluez5-util.h
View file @
63402d1c
...
...
@@ -196,7 +196,7 @@ void pa_bluetooth_transport_set_state(pa_bluetooth_transport *t, pa_bluetooth_tr
void
pa_bluetooth_transport_put
(
pa_bluetooth_transport
*
t
);
void
pa_bluetooth_transport_unlink
(
pa_bluetooth_transport
*
t
);
void
pa_bluetooth_transport_free
(
pa_bluetooth_transport
*
t
);
void
pa_bluetooth_transport_
setup
_a2dp_
absolute
_volume
(
pa_bluetooth_transport
*
t
);
void
pa_bluetooth_transport_
load
_a2dp_
sink
_volume
(
pa_bluetooth_transport
*
t
);
bool
pa_bluetooth_device_any_transport_connected
(
const
pa_bluetooth_device
*
d
);
bool
pa_bluetooth_device_switch_codec
(
pa_bluetooth_device
*
device
,
pa_bluetooth_profile_t
profile
,
pa_hashmap
*
capabilities_hashmap
,
const
pa_a2dp_codec
*
a2dp_codec
,
void
(
*
codec_switch_cb
)(
bool
,
pa_bluetooth_profile_t
profile
,
void
*
),
void
*
userdata
);
...
...
src/modules/bluetooth/module-bluez5-device.c
View file @
63402d1c
...
...
@@ -1085,6 +1085,18 @@ static int add_source(struct userdata *u) {
||
u
->
profile
==
PA_BLUETOOTH_PROFILE_HFP_HF
)
{
pa_source_set_set_volume_callback
(
u
->
source
,
source_set_volume_cb
);
u
->
source
->
n_volume_steps
=
16
;
}
else
if
(
u
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SOURCE
)
{
pa_assert
(
u
->
transport
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SOURCE
);
/* Absolute Volume is optional but BlueZ unconditionally reports
* feature category 2, meaning supporting it is mandatory.
* PulseAudio can and should perform the attenuation anyway in,
* the source role as it is the audio rendering device.
*/
// TODO: Send initial (restored) volume to the device, letting it know we are performing attenuation.
pa_source_set_set_volume_callback
(
u
->
source
,
source_set_volume_cb
);
pa_source_set_set_mute_callback
(
u
->
source
,
source_set_mute_cb
);
u
->
source
->
n_volume_steps
=
A2DP_MAX_GAIN
+
1
;
}
return
0
;
}
...
...
@@ -1423,8 +1435,6 @@ static int init_profile(struct userdata *u) {
PA_SINK_IS_LINKED
(
u
->
sink
->
state
),
u
->
sink
->
monitor_source
?
PA_SOURCE_IS_LINKED
(
u
->
sink
->
monitor_source
->
state
)
:
-
1
);
// pa_bluetooth_transport_setup_a2dp_absolute_volume(u->transport);
return
r
;
}
...
...
@@ -1759,6 +1769,22 @@ static int start_thread(struct userdata *u) {
if
(
u
->
a2dp_codec
)
pa_proplist_sets
(
u
->
card
->
proplist
,
PA_PROP_BLUETOOTH_CODEC
,
u
->
a2dp_codec
->
name
);
/* Now that everything is set up we are ready to check for the Volume property.
* Sometimes its initial "change" notification arrives too early when the sink
* is not available or still in UNLINKED state; check it again here to know if
* our sink peer supports Absolute Volume; in that case we should not perform
* any attenuation but delegate all set_volume calls to the peer through this
* Volume property.
*
* Note that this works the other way around if the peer is in source profile:
* we are rendering audio and hence responsible for applying attenuation. The
* set_volume callback is always registered, and Volume is always passed to
* BlueZ unconditionally. BlueZ only sends a notification to the peer if it
* registered a notification request for absolute volume previously.
*/
if
(
u
->
transport
&&
u
->
sink
)
pa_bluetooth_transport_load_a2dp_sink_volume
(
u
->
transport
);
return
0
;
}
...
...
@@ -2112,9 +2138,6 @@ static int set_profile_cb(pa_card *c, pa_card_profile *new_profile) {
if
(
start_thread
(
u
)
<
0
)
goto
off
;
if
(
u
->
transport
)
pa_bluetooth_transport_setup_a2dp_absolute_volume
(
u
->
transport
);
return
0
;
off:
...
...
@@ -2403,29 +2426,6 @@ static pa_hook_result_t transport_sink_volume_changed_cb(pa_bluetooth_discovery
return
PA_HOOK_OK
;
}
static
void
source_set_a2dp_remote_controlled
(
pa_source
*
s
)
{
struct
userdata
*
u
;
pa_assert
(
s
);
if
(
s
->
set_volume
==
source_set_volume_cb
)
return
;
pa_assert
(
s
->
core
);
u
=
s
->
userdata
;
pa_assert
(
u
);
pa_assert
(
u
->
source
==
s
);
pa_assert
(
u
->
transport
);
pa_assert
(
u
->
transport
->
profile
==
PA_BLUETOOTH_PROFILE_A2DP_SOURCE
);
pa_log_debug
(
"%s: Enabling volume notifications for A2DP peer"
,
s
->
name
);
pa_source_set_set_volume_callback
(
s
,
source_set_volume_cb
);
pa_source_set_set_mute_callback
(
s
,
source_set_mute_cb
);
s
->
n_volume_steps
=
A2DP_MAX_GAIN
+
1
;
}
static
pa_hook_result_t
transport_source_volume_changed_cb
(
pa_bluetooth_discovery
*
y
,
pa_bluetooth_transport
*
t
,
struct
userdata
*
u
)
{
pa_volume_t
volume
;
pa_cvolume
v
;
...
...
@@ -2446,8 +2446,6 @@ static pa_hook_result_t transport_source_volume_changed_cb(pa_bluetooth_discover
return
PA_HOOK_OK
;
}
source_set_a2dp_remote_controlled
(
u
->
source
);
// TODO: Apply to HSP too
if
(
volume
<=
A2DP_MUTE_VOLUME
)
{
pa_source_mute_changed
(
u
->
source
,
true
);
...
...
@@ -2497,9 +2495,6 @@ static void switch_codec_cb_handler(bool success, pa_bluetooth_profile_t profile
pa_log_info
(
"Codec successfully switched to %s with profile: %s"
,
u
->
a2dp_codec
->
name
,
pa_bluetooth_profile_to_string
(
u
->
profile
));
if
(
u
->
transport
)
pa_bluetooth_transport_setup_a2dp_absolute_volume
(
u
->
transport
);
return
;
off:
...
...
@@ -2806,9 +2801,6 @@ int pa__init(pa_module* m) {
PA_SINK_IS_LINKED
(
u
->
sink
->
state
),
u
->
sink
->
monitor_source
?
PA_SOURCE_IS_LINKED
(
u
->
sink
->
monitor_source
->
state
)
:
-
1
);
if
(
u
->
transport
)
pa_bluetooth_transport_setup_a2dp_absolute_volume
(
u
->
transport
);
message_handler_path
=
make_message_handler_path
(
u
->
card
->
name
);
pa_message_handler_register
(
m
->
core
,
message_handler_path
,
"Bluez5 device message handler"
,
bluez5_device_message_handler
,
(
void
*
)
u
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment