list_tags: stop reading after the headers

see #11
remains the command-line to adjust
This commit is contained in:
Frédéric Mangano
2016-03-30 14:09:19 +02:00
parent a21331057b
commit eb968dc513
2 changed files with 9 additions and 5 deletions

View File

@ -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<ogg::Stream> 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
}
}

View File

@ -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.