diff --git a/src/actions.cc b/src/actions.cc index 61305bb..c6f96fd 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -16,6 +16,7 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler, bool full) case ogg::HEADER_READY: stream_count++; sequence_numbers[s->stream.serialno] = stream_count; + handler.start_of_stream(stream_count, s->type); if (!handler.relevant(stream_count)) s->downgrade(); remaining_streams++; @@ -32,7 +33,7 @@ void opustags::list_tags(ogg::Decoder &dec, ITagsHandler &handler, bool full) // we want our optimization to be transparent to the TagsHandler } } - handler.end_of_stream(); + handler.end_of_file(); } void opustags::edit_tags( @@ -50,6 +51,7 @@ void opustags::edit_tags( case ogg::HEADER_READY: stream_count++; sequence_numbers[s->stream.serialno] = stream_count; + handler.start_of_stream(stream_count, s->type); if (!handler.relevant(stream_count)) s->downgrade(); // makes it UNKNOWN if (s->type == ogg::UNKNOWN_STREAM) { @@ -77,5 +79,5 @@ void opustags::edit_tags( ; } } - handler.end_of_stream(); + handler.end_of_file(); } diff --git a/src/ogg.h b/src/ogg.h index d53d463..1502301 100644 --- a/src/ogg.h +++ b/src/ogg.h @@ -21,7 +21,7 @@ namespace ogg }; enum StreamType { - UNKNOWN_STREAM, + UNKNOWN_STREAM = 0, OPUS_STREAM, }; diff --git a/src/tags_handler.h b/src/tags_handler.h index 844f99d..a351e40 100644 --- a/src/tags_handler.h +++ b/src/tags_handler.h @@ -31,14 +31,20 @@ namespace opustags { // return value would abort any further processing. virtual bool done() = 0; - // Signals the end of the stream. + // Signals a new stream was found. + // The meaning of type is in ogg::StreamType, but all you should assume + // is that when type is null (UNKNOWN_STREAM), list or edit won't be + // called. + virtual void start_of_stream(const int streamno, const int type) {} + + // Signals the end of the file (and all the streams). // 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() {} + virtual void end_of_file() {} }; }