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
28c69757
Commit
28c69757
authored
Sep 04, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/AutoConvert: use std::unique_ptr
parent
12091fcf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
AutoConvertFilterPlugin.cxx
src/filter/plugins/AutoConvertFilterPlugin.cxx
+16
-19
No files found.
src/filter/plugins/AutoConvertFilterPlugin.cxx
View file @
28c69757
...
...
@@ -26,28 +26,26 @@
#include "AudioFormat.hxx"
#include "util/ConstBuffer.hxx"
#include <memory>
#include <assert.h>
class
AutoConvertFilter
final
:
public
Filter
{
/**
* The underlying filter.
*/
Filter
*
const
filter
;
std
::
unique_ptr
<
Filter
>
filter
;
/**
* A convert_filter, just in case conversion is needed. nullptr
* if unused.
*/
Filter
*
const
convert
;
std
::
unique_ptr
<
Filter
>
convert
;
public
:
AutoConvertFilter
(
Filter
*
_filter
,
Filter
*
_convert
)
:
filter
(
_filter
),
convert
(
_convert
)
{}
~
AutoConvertFilter
()
{
delete
convert
;
delete
filter
;
}
AutoConvertFilter
(
std
::
unique_ptr
<
Filter
>
&&
_filter
,
std
::
unique_ptr
<
Filter
>
&&
_convert
)
:
filter
(
std
::
move
(
_filter
)),
convert
(
std
::
move
(
_convert
))
{}
virtual
ConstBuffer
<
void
>
FilterPCM
(
ConstBuffer
<
void
>
src
,
Error
&
error
)
override
;
...
...
@@ -76,26 +74,25 @@ PreparedAutoConvertFilter::Open(AudioFormat &in_audio_format, Error &error)
/* open the "real" filter */
AudioFormat
child_audio_format
=
in_audio_format
;
auto
*
new_filter
=
filter
->
Open
(
child_audio_format
,
error
);
if
(
new_filter
==
nullpt
r
)
std
::
unique_ptr
<
Filter
>
new_filter
(
filter
->
Open
(
child_audio_format
,
error
)
);
if
(
!
new_filte
r
)
return
nullptr
;
/* need to convert? */
Filter
*
convert
=
nullptr
;
std
::
unique_ptr
<
Filter
>
convert
;
if
(
in_audio_format
!=
child_audio_format
)
{
/* yes - create a convert_filter */
convert
=
convert_filter_new
(
in_audio_format
,
child_audio_format
,
error
);
if
(
convert
==
nullptr
)
{
delete
new_filter
;
convert
.
reset
(
convert_filter_new
(
in_audio_format
,
child_audio_format
,
error
));
if
(
!
convert
)
return
nullptr
;
}
}
return
new
AutoConvertFilter
(
new_filter
,
convert
);
return
new
AutoConvertFilter
(
std
::
move
(
new_filter
),
std
::
move
(
convert
));
}
ConstBuffer
<
void
>
...
...
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