diff --git a/src/actions.cc b/src/actions.cc index c7e406c..94b4e64 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -2,8 +2,9 @@ using namespace opustags; -void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler) +void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler, bool full) { + int remaining_streams = 0; std::shared_ptr s; while (!handler.done()) { s = dec.read_page(); @@ -17,14 +18,16 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler) ; // ignore else if (!handler.relevant(s->stream.serialno)) s->downgrade(); + remaining_streams++; break; case ogg::TAGS_READY: handler.list(s->stream.serialno, s->tags); s->downgrade(); // no more use for it - break; default: - ; + remaining_streams--; } + if (!full && remaining_streams <= 0) + break; // end_of_stream not called, since we stopped early } } diff --git a/src/actions.h b/src/actions.h index ea462e6..9e980e9 100644 --- a/src/actions.h +++ b/src/actions.h @@ -6,7 +6,8 @@ namespace opustags { // Decode a file and call the handler's list method every time a tags - // header is read. + // header is read. Set full to true if you want to make sure every single + // page of the stream is read. // // Use: // std::ifstream in("in.ogg"); @@ -14,7 +15,7 @@ namespace opustags { // TagsLister lister(options); // list_tags(dec, lister); // - void list_tags(ogg::Decoder&, ITagsHandler &); + void list_tags(ogg::Decoder&, ITagsHandler &, bool full = false); // Forward the input data to the output stream, transforming tags on-the-go // with the handler's edit method.