Commit a091bf72 authored by Rémi Duraffort's avatar Rémi Duraffort

codec_fake: Fix potential crash (add and delete the callback at the right

moment).
(cherry picked from commit 7261448e)
Signed-off-by: default avatarRémi Duraffort <ivoire@videolan.org>
parent 48b4a9cc
...@@ -154,7 +154,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -154,7 +154,6 @@ static int OpenDecoder( vlc_object_t *p_this )
free( p_dec->p_sys ); free( p_dec->p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
var_AddCallback( p_dec, "fake-file", FakeCallback, p_dec );
memset( &fmt_in, 0, sizeof(fmt_in) ); memset( &fmt_in, 0, sizeof(fmt_in) );
memset( &fmt_out, 0, sizeof(fmt_out) ); memset( &fmt_out, 0, sizeof(fmt_out) );
...@@ -166,7 +165,6 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -166,7 +165,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->p_sys->i_reload = (mtime_t)(val.i_int * 1000000); p_dec->p_sys->i_reload = (mtime_t)(val.i_int * 1000000);
p_dec->p_sys->i_next = (mtime_t)(p_dec->p_sys->i_reload + mdate()); p_dec->p_sys->i_next = (mtime_t)(p_dec->p_sys->i_reload + mdate());
} }
var_AddCallback( p_dec, "fake-file-reload", FakeCallback , p_dec );
psz_chroma = var_CreateGetString( p_dec, "fake-chroma" ); psz_chroma = var_CreateGetString( p_dec, "fake-chroma" );
if( strlen( psz_chroma ) != 4 ) if( strlen( psz_chroma ) != 4 )
...@@ -330,6 +328,10 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -330,6 +328,10 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec->p_sys->p_image = p_image; p_dec->p_sys->p_image = p_image;
vlc_mutex_init( &p_dec->p_sys->lock ); vlc_mutex_init( &p_dec->p_sys->lock );
/* Add the callback when every variables are available */
var_AddCallback( p_dec, "fake-file", FakeCallback, p_dec );
var_AddCallback( p_dec, "fake-file-reload", FakeCallback , p_dec );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -376,6 +378,9 @@ static void CloseDecoder( vlc_object_t *p_this ) ...@@ -376,6 +378,9 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_t *p_dec = (decoder_t *)p_this; decoder_t *p_dec = (decoder_t *)p_this;
picture_t *p_image = p_dec->p_sys->p_image; picture_t *p_image = p_dec->p_sys->p_image;
var_DelCallback( p_dec, "fake-file", FakeCallback, p_dec );
var_DelCallback( p_dec, "fake-file-reload", FakeCallback , p_dec );
if( p_image != NULL ) if( p_image != NULL )
picture_Release( p_image ); picture_Release( p_image );
......
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