list_tags: always call end_of_stream when done

related to issue #6
This commit is contained in:
Frédéric Mangano 2016-04-07 13:26:20 +02:00
parent dad987a8da
commit 410708e252

View File

@ -10,10 +10,8 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler, bool full)
std::shared_ptr<ogg::Stream> s;
while (!handler.done()) {
s = dec.read_page();
if (s == nullptr) {
handler.end_of_stream();
if (s == nullptr)
break; // end of stream
}
switch (s->state) {
case ogg::HEADER_READY:
if (s->type != ogg::UNKNOWN_STREAM) {
@ -30,9 +28,13 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler, bool full)
default:
remaining_streams--;
}
if (!full && remaining_streams <= 0)
break; // end_of_stream not called, since we stopped early
if (!full && remaining_streams <= 0) {
break;
// premature exit, but calls end_of_stream anyway
// we want our optimization to be transparent to the TagsHandler
}
}
handler.end_of_stream();
}
void opustags::edit_tags(