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
0c965d05
Commit
0c965d05
authored
Nov 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/AutoConvert: move the Filter class to TwoFilters.cxx
parent
77c14692
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
46 deletions
+92
-46
AutoConvertFilterPlugin.cxx
src/filter/plugins/AutoConvertFilterPlugin.cxx
+3
-46
TwoFilters.cxx
src/filter/plugins/TwoFilters.cxx
+39
-0
TwoFilters.hxx
src/filter/plugins/TwoFilters.hxx
+49
-0
meson.build
src/filter/plugins/meson.build
+1
-0
No files found.
src/filter/plugins/AutoConvertFilterPlugin.cxx
View file @
0c965d05
...
...
@@ -19,6 +19,7 @@
#include "AutoConvertFilterPlugin.hxx"
#include "ConvertFilterPlugin.hxx"
#include "TwoFilters.hxx"
#include "filter/Filter.hxx"
#include "filter/Prepared.hxx"
#include "pcm/AudioFormat.hxx"
...
...
@@ -27,33 +28,6 @@
#include <cassert>
#include <memory>
class
AutoConvertFilter
final
:
public
Filter
{
/**
* The underlying filter.
*/
std
::
unique_ptr
<
Filter
>
filter
;
/**
* A convert_filter, just in case conversion is needed. nullptr
* if unused.
*/
std
::
unique_ptr
<
Filter
>
convert
;
public
:
AutoConvertFilter
(
std
::
unique_ptr
<
Filter
>
&&
_filter
,
std
::
unique_ptr
<
Filter
>
&&
_convert
)
:
Filter
(
_filter
->
GetOutAudioFormat
()),
filter
(
std
::
move
(
_filter
)),
convert
(
std
::
move
(
_convert
))
{}
void
Reset
()
noexcept
override
{
filter
->
Reset
();
convert
->
Reset
();
}
ConstBuffer
<
void
>
FilterPCM
(
ConstBuffer
<
void
>
src
)
override
;
ConstBuffer
<
void
>
Flush
()
override
;
};
class
PreparedAutoConvertFilter
final
:
public
PreparedFilter
{
/**
* The underlying filter.
...
...
@@ -88,25 +62,8 @@ PreparedAutoConvertFilter::Open(AudioFormat &in_audio_format)
auto
convert
=
convert_filter_new
(
in_audio_format
,
child_audio_format
);
return
std
::
make_unique
<
AutoConvertFilter
>
(
std
::
move
(
new_filter
),
std
::
move
(
convert
));
}
ConstBuffer
<
void
>
AutoConvertFilter
::
FilterPCM
(
ConstBuffer
<
void
>
src
)
{
src
=
convert
->
FilterPCM
(
src
);
return
filter
->
FilterPCM
(
src
);
}
ConstBuffer
<
void
>
AutoConvertFilter
::
Flush
()
{
auto
result
=
convert
->
Flush
();
if
(
!
result
.
IsNull
())
return
filter
->
FilterPCM
(
result
);
return
filter
->
Flush
();
return
std
::
make_unique
<
TwoFilters
>
(
std
::
move
(
convert
),
std
::
move
(
new_filter
));
}
std
::
unique_ptr
<
PreparedFilter
>
...
...
src/filter/plugins/TwoFilters.cxx
0 → 100644
View file @
0c965d05
/*
* Copyright 2003-2020 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "TwoFilters.hxx"
#include "util/ConstBuffer.hxx"
ConstBuffer
<
void
>
TwoFilters
::
FilterPCM
(
ConstBuffer
<
void
>
src
)
{
return
second
->
FilterPCM
(
first
->
FilterPCM
(
src
));
}
ConstBuffer
<
void
>
TwoFilters
::
Flush
()
{
auto
result
=
first
->
Flush
();
if
(
!
result
.
IsNull
())
/* Flush() output from the first Filter must be
filtered by the second Filter */
return
second
->
FilterPCM
(
result
);
return
second
->
Flush
();
}
src/filter/plugins/TwoFilters.hxx
0 → 100644
View file @
0c965d05
/*
* Copyright 2003-2020 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_WITH_CONVERT_FILTER_HXX
#define MPD_WITH_CONVERT_FILTER_HXX
#include "filter/Filter.hxx"
#include <memory>
/**
* A #Filter implementation which chains two other filters.
*/
class
TwoFilters
final
:
public
Filter
{
std
::
unique_ptr
<
Filter
>
first
,
second
;
public
:
template
<
typename
F
,
typename
S
>
TwoFilters
(
F
&&
_first
,
S
&&
_second
)
noexcept
:
Filter
(
_second
->
GetOutAudioFormat
()),
first
(
std
::
forward
<
F
>
(
_first
)),
second
(
std
::
forward
<
S
>
(
_second
))
{}
void
Reset
()
noexcept
override
{
first
->
Reset
();
second
->
Reset
();
}
ConstBuffer
<
void
>
FilterPCM
(
ConstBuffer
<
void
>
src
)
override
;
ConstBuffer
<
void
>
Flush
()
override
;
};
#endif
src/filter/plugins/meson.build
View file @
0c965d05
...
...
@@ -14,6 +14,7 @@ filter_plugins = static_library(
'filter_plugins',
'../../AudioCompress/compress.c',
'NullFilterPlugin.cxx',
'TwoFilters.cxx',
'ChainFilterPlugin.cxx',
'AutoConvertFilterPlugin.cxx',
'ConvertFilterPlugin.cxx',
...
...
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