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
5fc0ce80
Commit
5fc0ce80
authored
Dec 27, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/pipe: move functions into the struct
parent
af9092df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
18 deletions
+35
-18
PipeOutputPlugin.cxx
src/output/plugins/PipeOutputPlugin.cxx
+35
-18
No files found.
src/output/plugins/PipeOutputPlugin.cxx
View file @
5fc0ce80
...
...
@@ -42,6 +42,14 @@ struct PipeOutput {
}
bool
Configure
(
const
config_param
&
param
,
Error
&
error
);
bool
Open
(
AudioFormat
&
audio_format
,
Error
&
error
);
void
Close
()
{
pclose
(
fh
);
}
size_t
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
);
};
static
constexpr
Domain
pipe_output_domain
(
"pipe_output"
);
...
...
@@ -85,43 +93,52 @@ pipe_output_finish(AudioOutput *ao)
delete
pd
;
}
static
bool
pipe_output_open
(
AudioOutput
*
ao
,
gcc_unused
AudioFormat
&
audio_format
,
Error
&
error
)
inline
bool
PipeOutput
::
Open
(
gcc_unused
AudioFormat
&
audio_format
,
Error
&
error
)
{
PipeOutput
*
pd
=
(
PipeOutput
*
)
ao
;
pd
->
fh
=
popen
(
pd
->
cmd
.
c_str
(),
"w"
);
if
(
pd
->
fh
==
nullptr
)
{
fh
=
popen
(
cmd
.
c_str
(),
"w"
);
if
(
fh
==
nullptr
)
{
error
.
FormatErrno
(
"Error opening pipe
\"
%s
\"
"
,
pd
->
cmd
.
c_str
());
cmd
.
c_str
());
return
false
;
}
return
true
;
}
static
bool
pipe_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
,
Error
&
error
)
{
PipeOutput
&
po
=
*
(
PipeOutput
*
)
ao
;
return
po
.
Open
(
audio_format
,
error
);
}
static
void
pipe_output_close
(
AudioOutput
*
ao
)
{
PipeOutput
*
pd
=
(
PipeOutput
*
)
ao
;
PipeOutput
&
po
=
*
(
PipeOutput
*
)
ao
;
pclose
(
pd
->
fh
);
po
.
Close
();
}
inline
size_t
PipeOutput
::
Play
(
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
{
size_t
nbytes
=
fwrite
(
chunk
,
1
,
size
,
fh
);
if
(
nbytes
==
0
)
error
.
SetErrno
(
"Write error on pipe"
);
return
nbytes
;
}
static
size_t
pipe_output_play
(
AudioOutput
*
ao
,
const
void
*
chunk
,
size_t
size
,
Error
&
error
)
{
PipeOutput
*
pd
=
(
PipeOutput
*
)
ao
;
size_t
ret
;
ret
=
fwrite
(
chunk
,
1
,
size
,
pd
->
fh
);
if
(
ret
==
0
)
error
.
SetErrno
(
"Write error on pipe"
);
PipeOutput
&
po
=
*
(
PipeOutput
*
)
ao
;
return
ret
;
return
po
.
Play
(
chunk
,
size
,
error
)
;
}
const
struct
AudioOutputPlugin
pipe_output_plugin
=
{
...
...
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