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
b45ea661
Commit
b45ea661
authored
Nov 05, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pipe: migrate from class Error to C++ exceptions
parent
543c5034
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
37 deletions
+16
-37
PipeOutputPlugin.cxx
src/output/plugins/PipeOutputPlugin.cxx
+16
-37
No files found.
src/output/plugins/PipeOutputPlugin.cxx
View file @
b45ea661
...
...
@@ -21,10 +21,10 @@
#include "PipeOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "../Wrapper.hxx"
#include "config/ConfigError.hxx"
#include "util/Error.hxx"
#include "system/Error.hxx"
#include <string>
#include <stdexcept>
#include <stdio.h>
...
...
@@ -33,13 +33,10 @@ class PipeOutput {
AudioOutput
base
;
std
::
string
cmd
;
const
std
::
string
cmd
;
FILE
*
fh
;
PipeOutput
()
:
base
(
pipe_output_plugin
)
{}
bool
Configure
(
const
ConfigBlock
&
block
,
Error
&
error
);
PipeOutput
(
const
ConfigBlock
&
block
);
public
:
static
PipeOutput
*
Create
(
const
ConfigBlock
&
block
,
Error
&
error
);
...
...
@@ -53,54 +50,36 @@ public:
size_t
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
);
};
inline
bool
PipeOutput
::
Configure
(
const
ConfigBlock
&
block
,
Error
&
error
)
PipeOutput
::
PipeOutput
(
const
ConfigBlock
&
block
)
:
base
(
pipe_output_plugin
,
block
),
cmd
(
block
.
GetBlockValue
(
"command"
,
""
))
{
if
(
!
base
.
Configure
(
block
,
error
))
return
false
;
cmd
=
block
.
GetBlockValue
(
"command"
,
""
);
if
(
cmd
.
empty
())
{
error
.
Set
(
config_domain
,
"No
\"
command
\"
parameter specified"
);
return
false
;
}
return
true
;
if
(
cmd
.
empty
())
throw
std
::
runtime_error
(
"No
\"
command
\"
parameter specified"
);
}
inline
PipeOutput
*
PipeOutput
::
Create
(
const
ConfigBlock
&
block
,
Error
&
error
)
PipeOutput
::
Create
(
const
ConfigBlock
&
block
,
Error
&
)
{
PipeOutput
*
po
=
new
PipeOutput
();
if
(
!
po
->
Configure
(
block
,
error
))
{
delete
po
;
return
nullptr
;
}
return
po
;
return
new
PipeOutput
(
block
);
}
inline
bool
PipeOutput
::
Open
(
gcc_unused
AudioFormat
&
audio_format
,
Error
&
error
)
PipeOutput
::
Open
(
gcc_unused
AudioFormat
&
audio_format
,
Error
&
)
{
fh
=
popen
(
cmd
.
c_str
(),
"w"
);
if
(
fh
==
nullptr
)
{
error
.
FormatErrno
(
"Error opening pipe
\"
%s
\"
"
,
cmd
.
c_str
());
return
false
;
}
if
(
fh
==
nullptr
)
throw
FormatErrno
(
"Error opening pipe
\"
%s
\"
"
,
cmd
.
c_str
());
return
true
;
}
inline
size_t
PipeOutput
::
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
PipeOutput
::
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
)
{
size_t
nbytes
=
fwrite
(
chunk
,
1
,
size
,
fh
);
if
(
nbytes
==
0
)
error
.
Set
Errno
(
"Write error on pipe"
);
throw
Make
Errno
(
"Write error on pipe"
);
return
nbytes
;
}
...
...
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