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
77c14692
Commit
77c14692
authored
Nov 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/AutoConvert: eliminate AutoConvertFilter if possible
If no conversion is necessary, return the child Filter as-is. This allows removing all nullptr checks from AutoConvertFilter.
parent
226eb263
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
AutoConvertFilterPlugin.cxx
src/filter/plugins/AutoConvertFilterPlugin.cxx
+12
-17
No files found.
src/filter/plugins/AutoConvertFilterPlugin.cxx
View file @
77c14692
...
...
@@ -47,9 +47,7 @@ public:
void
Reset
()
noexcept
override
{
filter
->
Reset
();
if
(
convert
)
convert
->
Reset
();
convert
->
Reset
();
}
ConstBuffer
<
void
>
FilterPCM
(
ConstBuffer
<
void
>
src
)
override
;
...
...
@@ -81,13 +79,14 @@ PreparedAutoConvertFilter::Open(AudioFormat &in_audio_format)
/* need to convert? */
std
::
unique_ptr
<
Filter
>
convert
;
if
(
in_audio_format
!=
child_audio_format
)
{
/* yes - create a convert_filter */
if
(
in_audio_format
==
child_audio_format
)
/* no */
return
new_filter
;
convert
=
convert_filter_new
(
in_audio_format
,
child_audio_format
);
}
/* yes - create a convert_filter */
auto
convert
=
convert_filter_new
(
in_audio_format
,
child_audio_format
);
return
std
::
make_unique
<
AutoConvertFilter
>
(
std
::
move
(
new_filter
),
std
::
move
(
convert
));
...
...
@@ -96,20 +95,16 @@ PreparedAutoConvertFilter::Open(AudioFormat &in_audio_format)
ConstBuffer
<
void
>
AutoConvertFilter
::
FilterPCM
(
ConstBuffer
<
void
>
src
)
{
if
(
convert
!=
nullptr
)
src
=
convert
->
FilterPCM
(
src
);
src
=
convert
->
FilterPCM
(
src
);
return
filter
->
FilterPCM
(
src
);
}
ConstBuffer
<
void
>
AutoConvertFilter
::
Flush
()
{
if
(
convert
!=
nullptr
)
{
auto
result
=
convert
->
Flush
();
if
(
!
result
.
IsNull
())
return
filter
->
FilterPCM
(
result
);
}
auto
result
=
convert
->
Flush
();
if
(
!
result
.
IsNull
())
return
filter
->
FilterPCM
(
result
);
return
filter
->
Flush
();
}
...
...
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