mirror of
https://github.com/fmang/opustags.git
synced 2025-07-09 10:55:10 +02:00
list_tags: stop reading after the headers
see #11 remains the command-line to adjust
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user