DecoderAPI: add function decoder_skip()
Move code from the "mad" plugin.
This commit is contained in:
parent
dba41e2e4a
commit
bf7417981f
@ -292,6 +292,22 @@ decoder_read(Decoder *decoder,
|
|||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
decoder_skip(Decoder *decoder, InputStream &is, size_t size)
|
||||||
|
{
|
||||||
|
while (size > 0) {
|
||||||
|
char buffer[1024];
|
||||||
|
size_t nbytes = decoder_read(decoder, is, buffer,
|
||||||
|
std::min(sizeof(buffer), size));
|
||||||
|
if (nbytes == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size -= nbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
decoder_timestamp(Decoder &decoder, double t)
|
decoder_timestamp(Decoder &decoder, double t)
|
||||||
{
|
{
|
||||||
|
@ -112,6 +112,14 @@ decoder_read(Decoder &decoder, InputStream &is,
|
|||||||
return decoder_read(&decoder, is, buffer, length);
|
return decoder_read(&decoder, is, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip data on the #InputStream.
|
||||||
|
*
|
||||||
|
* @return true on success, false on error or command
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
decoder_skip(Decoder *decoder, InputStream &is, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time stamp for the next data chunk [seconds]. The MPD
|
* Sets the time stamp for the next data chunk [seconds]. The MPD
|
||||||
* core automatically counts it up, and a decoder plugin only needs to
|
* core automatically counts it up, and a decoder plugin only needs to
|
||||||
|
@ -413,20 +413,7 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
|
|||||||
mad_stream_skip(&stream, tagsize);
|
mad_stream_skip(&stream, tagsize);
|
||||||
} else {
|
} else {
|
||||||
mad_stream_skip(&stream, count);
|
mad_stream_skip(&stream, count);
|
||||||
|
decoder_skip(decoder, input_stream, tagsize - count);
|
||||||
while (count < tagsize) {
|
|
||||||
size_t len = tagsize - count;
|
|
||||||
char ignored[1024];
|
|
||||||
if (len > sizeof(ignored))
|
|
||||||
len = sizeof(ignored);
|
|
||||||
|
|
||||||
len = decoder_read(decoder, input_stream,
|
|
||||||
ignored, len);
|
|
||||||
if (len == 0)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
count += len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,22 @@ decoder_read(gcc_unused Decoder *decoder,
|
|||||||
return is.LockRead(buffer, length, IgnoreError());
|
return is.LockRead(buffer, length, IgnoreError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
decoder_skip(Decoder *decoder, InputStream &is, size_t size)
|
||||||
|
{
|
||||||
|
while (size > 0) {
|
||||||
|
char buffer[1024];
|
||||||
|
size_t nbytes = decoder_read(decoder, is, buffer,
|
||||||
|
std::min(sizeof(buffer), size));
|
||||||
|
if (nbytes == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size -= nbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
decoder_timestamp(gcc_unused Decoder &decoder,
|
decoder_timestamp(gcc_unused Decoder &decoder,
|
||||||
gcc_unused double t)
|
gcc_unused double t)
|
||||||
|
@ -101,6 +101,22 @@ decoder_read(gcc_unused Decoder *decoder,
|
|||||||
return is.LockRead(buffer, length, IgnoreError());
|
return is.LockRead(buffer, length, IgnoreError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
decoder_skip(Decoder *decoder, InputStream &is, size_t size)
|
||||||
|
{
|
||||||
|
while (size > 0) {
|
||||||
|
char buffer[1024];
|
||||||
|
size_t nbytes = decoder_read(decoder, is, buffer,
|
||||||
|
std::min(sizeof(buffer), size));
|
||||||
|
if (nbytes == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size -= nbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
decoder_timestamp(gcc_unused Decoder &decoder,
|
decoder_timestamp(gcc_unused Decoder &decoder,
|
||||||
gcc_unused double t)
|
gcc_unused double t)
|
||||||
|
Loading…
Reference in New Issue
Block a user