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
13816c1c
Commit
13816c1c
authored
Nov 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/{recorder,httpd,shout}: use std::unique_ptr to manage PreparedEncoder pointer
parent
c54a920d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
18 deletions
+9
-18
RecorderOutputPlugin.cxx
src/output/plugins/RecorderOutputPlugin.cxx
+3
-6
ShoutOutputPlugin.cxx
src/output/plugins/ShoutOutputPlugin.cxx
+3
-4
HttpdInternal.hxx
src/output/plugins/httpd/HttpdInternal.hxx
+2
-2
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+1
-6
No files found.
src/output/plugins/RecorderOutputPlugin.cxx
View file @
13816c1c
...
...
@@ -35,6 +35,7 @@
#include "util/ScopeExit.hxx"
#include <stdexcept>
#include <memory>
#include <assert.h>
#include <stdlib.h>
...
...
@@ -45,7 +46,7 @@ class RecorderOutput final : AudioOutput {
/**
* The configured encoder plugin.
*/
PreparedEncoder
*
prepared_encoder
=
nullpt
r
;
std
::
unique_ptr
<
PreparedEncoder
>
prepared_encode
r
;
Encoder
*
encoder
;
/**
...
...
@@ -72,10 +73,6 @@ class RecorderOutput final : AudioOutput {
RecorderOutput
(
const
ConfigBlock
&
block
);
~
RecorderOutput
()
{
delete
prepared_encoder
;
}
public
:
static
AudioOutput
*
Create
(
EventLoop
&
,
const
ConfigBlock
&
block
)
{
return
new
RecorderOutput
(
block
);
...
...
@@ -136,7 +133,7 @@ RecorderOutput::RecorderOutput(const ConfigBlock &block)
/* initialize encoder */
prepared_encoder
=
encoder_init
(
*
encoder_plugin
,
block
);
prepared_encoder
.
reset
(
encoder_init
(
*
encoder_plugin
,
block
)
);
}
inline
void
...
...
src/output/plugins/ShoutOutputPlugin.cxx
View file @
13816c1c
...
...
@@ -30,6 +30,7 @@
#include <shout/shout.h>
#include <stdexcept>
#include <memory>
#include <assert.h>
#include <stdlib.h>
...
...
@@ -42,7 +43,7 @@ struct ShoutOutput final : AudioOutput {
shout_t
*
shout_conn
;
shout_metadata_t
*
shout_meta
;
PreparedEncoder
*
prepared_encoder
=
nullpt
r
;
std
::
unique_ptr
<
PreparedEncoder
>
prepared_encode
r
;
Encoder
*
encoder
;
float
quality
=
-
2.0
;
...
...
@@ -162,7 +163,7 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
throw
FormatRuntimeError
(
"couldn't find shout encoder plugin
\"
%s
\"
"
,
encoding
);
prepared_encoder
=
encoder_init
(
*
encoder_plugin
,
block
);
prepared_encoder
.
reset
(
encoder_init
(
*
encoder_plugin
,
block
)
);
unsigned
shout_format
;
if
(
strcmp
(
encoding
,
"mp3"
)
==
0
||
strcmp
(
encoding
,
"lame"
)
==
0
)
...
...
@@ -243,8 +244,6 @@ ShoutOutput::~ShoutOutput()
shout_init_count
--
;
if
(
shout_init_count
==
0
)
shout_shutdown
();
delete
prepared_encoder
;
}
AudioOutput
*
...
...
src/output/plugins/httpd/HttpdInternal.hxx
View file @
13816c1c
...
...
@@ -39,6 +39,7 @@
#include <queue>
#include <list>
#include <memory>
struct
ConfigBlock
;
class
EventLoop
;
...
...
@@ -60,7 +61,7 @@ class HttpdOutput final : AudioOutput, ServerSocket {
/**
* The configured encoder plugin.
*/
PreparedEncoder
*
prepared_encoder
=
nullpt
r
;
std
::
unique_ptr
<
PreparedEncoder
>
prepared_encode
r
;
Encoder
*
encoder
=
nullptr
;
/**
...
...
@@ -152,7 +153,6 @@ private:
public
:
HttpdOutput
(
EventLoop
&
_loop
,
const
ConfigBlock
&
block
);
~
HttpdOutput
();
static
AudioOutput
*
Create
(
EventLoop
&
event_loop
,
const
ConfigBlock
&
block
)
{
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
13816c1c
...
...
@@ -79,7 +79,7 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
/* initialize encoder */
prepared_encoder
=
encoder_init
(
*
encoder_plugin
,
block
);
prepared_encoder
.
reset
(
encoder_init
(
*
encoder_plugin
,
block
)
);
/* determine content type */
content_type
=
prepared_encoder
->
GetMimeType
();
...
...
@@ -87,11 +87,6 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
content_type
=
"application/octet-stream"
;
}
HttpdOutput
::~
HttpdOutput
()
{
delete
prepared_encoder
;
}
inline
void
HttpdOutput
::
Bind
()
{
...
...
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