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
1caa41a6
Commit
1caa41a6
authored
Jan 14, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_encoder: use EncoderToOutputStream()
parent
bf596352
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
32 deletions
+42
-32
run_encoder.cxx
test/run_encoder.cxx
+16
-15
test_vorbis_encoder.cxx
test/test_vorbis_encoder.cxx
+26
-17
No files found.
test/run_encoder.cxx
View file @
1caa41a6
...
...
@@ -21,29 +21,19 @@
#include "encoder/EncoderList.hxx"
#include "encoder/EncoderPlugin.hxx"
#include "encoder/EncoderInterface.hxx"
#include "encoder/ToOutputStream.hxx"
#include "AudioFormat.hxx"
#include "AudioParser.hxx"
#include "config/ConfigData.hxx"
#include "fs/io/StdioOutputStream.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "stdbin.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
static
void
encoder_to_stdout
(
Encoder
&
encoder
)
{
size_t
length
;
static
char
buffer
[
32768
];
while
((
length
=
encoder_read
(
&
encoder
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
gcc_unused
ssize_t
ignored
=
write
(
1
,
buffer
,
length
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
const
char
*
encoder_name
;
...
...
@@ -95,7 +85,12 @@ int main(int argc, char **argv)
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
StdioOutputStream
os
(
stdout
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
/* do it */
...
...
@@ -106,7 +101,10 @@ int main(int argc, char **argv)
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
}
if
(
!
encoder_end
(
encoder
,
error
))
{
...
...
@@ -114,7 +112,10 @@ int main(int argc, char **argv)
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
encoder
->
Close
();
encoder
->
Dispose
();
...
...
test/test_vorbis_encoder.cxx
View file @
1caa41a6
...
...
@@ -21,29 +21,20 @@
#include "encoder/EncoderList.hxx"
#include "encoder/EncoderPlugin.hxx"
#include "encoder/EncoderInterface.hxx"
#include "encoder/ToOutputStream.hxx"
#include "AudioFormat.hxx"
#include "config/ConfigData.hxx"
#include "
stdbin.h
"
#include "
fs/io/StdioOutputStream.hxx
"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include <stddef.h>
#include <unistd.h>
static
uint8_t
zero
[
256
];
static
void
encoder_to_stdout
(
Encoder
&
encoder
)
{
size_t
length
;
static
char
buffer
[
32768
];
while
((
length
=
encoder_read
(
&
encoder
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
gcc_unused
ssize_t
ignored
=
write
(
1
,
buffer
,
length
);
}
}
int
main
(
gcc_unused
int
argc
,
gcc_unused
char
**
argv
)
{
...
...
@@ -66,21 +57,33 @@ main(gcc_unused int argc, gcc_unused char **argv)
success
=
encoder
->
Open
(
audio_format
,
IgnoreError
());
assert
(
success
);
encoder_to_stdout
(
*
encoder
);
StdioOutputStream
os
(
stdout
);
Error
error
;
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
/* write a block of data */
success
=
encoder_write
(
encoder
,
zero
,
sizeof
(
zero
),
IgnoreError
());
assert
(
success
);
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
/* write a tag */
success
=
encoder_pre_tag
(
encoder
,
IgnoreError
());
assert
(
success
);
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
Tag
tag
;
...
...
@@ -94,7 +97,10 @@ main(gcc_unused int argc, gcc_unused char **argv)
success
=
encoder_tag
(
encoder
,
tag
,
IgnoreError
());
assert
(
success
);
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
/* write another block of data */
...
...
@@ -106,7 +112,10 @@ main(gcc_unused int argc, gcc_unused char **argv)
success
=
encoder_end
(
encoder
,
IgnoreError
());
assert
(
success
);
encoder_to_stdout
(
*
encoder
);
if
(
!
EncoderToOutputStream
(
os
,
*
encoder
,
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
encoder
->
Close
();
encoder
->
Dispose
();
...
...
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