Commit dcd503d8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: close acceleration back-end after the context

parent 4af52d5e
...@@ -333,22 +333,13 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -333,22 +333,13 @@ static int OpenDecoder( vlc_object_t *p_this )
static void CloseDecoder( vlc_object_t *p_this ) static void CloseDecoder( vlc_object_t *p_this )
{ {
decoder_t *p_dec = (decoder_t *)p_this; decoder_t *p_dec = (decoder_t *)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
switch( p_dec->fmt_out.i_cat ) if( p_dec->fmt_out.i_cat == VIDEO_ES )
{ EndVideoDec( p_dec );
case VIDEO_ES: else
EndVideoDec ( p_dec ); ffmpeg_CloseCodec( p_dec );
break;
}
if( !p_sys->b_delayed_open ) decoder_sys_t *p_sys = p_dec->p_sys;
{
vlc_avcodec_lock();
avcodec_close( p_sys->p_context );
vlc_avcodec_unlock();
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->p_codec->name );
}
av_freep( &p_sys->p_context->extradata ); av_freep( &p_sys->p_context->extradata );
avcodec_free_context( &p_sys->p_context ); avcodec_free_context( &p_sys->p_context );
...@@ -389,3 +380,16 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ) ...@@ -389,3 +380,16 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
p_sys->b_delayed_open = false; p_sys->b_delayed_open = false;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
void ffmpeg_CloseCodec( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->b_delayed_open )
return;
vlc_avcodec_lock();
avcodec_close( p_sys->p_context );
vlc_avcodec_unlock();
msg_Dbg( p_dec, "ffmpeg codec (%s) stopped", p_sys->p_codec->name );
}
...@@ -55,6 +55,7 @@ int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * ); ...@@ -55,6 +55,7 @@ int InitSubtitleDec( decoder_t *, AVCodecContext *, const AVCodec * );
/* Initialize decoder */ /* Initialize decoder */
int ffmpeg_OpenCodec( decoder_t *p_dec ); int ffmpeg_OpenCodec( decoder_t *p_dec );
void ffmpeg_CloseCodec( decoder_t *p_dec );
/***************************************************************************** /*****************************************************************************
* Module descriptor help strings * Module descriptor help strings
......
...@@ -819,6 +819,8 @@ void EndVideoDec( decoder_t *p_dec ) ...@@ -819,6 +819,8 @@ void EndVideoDec( decoder_t *p_dec )
wait_mt( p_sys ); wait_mt( p_sys );
ffmpeg_CloseCodec( p_dec );
if( p_sys->p_ff_pic ) if( p_sys->p_ff_pic )
avcodec_free_frame( &p_sys->p_ff_pic ); avcodec_free_frame( &p_sys->p_ff_pic );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment