Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
073e9d06
Commit
073e9d06
authored
May 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer/software: keep attribute "volume" in the 0..100 range
The attribute must be 0..100 and not 0..1024. Previously, the code was inconsistent.
parent
fd1b0493
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
SoftwareMixerPlugin.cxx
src/mixer/plugins/SoftwareMixerPlugin.cxx
+19
-7
No files found.
src/mixer/plugins/SoftwareMixerPlugin.cxx
View file @
073e9d06
...
@@ -49,6 +49,9 @@ class SoftwareMixer final : public Mixer {
...
@@ -49,6 +49,9 @@ class SoftwareMixer final : public Mixer {
*/
*/
bool
owns_filter
;
bool
owns_filter
;
/**
* The current volume in percent (0..100).
*/
unsigned
volume
;
unsigned
volume
;
public
:
public
:
...
@@ -93,19 +96,28 @@ software_mixer_init(gcc_unused EventLoop &event_loop,
...
@@ -93,19 +96,28 @@ software_mixer_init(gcc_unused EventLoop &event_loop,
return
new
SoftwareMixer
(
listener
);
return
new
SoftwareMixer
(
listener
);
}
}
gcc_const
static
unsigned
PercentVolumeToSoftwareVolume
(
unsigned
volume
)
{
assert
(
volume
<=
100
);
if
(
volume
>=
100
)
return
PCM_VOLUME_1
;
else
if
(
volume
>
0
)
return
pcm_float_to_volume
((
exp
(
volume
/
25.0
)
-
1
)
/
(
54.5981500331
F
-
1
));
else
return
0
;
}
bool
bool
SoftwareMixer
::
SetVolume
(
unsigned
new_volume
,
gcc_unused
Error
&
error
)
SoftwareMixer
::
SetVolume
(
unsigned
new_volume
,
gcc_unused
Error
&
error
)
{
{
assert
(
new_volume
<=
100
);
assert
(
new_volume
<=
100
);
if
(
new_volume
>=
100
)
new_volume
=
PCM_VOLUME_1
;
else
if
(
new_volume
>
0
)
new_volume
=
pcm_float_to_volume
((
exp
(
new_volume
/
25.0
)
-
1
)
/
(
54.5981500331
F
-
1
));
volume
=
new_volume
;
volume
=
new_volume
;
volume_filter_set
(
filter
,
new_volume
);
volume_filter_set
(
filter
,
PercentVolumeToSoftwareVolume
(
new_volume
)
);
return
true
;
return
true
;
}
}
...
...
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