change sematics of pop to return the packet* instead of boolean. Free packets in clearQueue
This commit is contained in:
parent
5e7404d448
commit
c6607ea5fe
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "zm_packetqueue.h"
|
#include "zm_packetqueue.h"
|
||||||
|
#include "zm_ffmpeg.h"
|
||||||
|
|
||||||
#define VIDEO_QUEUESIZE 200
|
#define VIDEO_QUEUESIZE 200
|
||||||
#define AUDIO_QUEUESIZE 50
|
#define AUDIO_QUEUESIZE 50
|
||||||
|
@ -34,28 +35,34 @@ zm_packetqueue::~zm_packetqueue() {
|
||||||
|
|
||||||
bool zm_packetqueue::queuePacket( AVPacket* packet ) {
|
bool zm_packetqueue::queuePacket( AVPacket* packet ) {
|
||||||
|
|
||||||
AVPacket input_ref = { 0 };
|
//AVPacket *input_ref = (AVPacket *)av_malloc(sizeof(AVPacket));
|
||||||
if ( av_packet_ref(&input_ref, packet) < 0 ) {
|
//if ( av_packet_ref( input_ref, packet ) < 0 ) {
|
||||||
return false;
|
//free(input_ref);
|
||||||
}
|
//return false;
|
||||||
pktQueue.push(*packet);
|
//}
|
||||||
|
pktQueue.push( packet );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zm_packetqueue::popPacket( AVPacket* packet ) {
|
AVPacket* zm_packetqueue::popPacket( ) {
|
||||||
if ( pktQueue.empty() ) {
|
if ( pktQueue.empty() ) {
|
||||||
return false;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*packet = pktQueue.front();
|
AVPacket *packet = pktQueue.front();
|
||||||
pktQueue.pop();
|
pktQueue.pop();
|
||||||
|
|
||||||
return true;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zm_packetqueue::clearQueue() {
|
void zm_packetqueue::clearQueue() {
|
||||||
|
AVPacket *packet = NULL;
|
||||||
while(!pktQueue.empty()) {
|
while(!pktQueue.empty()) {
|
||||||
pktQueue.pop();
|
|
||||||
|
packet = pktQueue.front();
|
||||||
|
pktQueue.pop();
|
||||||
|
// If we clear it, then no freeing gets done, whereas when we pop off, we assume that the packet was freed somewhere else.
|
||||||
|
zm_av_unref_packet( packet );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue