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
a43b0f52
Commit
a43b0f52
authored
Jul 01, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mixer/software: move Filter management to the AudioOutput
parent
d93271e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
41 deletions
+43
-41
SoftwareMixerPlugin.cxx
src/mixer/plugins/SoftwareMixerPlugin.cxx
+16
-36
SoftwareMixerPlugin.hxx
src/mixer/plugins/SoftwareMixerPlugin.hxx
+6
-4
Init.cxx
src/output/Init.cxx
+15
-1
Internal.hxx
src/output/Internal.hxx
+6
-0
No files found.
src/mixer/plugins/SoftwareMixerPlugin.cxx
View file @
a43b0f52
...
...
@@ -31,23 +31,8 @@
#include <assert.h>
#include <math.h>
static
Filter
*
CreateVolumeFilter
()
{
return
filter_new
(
&
volume_filter_plugin
,
ConfigBlock
(),
IgnoreError
());
}
class
SoftwareMixer
final
:
public
Mixer
{
Filter
*
filter
;
/**
* If this is true, then this object "owns" the #Filter
* instance (see above). It will be set to false by
* software_mixer_get_filter(); after that, the caller will be
* responsible for the #Filter.
*/
bool
owns_filter
=
true
;
Filter
*
filter
=
nullptr
;
/**
* The current volume in percent (0..100).
...
...
@@ -56,18 +41,11 @@ class SoftwareMixer final : public Mixer {
public
:
SoftwareMixer
(
MixerListener
&
_listener
)
:
Mixer
(
software_mixer_plugin
,
_listener
),
filter
(
CreateVolumeFilter
())
:
Mixer
(
software_mixer_plugin
,
_listener
)
{
assert
(
filter
!=
nullptr
);
}
virtual
~
SoftwareMixer
()
{
if
(
owns_filter
)
delete
filter
;
}
Filter
*
GetFilter
(
);
void
SetFilter
(
Filter
*
_filter
);
/* virtual methods from class Mixer */
virtual
bool
Open
(
gcc_unused
Error
&
error
)
override
{
...
...
@@ -115,7 +93,9 @@ SoftwareMixer::SetVolume(unsigned new_volume, gcc_unused Error &error)
assert
(
new_volume
<=
100
);
volume
=
new_volume
;
volume_filter_set
(
filter
,
PercentVolumeToSoftwareVolume
(
new_volume
));
if
(
filter
!=
nullptr
)
volume_filter_set
(
filter
,
PercentVolumeToSoftwareVolume
(
new_volume
));
return
true
;
}
...
...
@@ -124,19 +104,19 @@ const MixerPlugin software_mixer_plugin = {
true
,
};
inline
Filter
*
SoftwareMixer
::
GetFilter
(
)
inline
void
SoftwareMixer
::
SetFilter
(
Filter
*
_filter
)
{
assert
(
owns_filter
)
;
filter
=
_filter
;
owns_filter
=
false
;
return
filter
;
if
(
filter
!=
nullptr
)
volume_filter_set
(
filter
,
PercentVolumeToSoftwareVolume
(
volume
));
}
Filter
*
software_mixer_
get_filter
(
Mixer
*
mix
er
)
void
software_mixer_
set_filter
(
Mixer
&
mixer
,
Filter
*
filt
er
)
{
SoftwareMixer
*
sm
=
(
SoftwareMixer
*
)
mixer
;
assert
(
sm
->
IsPlugin
(
software_mixer_plugin
));
return
sm
->
GetFilter
();
SoftwareMixer
&
sm
=
(
SoftwareMixer
&
)
mixer
;
sm
.
SetFilter
(
filter
);
}
src/mixer/plugins/SoftwareMixerPlugin.hxx
View file @
a43b0f52
...
...
@@ -24,10 +24,12 @@ class Mixer;
class
Filter
;
/**
* Returns the (volume) filter associated with this mixer. All users
* of this mixer plugin should install this filter.
* Attach a #VolumeFilter to this mixer. The #VolumeFilter is the
* entity which actually applies the volume; it is created and managed
* by the output. Mixer::SetVolume() calls will be forwarded to
* volume_filter_set().
*/
Filter
*
software_mixer_
get_filter
(
Mixer
*
mix
er
);
void
software_mixer_
set_filter
(
Mixer
&
mixer
,
Filter
*
filt
er
);
#endif
src/output/Init.cxx
View file @
a43b0f52
...
...
@@ -102,6 +102,13 @@ audio_output_mixer_type(const ConfigBlock &block)
"hardware"
));
}
static
Filter
*
CreateVolumeFilter
()
{
return
filter_new
(
&
volume_filter_plugin
,
ConfigBlock
(),
IgnoreError
());
}
static
Mixer
*
audio_output_load_mixer
(
EventLoop
&
event_loop
,
AudioOutput
&
ao
,
const
ConfigBlock
&
block
,
...
...
@@ -110,6 +117,8 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
MixerListener
&
listener
,
Error
&
error
)
{
assert
(
ao
.
volume_filter
==
nullptr
);
Mixer
*
mixer
;
switch
(
audio_output_mixer_type
(
block
))
{
...
...
@@ -135,8 +144,13 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
IgnoreError
());
assert
(
mixer
!=
nullptr
);
ao
.
volume_filter
=
CreateVolumeFilter
();
assert
(
ao
.
volume_filter
!=
nullptr
);
filter_chain_append
(
filter_chain
,
"software_mixer"
,
software_mixer_get_filter
(
mixer
));
ao
.
volume_filter
);
software_mixer_set_filter
(
*
mixer
,
ao
.
volume_filter
);
return
mixer
;
}
...
...
src/output/Internal.hxx
View file @
a43b0f52
...
...
@@ -190,6 +190,12 @@ struct AudioOutput {
Filter
*
filter
=
nullptr
;
/**
* The #VolumeFilter instance of this audio output. It is
* used by the #SoftwareMixer.
*/
Filter
*
volume_filter
=
nullptr
;
/**
* The replay_gain_filter_plugin instance of this audio
* output.
*/
...
...
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