Fix warning about frames left in queue.
Example: - [libmp3lame @ 0x55b9e7248300] 4 frames left in the queue on closing
This commit is contained in:
parent
f5b19475c9
commit
6b18c1f9b8
|
@ -450,6 +450,7 @@ void recording::MediaRecorder::Stop()
|
||||||
npts = 0;
|
npts = 0;
|
||||||
if (oc)
|
if (oc)
|
||||||
{
|
{
|
||||||
|
flush_frames();
|
||||||
// close the output file
|
// close the output file
|
||||||
if (!(fmt->flags & AVFMT_NOFILE))
|
if (!(fmt->flags & AVFMT_NOFILE))
|
||||||
{
|
{
|
||||||
|
@ -623,3 +624,16 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
|
||||||
}
|
}
|
||||||
return MRET_OK;
|
return MRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flush last frames to avoid
|
||||||
|
// "X frames left in the queue on closing"
|
||||||
|
void recording::MediaRecorder::flush_frames()
|
||||||
|
{
|
||||||
|
AVPacket pkt;
|
||||||
|
av_init_packet(&pkt);
|
||||||
|
pkt.data = NULL;
|
||||||
|
pkt.size = 0;
|
||||||
|
// flush last audio frames
|
||||||
|
while (avcodec_receive_packet(aenc, &pkt) >= 0)
|
||||||
|
avcodec_send_frame(aenc, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -111,6 +111,9 @@ class MediaRecorder
|
||||||
MediaRet setup_video_stream(int width, int height);
|
MediaRet setup_video_stream(int width, int height);
|
||||||
MediaRet setup_audio_stream();
|
MediaRet setup_audio_stream();
|
||||||
MediaRet finish_setup(const char *fname);
|
MediaRet finish_setup(const char *fname);
|
||||||
|
// flush last frames to avoid
|
||||||
|
// "X frames left in the queue on closing"
|
||||||
|
void flush_frames();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue