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
33f70931
Commit
33f70931
authored
Sep 04, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/API: add decoder_read_much()
parent
8830ea31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
DecoderAPI.cxx
src/decoder/DecoderAPI.cxx
+21
-0
DecoderAPI.hxx
src/decoder/DecoderAPI.hxx
+12
-0
No files found.
src/decoder/DecoderAPI.cxx
View file @
33f70931
...
...
@@ -42,6 +42,27 @@ decoder_read(DecoderClient *client,
}
}
size_t
decoder_read_much
(
DecoderClient
*
client
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
noexcept
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
size_t
total
=
0
;
while
(
size
>
0
&&
!
is
.
LockIsEOF
())
{
size_t
nbytes
=
decoder_read
(
client
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
return
false
;
total
+=
nbytes
;
buffer
+=
nbytes
;
size
-=
nbytes
;
}
return
total
;
}
bool
decoder_read_full
(
DecoderClient
*
client
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
noexcept
...
...
src/decoder/DecoderAPI.hxx
View file @
33f70931
...
...
@@ -76,6 +76,18 @@ decoder_read(DecoderClient &decoder, InputStream &is,
/**
* Blocking read from the input stream. Attempts to fill the buffer
* as much as possible, until either end-of-file is reached or an
* error occurs.
*
* @return the number of bytes read, or 0 if one of the following
* occurs: end of file; error; command (like SEEK or STOP).
*/
size_t
decoder_read_much
(
DecoderClient
*
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
size
)
noexcept
;
/**
* Blocking read from the input stream. Attempts to fill the buffer
* completely; there is no partial result.
*
* @return true on success, false on error or command or not enough
...
...
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