mirror of
https://github.com/fmang/opustags.git
synced 2025-03-14 08:30:08 +01:00
specify TagsHandler::end_of_stream
This commit is contained in:
parent
32c5e2b0a6
commit
a78906a8d4
@ -7,8 +7,10 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler)
|
||||
std::shared_ptr<ogg::Stream> s;
|
||||
while (!handler.done()) {
|
||||
s = dec.read_page();
|
||||
if (s == nullptr)
|
||||
if (s == nullptr) {
|
||||
handler.end_of_stream();
|
||||
break; // end of stream
|
||||
}
|
||||
switch (s->state) {
|
||||
case ogg::HEADER_READY:
|
||||
if (!handler.relevant(s->stream.serialno))
|
||||
@ -28,7 +30,7 @@ void opustags::edit_tags(
|
||||
ogg::Decoder &in, ogg::Encoder &out, ITagsHandler &handler)
|
||||
{
|
||||
std::shared_ptr<ogg::Stream> s;
|
||||
while (true) {
|
||||
for (;;) {
|
||||
s = in.read_page();
|
||||
if (s == nullptr)
|
||||
break; // end of stream
|
||||
@ -60,4 +62,5 @@ void opustags::edit_tags(
|
||||
;
|
||||
}
|
||||
}
|
||||
handler.end_of_stream();
|
||||
}
|
||||
|
@ -30,6 +30,15 @@ namespace opustags {
|
||||
// use keeping reading the file for new streams. In that case, a true
|
||||
// return value would abort any further processing.
|
||||
virtual bool done() = 0;
|
||||
|
||||
// Signals the end of the stream.
|
||||
// If after this function is called, done() returns false, it's an
|
||||
// error. However, it would be better to raise the error inside
|
||||
// end_of_stream().
|
||||
// For example, if you expect to find the stream #1 and reach the
|
||||
// end-of-stream before finding it, better tell the user that you
|
||||
// didn't do what he expected.
|
||||
virtual void end_of_stream() {}
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user