ogg: flush packets before paging in

This commit is contained in:
Frédéric Mangano
2016-03-02 15:15:13 +01:00
parent 84a0ce55af
commit c19233236a
2 changed files with 8 additions and 0 deletions

View File

@ -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");

View File

@ -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&);