|
@@ -210,6 +210,23 @@ FfmpegAudioCursor::
|
|
|
*/
|
|
*/
|
|
|
void FfmpegAudioCursor::
|
|
void FfmpegAudioCursor::
|
|
|
cleanup() {
|
|
cleanup() {
|
|
|
|
|
+ if (_audio_ctx && _audio_ctx->codec) {
|
|
|
|
|
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
|
|
|
|
|
+ // We need to drain the codec to prevent a memory leak.
|
|
|
|
|
+ avcodec_send_packet(_audio_ctx, nullptr);
|
|
|
|
|
+ while (avcodec_receive_frame(_audio_ctx, _frame) == 0) {}
|
|
|
|
|
+ avcodec_flush_buffers(_audio_ctx);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+ avcodec_close(_audio_ctx);
|
|
|
|
|
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0)
|
|
|
|
|
+ avcodec_free_context(&_audio_ctx);
|
|
|
|
|
+#else
|
|
|
|
|
+ delete _audio_ctx;
|
|
|
|
|
+#endif
|
|
|
|
|
+ }
|
|
|
|
|
+ _audio_ctx = nullptr;
|
|
|
|
|
+
|
|
|
if (_frame) {
|
|
if (_frame) {
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101)
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101)
|
|
|
av_frame_free(&_frame);
|
|
av_frame_free(&_frame);
|
|
@@ -237,16 +254,6 @@ cleanup() {
|
|
|
_buffer = nullptr;
|
|
_buffer = nullptr;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if ((_audio_ctx)&&(_audio_ctx->codec)) {
|
|
|
|
|
- avcodec_close(_audio_ctx);
|
|
|
|
|
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0)
|
|
|
|
|
- avcodec_free_context(&_audio_ctx);
|
|
|
|
|
-#else
|
|
|
|
|
- delete _audio_ctx;
|
|
|
|
|
-#endif
|
|
|
|
|
- }
|
|
|
|
|
- _audio_ctx = nullptr;
|
|
|
|
|
-
|
|
|
|
|
if (_format_ctx) {
|
|
if (_format_ctx) {
|
|
|
_ffvfile.close();
|
|
_ffvfile.close();
|
|
|
_format_ctx = nullptr;
|
|
_format_ctx = nullptr;
|