diff --git a/dom/media/ogg/OggDemuxer.cpp b/dom/media/ogg/OggDemuxer.cpp index 9f72a0a2c174..db91abbface5 100644 --- a/dom/media/ogg/OggDemuxer.cpp +++ b/dom/media/ogg/OggDemuxer.cpp @@ -862,11 +862,23 @@ RefPtr OggDemuxer::GetNextPacket(TrackInfo::TrackType aType) { OggCodecState* state = GetTrackCodecState(aType); - DemuxUntilPacketAvailable(state); + ogg_packet* packet = nullptr; + + do { + if (packet) { + OggCodecState::ReleasePacket(state->PacketOut()); + } + DemuxUntilPacketAvailable(state); + + packet = state->PacketPeek(); + } while (packet && state->IsHeader(packet)); + + if (!packet) { + return nullptr; + } // Check the eos state in case we need to look for chained streams. - ogg_packet* packet = state->PacketPeek(); - bool eos = packet && packet->e_o_s; + bool eos = packet->e_o_s; RefPtr data = state->PacketOutAsMediaRawData();;