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
49dcac5c
Commit
49dcac5c
authored
Aug 26, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/TwoFilters: add class PreparedTwoFilters
parent
38a4b0d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
TwoFilters.cxx
src/filter/plugins/TwoFilters.cxx
+21
-0
TwoFilters.hxx
src/filter/plugins/TwoFilters.hxx
+19
-0
No files found.
src/filter/plugins/TwoFilters.cxx
View file @
49dcac5c
...
@@ -18,7 +18,10 @@
...
@@ -18,7 +18,10 @@
*/
*/
#include "TwoFilters.hxx"
#include "TwoFilters.hxx"
#include "pcm/AudioFormat.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/RuntimeError.hxx"
#include "util/StringBuffer.hxx"
ConstBuffer
<
void
>
ConstBuffer
<
void
>
TwoFilters
::
FilterPCM
(
ConstBuffer
<
void
>
src
)
TwoFilters
::
FilterPCM
(
ConstBuffer
<
void
>
src
)
...
@@ -37,3 +40,21 @@ TwoFilters::Flush()
...
@@ -37,3 +40,21 @@ TwoFilters::Flush()
return
second
->
Flush
();
return
second
->
Flush
();
}
}
std
::
unique_ptr
<
Filter
>
PreparedTwoFilters
::
Open
(
AudioFormat
&
audio_format
)
{
auto
a
=
first
->
Open
(
audio_format
);
const
auto
&
a_out_format
=
a
->
GetOutAudioFormat
();
auto
b_in_format
=
a_out_format
;
auto
b
=
second
->
Open
(
b_in_format
);
if
(
b_in_format
!=
a_out_format
)
throw
FormatRuntimeError
(
"Audio format not supported by filter '%s': %s"
,
second_name
.
c_str
(),
ToString
(
a_out_format
).
c_str
());
return
std
::
make_unique
<
TwoFilters
>
(
std
::
move
(
a
),
std
::
move
(
b
));
}
src/filter/plugins/TwoFilters.hxx
View file @
49dcac5c
...
@@ -21,8 +21,10 @@
...
@@ -21,8 +21,10 @@
#define MPD_TWO_FILTERS_HXX
#define MPD_TWO_FILTERS_HXX
#include "filter/Filter.hxx"
#include "filter/Filter.hxx"
#include "filter/Prepared.hxx"
#include <memory>
#include <memory>
#include <string>
/**
/**
* A #Filter implementation which chains two other filters.
* A #Filter implementation which chains two other filters.
...
@@ -46,4 +48,21 @@ public:
...
@@ -46,4 +48,21 @@ public:
ConstBuffer
<
void
>
Flush
()
override
;
ConstBuffer
<
void
>
Flush
()
override
;
};
};
/**
* Like #TwoFilters, but implements the #PreparedFilter interface.
*/
class
PreparedTwoFilters
final
:
public
PreparedFilter
{
std
::
unique_ptr
<
PreparedFilter
>
first
,
second
;
std
::
string
second_name
;
public
:
template
<
typename
F
,
typename
S
,
typename
N
>
PreparedTwoFilters
(
F
&&
_first
,
S
&&
_second
,
N
&&
_second_name
)
noexcept
:
first
(
std
::
forward
<
F
>
(
_first
)),
second
(
std
::
forward
<
S
>
(
_second
)),
second_name
(
std
::
forward
<
N
>
(
_second_name
))
{}
std
::
unique_ptr
<
Filter
>
Open
(
AudioFormat
&
audio_format
)
override
;
};
#endif
#endif
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