forked from teamnwah/openmw-tes3coop
Only duplicate AVPackets as needed
Packets that don't have a destruct method are using static memory, which will only be valid until the next av_read_frame call. Otherwise, it's already dynamically allocated and will remain valid.
This commit is contained in:
parent
6008cf0d15
commit
db23c8152e
1 changed files with 10 additions and 3 deletions
|
@ -158,14 +158,21 @@ struct VideoState {
|
|||
void PacketQueue::put(AVPacket *pkt)
|
||||
{
|
||||
AVPacketList *pkt1;
|
||||
if(av_dup_packet(pkt) < 0)
|
||||
throw std::runtime_error("Failed to duplicate packet");
|
||||
|
||||
pkt1 = (AVPacketList*)av_malloc(sizeof(AVPacketList));
|
||||
if(!pkt1) throw std::bad_alloc();
|
||||
pkt1->pkt = *pkt;
|
||||
pkt1->next = NULL;
|
||||
|
||||
if(pkt1->pkt.destruct == NULL)
|
||||
{
|
||||
if(av_dup_packet(&pkt1->pkt) < 0)
|
||||
{
|
||||
av_free(pkt1);
|
||||
throw std::runtime_error("Failed to duplicate packet");
|
||||
}
|
||||
av_free_packet(pkt);
|
||||
}
|
||||
|
||||
this->mutex.lock ();
|
||||
|
||||
if(!last_pkt)
|
||||
|
|
Loading…
Reference in a new issue