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
b1a9958c
Commit
b1a9958c
authored
Mar 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_output: add struct CommandLine
parent
e6a81bb9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
run_output.cxx
test/run_output.cxx
+30
-16
No files found.
test/run_output.cxx
View file @
b1a9958c
...
...
@@ -39,6 +39,31 @@
#include <stdlib.h>
#include <stdio.h>
struct
CommandLine
{
FromNarrowPath
config_path
;
const
char
*
output_name
=
nullptr
;
AudioFormat
audio_format
{
44100
,
SampleFormat
::
S16
,
2
};
};
static
CommandLine
ParseCommandLine
(
int
argc
,
char
**
argv
)
{
CommandLine
c
;
if
(
argc
<
3
||
argc
>
4
)
throw
std
::
runtime_error
(
"Usage: run_output CONFIG NAME [FORMAT] <IN"
);
c
.
config_path
=
argv
[
1
];
c
.
output_name
=
argv
[
2
];
if
(
argc
>
3
)
c
.
audio_format
=
ParseAudioFormat
(
argv
[
3
],
false
);
return
c
;
}
static
std
::
unique_ptr
<
AudioOutput
>
LoadAudioOutput
(
const
ConfigData
&
config
,
EventLoop
&
event_loop
,
const
char
*
name
)
...
...
@@ -107,34 +132,23 @@ run_output(AudioOutput &ao, AudioFormat audio_format)
int
main
(
int
argc
,
char
**
argv
)
try
{
if
(
argc
<
3
||
argc
>
4
)
{
fprintf
(
stderr
,
"Usage: run_output CONFIG NAME [FORMAT] <IN
\n
"
);
return
EXIT_FAILURE
;
}
const
FromNarrowPath
config_path
=
argv
[
1
];
AudioFormat
audio_format
(
44100
,
SampleFormat
::
S16
,
2
);
const
auto
c
=
ParseCommandLine
(
argc
,
argv
);
/* read configuration file (mpd.conf) */
const
auto
config
=
AutoLoadConfigFile
(
config_path
);
const
auto
config
=
AutoLoadConfigFile
(
c
.
c
onfig_path
);
EventThread
io_thread
;
io_thread
.
Start
();
/* initialize the audio output */
auto
ao
=
LoadAudioOutput
(
config
,
io_thread
.
GetEventLoop
(),
argv
[
2
]);
/* parse the audio format */
if
(
argc
>
3
)
audio_format
=
ParseAudioFormat
(
argv
[
3
],
false
);
auto
ao
=
LoadAudioOutput
(
config
,
io_thread
.
GetEventLoop
(),
c
.
output_name
);
/* do it */
run_output
(
*
ao
,
audio_format
);
run_output
(
*
ao
,
c
.
audio_format
);
/* cleanup and exit */
...
...
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