[vlc-commits] postproc: reduce lock contention in callback
Rémi Denis-Courmont
git at videolan.org
Thu Jul 24 18:12:07 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 24 19:11:27 2014 +0300| [404b15a65beb71e9a2d87f95064441cb9f46c155] | committer: Rémi Denis-Courmont
postproc: reduce lock contention in callback
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=404b15a65beb71e9a2d87f95064441cb9f46c155
---
modules/video_filter/postproc.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c
index 3ee8882..454c79c 100644
--- a/modules/video_filter/postproc.c
+++ b/modules/video_filter/postproc.c
@@ -331,28 +331,27 @@ static void PPChangeMode( filter_t *p_filter, const char *psz_name,
int i_quality )
{
filter_sys_t *p_sys = p_filter->p_sys;
+ pp_mode *newmode = NULL, *oldmode;
+
vlc_mutex_lock( &p_sys->lock );
if( i_quality > 0 )
{
- pp_mode *pp_mode = pp_get_mode_by_name_and_quality( psz_name ?
- psz_name :
- "default",
- i_quality );
- if( pp_mode )
- {
- pp_free_mode( p_sys->pp_mode );
- p_sys->pp_mode = pp_mode;
+ newmode = pp_get_mode_by_name_and_quality( psz_name ? psz_name :
+ "default", i_quality );
+ if( newmode == NULL )
+ {
+ msg_Warn( p_filter, "Error while changing post processing mode. "
+ "Keeping previous mode." );
+ return;
}
- else
- msg_Warn( p_filter, "Error while changing post processing mode. "
- "Keeping previous mode." );
- }
- else
- {
- pp_free_mode( p_sys->pp_mode );
- p_sys->pp_mode = NULL;
}
+
+ vlc_mutex_lock( &p_sys->lock );
+ oldmode = p_sys->pp_mode;
+ p_sys->pp_mode = newmode;
vlc_mutex_unlock( &p_sys->lock );
+
+ pp_free_mode( oldmode );
}
static int PPQCallback( vlc_object_t *p_this, const char *psz_var,
More information about the vlc-commits
mailing list