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
de0affe1
Commit
de0affe1
authored
Mar 11, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_convert: move code to ParseCommandLine()
parent
26e718c7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
run_convert.cxx
test/run_convert.cxx
+28
-13
No files found.
test/run_convert.cxx
View file @
de0affe1
...
...
@@ -28,32 +28,47 @@
#include "pcm/Convert.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx"
#include "util/OptionParser.hxx"
#include "util/PrintException.hxx"
#include <stdexcept>
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int
main
(
int
argc
,
char
**
argv
)
try
{
if
(
argc
!=
3
)
{
fprintf
(
stderr
,
"Usage: run_convert IN_FORMAT OUT_FORMAT <IN >OUT
\n
"
);
return
1
;
struct
CommandLine
{
AudioFormat
in_audio_format
,
out_audio_format
;
};
static
CommandLine
ParseCommandLine
(
int
argc
,
char
**
argv
)
{
CommandLine
c
;
OptionParser
option_parser
(
nullptr
,
argc
,
argv
);
while
(
option_parser
.
Next
())
{
}
const
auto
in_audio_format
=
ParseAudioFormat
(
argv
[
1
],
false
);
const
auto
out_audio_format_mask
=
ParseAudioFormat
(
argv
[
2
],
false
);
auto
args
=
option_parser
.
GetRemaining
();
if
(
args
.
size
!=
2
)
throw
std
::
runtime_error
(
"Usage: run_convert IN_FORMAT OUT_FORMAT <IN >OUT"
);
const
auto
out_audio_format
=
in_audio_format
.
WithMask
(
out_audio_format_mask
);
c
.
in_audio_format
=
ParseAudioFormat
(
args
[
0
],
false
);
c
.
out_audio_format
=
c
.
in_audio_format
.
WithMask
(
ParseAudioFormat
(
args
[
1
],
false
));
return
c
;
}
int
main
(
int
argc
,
char
**
argv
)
try
{
const
auto
c
=
ParseCommandLine
(
argc
,
argv
);
const
size_t
in_frame_size
=
in_audio_format
.
GetFrameSize
();
const
size_t
in_frame_size
=
c
.
in_audio_format
.
GetFrameSize
();
PcmConvert
state
(
in_audio_format
,
out_audio_format
);
PcmConvert
state
(
c
.
in_audio_format
,
c
.
out_audio_format
);
StaticFifoBuffer
<
uint8_t
,
4096
>
buffer
;
...
...
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