Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marijn Suijten
pulseaudio
Commits
89b5ce87
Commit
89b5ce87
authored
Jun 07, 2020
by
Marijn Suijten
🦀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bluetooth: Round volume to closest instead of up
parent
4fe06ac0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
20 deletions
+11
-20
src/modules/bluetooth/module-bluez5-device.c
src/modules/bluetooth/module-bluez5-device.c
+11
-20
No files found.
src/modules/bluetooth/module-bluez5-device.c
View file @
89b5ce87
...
...
@@ -988,16 +988,12 @@ static void source_set_volume_cb(pa_source *s) {
pa_assert
(
u
);
pa_assert
(
u
->
source
==
s
);
gain
=
(
pa_cvolume_max
(
&
s
->
real_volume
)
*
u
->
transport
->
max_rx_volume_gain
)
/
PA_VOLUME_NORM
;
gain
=
(
pa_cvolume_max
(
&
s
->
real_volume
)
*
u
->
transport
->
max_rx_volume_gain
+
PA_VOLUME_NORM
/
2
)
/
PA_VOLUME_NORM
;
if
(
gain
>
u
->
transport
->
max_rx_volume_gain
)
gain
=
u
->
transport
->
max_rx_volume_gain
;
volume
=
(
pa_volume_t
)
(
gain
*
PA_VOLUME_NORM
/
u
->
transport
->
max_rx_volume_gain
);
/* increment volume by one to correct rounding errors */
if
(
volume
<
PA_VOLUME_NORM
)
volume
++
;
volume
=
(
pa_volume_t
)
((
gain
*
PA_VOLUME_NORM
+
u
->
transport
->
max_rx_volume_gain
/
2
)
/
u
->
transport
->
max_rx_volume_gain
);
pa_cvolume_set
(
&
s
->
real_volume
,
u
->
decoder_sample_spec
.
channels
,
volume
);
...
...
@@ -1155,16 +1151,12 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_assert
(
u
);
pa_assert
(
u
->
sink
==
s
);
gain
=
(
pa_cvolume_max
(
&
s
->
real_volume
)
*
u
->
transport
->
max_tx_volume_gain
)
/
PA_VOLUME_NORM
;
gain
=
(
pa_cvolume_max
(
&
s
->
real_volume
)
*
u
->
transport
->
max_tx_volume_gain
+
PA_VOLUME_NORM
/
2
)
/
PA_VOLUME_NORM
;
if
(
gain
>
u
->
transport
->
max_tx_volume_gain
)
gain
=
u
->
transport
->
max_tx_volume_gain
;
volume
=
(
pa_volume_t
)
(
gain
*
PA_VOLUME_NORM
/
u
->
transport
->
max_tx_volume_gain
);
/* increment volume by one to correct rounding errors */
if
(
volume
<
PA_VOLUME_NORM
)
volume
++
;
volume
=
(
pa_volume_t
)
((
gain
*
PA_VOLUME_NORM
+
u
->
transport
->
max_tx_volume_gain
/
2
)
/
u
->
transport
->
max_tx_volume_gain
);
pa_cvolume_set
(
&
s
->
real_volume
,
u
->
encoder_sample_spec
.
channels
,
volume
);
...
...
@@ -2433,11 +2425,10 @@ static pa_hook_result_t transport_tx_volume_gain_changed_cb(pa_bluetooth_discove
return
PA_HOOK_OK
;
gain
=
t
->
tx_volume_gain
;
volume
=
(
pa_volume_t
)
(
gain
*
PA_VOLUME_NORM
/
t
->
max_tx_volume_gain
);
volume
=
(
pa_volume_t
)
(
(
gain
*
PA_VOLUME_NORM
+
t
->
max_tx_volume_gain
/
2
)
/
t
->
max_tx_volume_gain
);
/* increment volume by one to correct rounding errors */
if
(
volume
<
PA_VOLUME_NORM
)
volume
++
;
if
(
volume
>
PA_VOLUME_NORM
)
volume
=
PA_VOLUME_NORM
;
pa_cvolume_set
(
&
v
,
u
->
encoder_sample_spec
.
channels
,
volume
);
...
...
@@ -2461,11 +2452,11 @@ static pa_hook_result_t transport_rx_volume_gain_changed_cb(pa_bluetooth_discove
return
PA_HOOK_OK
;
gain
=
t
->
rx_volume_gain
;
volume
=
(
pa_volume_t
)
(
gain
*
PA_VOLUME_NORM
/
t
->
max_rx_volume_gain
);
/* increment volume by one to correct rounding errors */
if
(
volume
<
PA_VOLUME_NORM
)
volume
++
;
volume
=
(
pa_volume_t
)((
gain
*
PA_VOLUME_NORM
+
t
->
max_rx_volume_gain
/
2
)
/
t
->
max_rx_volume_gain
);
if
(
volume
>
PA_VOLUME_NORM
)
volume
=
PA_VOLUME_NORM
;
pa_cvolume_set
(
&
v
,
u
->
decoder_sample_spec
.
channels
,
volume
);
...
...
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