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
f3e133c6
Commit
f3e133c6
authored
Mar 25, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_filter: use class FileDescriptor
parent
1678a6eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
run_filter.cxx
test/run_filter.cxx
+10
-8
No files found.
test/run_filter.cxx
View file @
f3e133c6
...
...
@@ -28,6 +28,7 @@
#include "pcm/Volume.hxx"
#include "mixer/MixerControl.hxx"
#include "system/Error.hxx"
#include "system/FileDescriptor.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringBuffer.hxx"
#include "util/RuntimeError.hxx"
...
...
@@ -40,8 +41,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
void
mixer_set_volume
(
gcc_unused
Mixer
*
mixer
,
...
...
@@ -62,9 +61,9 @@ LoadFilter(const ConfigData &config, const char *name)
}
static
size_t
ReadOrThrow
(
int
fd
,
void
*
buffer
,
size_t
size
)
ReadOrThrow
(
FileDescriptor
fd
,
void
*
buffer
,
size_t
size
)
{
auto
nbytes
=
read
(
fd
,
buffer
,
size
);
auto
nbytes
=
fd
.
Read
(
buffer
,
size
);
if
(
nbytes
<
0
)
throw
MakeErrno
(
"Read failed"
);
...
...
@@ -72,7 +71,7 @@ ReadOrThrow(int fd, void *buffer, size_t size)
}
static
void
FullRead
(
int
fd
,
void
*
_buffer
,
size_t
size
)
FullRead
(
FileDescriptor
fd
,
void
*
_buffer
,
size_t
size
)
{
auto
buffer
=
(
uint8_t
*
)
_buffer
;
...
...
@@ -87,7 +86,7 @@ FullRead(int fd, void *_buffer, size_t size)
}
static
size_t
ReadFrames
(
int
fd
,
void
*
_buffer
,
size_t
size
,
size_t
frame_size
)
ReadFrames
(
FileDescriptor
fd
,
void
*
_buffer
,
size_t
size
,
size_t
frame_size
)
{
auto
buffer
=
(
uint8_t
*
)
_buffer
;
...
...
@@ -142,17 +141,20 @@ try {
/* play */
FileDescriptor
input_fd
(
STDIN_FILENO
);
FileDescriptor
output_fd
(
STDOUT_FILENO
);
while
(
true
)
{
char
buffer
[
4096
];
ssize_t
nbytes
=
ReadFrames
(
0
,
buffer
,
sizeof
(
buffer
),
ssize_t
nbytes
=
ReadFrames
(
input_fd
,
buffer
,
sizeof
(
buffer
),
in_frame_size
);
if
(
nbytes
==
0
)
break
;
auto
dest
=
filter
->
FilterPCM
({(
const
void
*
)
buffer
,
(
size_t
)
nbytes
});
nbytes
=
write
(
1
,
dest
.
data
,
dest
.
size
);
nbytes
=
output_fd
.
Write
(
dest
.
data
,
dest
.
size
);
if
(
nbytes
<
0
)
{
fprintf
(
stderr
,
"Failed to write: %s
\n
"
,
strerror
(
errno
));
...
...
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