mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
parent
32df05b528
commit
85cb742f79
@ -210,6 +210,23 @@ FfmpegAudioCursor::
|
||||
*/
|
||||
void FfmpegAudioCursor::
|
||||
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 LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101)
|
||||
av_frame_free(&_frame);
|
||||
@ -237,16 +254,6 @@ cleanup() {
|
||||
_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) {
|
||||
_ffvfile.close();
|
||||
_format_ctx = nullptr;
|
||||
|
@ -595,7 +595,14 @@ close_stream() {
|
||||
// Hold the global lock while we free avcodec objects.
|
||||
ReMutexHolder av_holder(_av_lock);
|
||||
|
||||
if ((_video_ctx)&&(_video_ctx->codec)) {
|
||||
if (_video_ctx && _video_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(_video_ctx, nullptr);
|
||||
while (avcodec_receive_frame(_video_ctx, _frame) == 0) {}
|
||||
avcodec_flush_buffers(_video_ctx);
|
||||
#endif
|
||||
|
||||
avcodec_close(_video_ctx);
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 52, 0)
|
||||
avcodec_free_context(&_video_ctx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user