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
d37b788e
Commit
d37b788e
authored
Dec 14, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DecoderAPI: add function decoder_read_full()
Move code from the "mad" plugin.
parent
cb336ff6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
12 deletions
+67
-12
DecoderAPI.cxx
src/DecoderAPI.cxx
+18
-0
DecoderAPI.hxx
src/DecoderAPI.hxx
+11
-0
MadDecoderPlugin.cxx
src/decoder/MadDecoderPlugin.cxx
+2
-12
FakeDecoderAPI.cxx
test/FakeDecoderAPI.cxx
+18
-0
run_decoder.cxx
test/run_decoder.cxx
+18
-0
No files found.
src/DecoderAPI.cxx
View file @
d37b788e
...
...
@@ -307,6 +307,24 @@ decoder_read(Decoder *decoder,
}
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
while
(
size
>
0
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
return
false
;
buffer
+=
nbytes
;
size
-=
nbytes
;
}
return
true
;
}
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
{
while
(
size
>
0
)
{
...
...
src/DecoderAPI.hxx
View file @
d37b788e
...
...
@@ -117,6 +117,17 @@ decoder_read(Decoder &decoder, InputStream &is,
}
/**
* 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
* data
*/
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
buffer
,
size_t
size
);
/**
* Skip data on the #InputStream.
*
* @return true on success, false on error or command
...
...
src/decoder/MadDecoderPlugin.cxx
View file @
d37b788e
...
...
@@ -353,18 +353,8 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
memcpy
(
allocated
,
stream
.
this_frame
,
count
);
mad_stream_skip
(
&
(
stream
),
count
);
while
(
count
<
tagsize
)
{
size_t
len
;
len
=
decoder_read
(
decoder
,
input_stream
,
allocated
+
count
,
tagsize
-
count
);
if
(
len
==
0
)
break
;
else
count
+=
len
;
}
if
(
count
!=
tagsize
)
{
if
(
!
decoder_read_full
(
decoder
,
input_stream
,
allocated
+
count
,
tagsize
-
count
))
{
LogDebug
(
mad_domain
,
"error parsing ID3 tag"
);
g_free
(
allocated
);
return
;
...
...
test/FakeDecoderAPI.cxx
View file @
d37b788e
...
...
@@ -66,6 +66,24 @@ decoder_read(gcc_unused Decoder *decoder,
}
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
while
(
size
>
0
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
return
false
;
buffer
+=
nbytes
;
size
-=
nbytes
;
}
return
true
;
}
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
{
while
(
size
>
0
)
{
...
...
test/run_decoder.cxx
View file @
d37b788e
...
...
@@ -102,6 +102,24 @@ decoder_read(gcc_unused Decoder *decoder,
}
bool
decoder_read_full
(
Decoder
*
decoder
,
InputStream
&
is
,
void
*
_buffer
,
size_t
size
)
{
uint8_t
*
buffer
=
(
uint8_t
*
)
_buffer
;
while
(
size
>
0
)
{
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
size
);
if
(
nbytes
==
0
)
return
false
;
buffer
+=
nbytes
;
size
-=
nbytes
;
}
return
true
;
}
bool
decoder_skip
(
Decoder
*
decoder
,
InputStream
&
is
,
size_t
size
)
{
while
(
size
>
0
)
{
...
...
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