diff --git a/src/ogg.cc b/src/ogg.cc index e260550..0acf493 100644 --- a/src/ogg.cc +++ b/src/ogg.cc @@ -24,10 +24,17 @@ ogg::Stream::~Stream() ogg_stream_clear(&stream); } +void ogg::Stream::flush_packets() +{ + ogg_packet op; + while (ogg_stream_packetout(&stream, &op) > 0); +} + bool ogg::Stream::page_in(ogg_page &og) { if (state == ogg::RAW_READY) return true; + flush_packets(); // otherwise packet_out keeps returning the same packet if (ogg_stream_pagein(&stream, &og) != 0) throw std::runtime_error("ogg_stream_pagein failed"); diff --git a/src/ogg.h b/src/ogg.h index b89c460..59cc501 100644 --- a/src/ogg.h +++ b/src/ogg.h @@ -64,6 +64,7 @@ namespace ogg ogg_stream_state stream; private: + void flush_packets(); bool handle_page(); void handle_packet(const ogg_packet&); void parse_header(const ogg_packet&);