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

Convert highlight to global mutex

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent e4b0862f
...@@ -481,6 +481,7 @@ enum { ...@@ -481,6 +481,7 @@ enum {
VLC_GCRYPT_MUTEX, VLC_GCRYPT_MUTEX,
VLC_XLIB_MUTEX, VLC_XLIB_MUTEX,
VLC_MOSAIC_MUTEX, VLC_MOSAIC_MUTEX,
VLC_HIGHLIGHT_MUTEX,
/* Insert new entry HERE */ /* Insert new entry HERE */
VLC_MAX_MUTEX VLC_MAX_MUTEX
}; };
......
...@@ -368,7 +368,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -368,7 +368,6 @@ static int Open( vlc_object_t *p_this )
var_Create( p_sys->p_input, "color", VLC_VAR_ADDRESS ); var_Create( p_sys->p_input, "color", VLC_VAR_ADDRESS );
var_Create( p_sys->p_input, "menu-palette", VLC_VAR_ADDRESS ); var_Create( p_sys->p_input, "menu-palette", VLC_VAR_ADDRESS );
var_Create( p_sys->p_input, "highlight", VLC_VAR_BOOL ); var_Create( p_sys->p_input, "highlight", VLC_VAR_BOOL );
var_Create( p_sys->p_input, "highlight-mutex", VLC_VAR_MUTEX );
/* catch all key event */ /* catch all key event */
var_AddCallback( p_demux->p_libvlc, "key-action", EventKey, p_demux ); var_AddCallback( p_demux->p_libvlc, "key-action", EventKey, p_demux );
...@@ -408,7 +407,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -408,7 +407,6 @@ static void Close( vlc_object_t *p_this )
vlc_timer_destroy( p_sys->still.timer ); vlc_timer_destroy( p_sys->still.timer );
vlc_mutex_destroy( &p_sys->still.lock ); vlc_mutex_destroy( &p_sys->still.lock );
var_Destroy( p_sys->p_input, "highlight-mutex" );
var_Destroy( p_sys->p_input, "highlight" ); var_Destroy( p_sys->p_input, "highlight" );
var_Destroy( p_sys->p_input, "x-start" ); var_Destroy( p_sys->p_input, "x-start" );
var_Destroy( p_sys->p_input, "x-end" ); var_Destroy( p_sys->p_input, "x-end" );
...@@ -1050,9 +1048,6 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode ) ...@@ -1050,9 +1048,6 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part ); dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part );
if( var_Get( p_sys->p_input, "highlight-mutex", &val ) == VLC_SUCCESS )
{
vlc_mutex_t *p_mutex = val.p_address;
dvdnav_highlight_area_t hl; dvdnav_highlight_area_t hl;
int32_t i_button; int32_t i_button;
bool b_button_ok; bool b_button_ok;
...@@ -1075,8 +1070,7 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode ) ...@@ -1075,8 +1070,7 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
if( b_button_ok ) if( b_button_ok )
{ {
int i; for( unsigned i = 0; i < 4; i++ )
for( i = 0; i < 4; i++ )
{ {
uint32_t i_yuv = p_sys->clut[(hl.palette>>(16+i*4))&0x0f]; uint32_t i_yuv = p_sys->clut[(hl.palette>>(16+i*4))&0x0f];
uint8_t i_alpha = ( (hl.palette>>(i*4))&0x0f ) * 0xff / 0xf; uint8_t i_alpha = ( (hl.palette>>(i*4))&0x0f ) * 0xff / 0xf;
...@@ -1087,16 +1081,14 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode ) ...@@ -1087,16 +1081,14 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
p_sys->palette[i][3] = i_alpha; p_sys->palette[i][3] = i_alpha;
} }
vlc_mutex_lock( p_mutex ); vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
var_SetInteger( p_sys->p_input, "x-start", hl.sx ); var_SetInteger( p_sys->p_input, "x-start", hl.sx );
var_SetInteger( p_sys->p_input, "x-end", hl.ex ); var_SetInteger( p_sys->p_input, "x-end", hl.ex );
var_SetInteger( p_sys->p_input, "y-start", hl.sy ); var_SetInteger( p_sys->p_input, "y-start", hl.sy );
var_SetInteger( p_sys->p_input, "y-end", hl.ey ); var_SetInteger( p_sys->p_input, "y-end", hl.ey );
var_SetAddress( p_sys->p_input, "menu-palette", p_sys->palette ); var_SetAddress( p_sys->p_input, "menu-palette", p_sys->palette );
var_SetBool( p_sys->p_input, "highlight", true ); var_SetBool( p_sys->p_input, "highlight", true );
vlc_mutex_unlock( p_mutex );
msg_Dbg( p_demux, "buttonUpdate %d", i_button ); msg_Dbg( p_demux, "buttonUpdate %d", i_button );
} }
...@@ -1106,11 +1098,10 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode ) ...@@ -1106,11 +1098,10 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
i_button, i_title ); i_button, i_title );
/* Show all */ /* Show all */
vlc_mutex_lock( p_mutex ); vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
var_SetBool( p_sys->p_input, "highlight", false ); var_SetBool( p_sys->p_input, "highlight", false );
vlc_mutex_unlock( p_mutex );
}
} }
vlc_global_unlock( VLC_HIGHLIGHT_MUTEX );
} }
static void ESSubtitleUpdate( demux_t *p_demux ) static void ESSubtitleUpdate( demux_t *p_demux )
......
...@@ -345,11 +345,6 @@ void event_thread_t::EventThread() ...@@ -345,11 +345,6 @@ void event_thread_t::EventThread()
// select new button // select new button
if ( best != i_curr_button ) if ( best != i_curr_button )
{ {
vlc_value_t val;
if( var_Get( p_sys->p_input, "highlight-mutex", &val ) == VLC_SUCCESS )
{
vlc_mutex_t *p_mutex = (vlc_mutex_t *) val.p_address;
uint32_t i_palette; uint32_t i_palette;
if(button_ptr.btn_coln != 0) { if(button_ptr.btn_coln != 0) {
...@@ -370,18 +365,19 @@ void event_thread_t::EventThread() ...@@ -370,18 +365,19 @@ void event_thread_t::EventThread()
p_sys->palette[i][3] = i_alpha; p_sys->palette[i][3] = i_alpha;
} }
vlc_mutex_lock( p_mutex ); vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
val.i_int = button_ptr.x_start; var_Set( p_sys->p_input, "x-start", val ); var_SetInteger( p_sys->p_input, "x-start",
val.i_int = button_ptr.x_end; var_Set( p_sys->p_input, "x-end", val ); button_ptr.x_start );
val.i_int = button_ptr.y_start; var_Set( p_sys->p_input, "y-start", val ); var_SetInteger( p_sys->p_input, "x-end",
val.i_int = button_ptr.y_end; var_Set( p_sys->p_input, "y-end", val ); button_ptr.x_end );
var_SetInteger( p_sys->p_input, "y-start",
val.p_address = (void *)p_sys->palette; button_ptr.y_start );
var_Set( p_sys->p_input, "menu-palette", val ); var_SetInteger( p_sys->p_input, "y-end",
button_ptr.y_end );
val.b_bool = true; var_Set( p_sys->p_input, "highlight", val ); var_SetAddress( p_sys->p_input, "menu-palette",
vlc_mutex_unlock( p_mutex ); p_sys->palette );
} var_SetBool( p_sys->p_input, "highlight", true );
vlc_global_unlock( VLC_HIGHLIGHT_MUTEX );
} }
vlc_mutex_unlock( &p_sys->lock_demuxer ); vlc_mutex_unlock( &p_sys->lock_demuxer );
vlc_mutex_lock( &lock ); vlc_mutex_lock( &lock );
...@@ -601,7 +597,6 @@ void demux_sys_t::InitUi() ...@@ -601,7 +597,6 @@ void demux_sys_t::InitUi()
var_Create( p_input, "color", VLC_VAR_ADDRESS ); var_Create( p_input, "color", VLC_VAR_ADDRESS );
var_Create( p_input, "menu-palette", VLC_VAR_ADDRESS ); var_Create( p_input, "menu-palette", VLC_VAR_ADDRESS );
var_Create( p_input, "highlight", VLC_VAR_BOOL ); var_Create( p_input, "highlight", VLC_VAR_BOOL );
var_Create( p_input, "highlight-mutex", VLC_VAR_MUTEX );
} }
/* Now create our event thread catcher */ /* Now create our event thread catcher */
...@@ -615,7 +610,6 @@ void demux_sys_t::CleanUi() ...@@ -615,7 +610,6 @@ void demux_sys_t::CleanUi()
if( p_input ) if( p_input )
{ {
var_Destroy( p_input, "highlight-mutex" );
var_Destroy( p_input, "highlight" ); var_Destroy( p_input, "highlight" );
var_Destroy( p_input, "x-start" ); var_Destroy( p_input, "x-start" );
var_Destroy( p_input, "x-end" ); var_Destroy( p_input, "x-end" );
......
...@@ -41,6 +41,7 @@ void vlc_global_mutex (unsigned n, bool acquire) ...@@ -41,6 +41,7 @@ void vlc_global_mutex (unsigned n, bool acquire)
VLC_STATIC_MUTEX, VLC_STATIC_MUTEX,
VLC_STATIC_MUTEX, VLC_STATIC_MUTEX,
VLC_STATIC_MUTEX, VLC_STATIC_MUTEX,
VLC_STATIC_MUTEX,
}; };
assert (n < (sizeof (locks) / sizeof (locks[0]))); assert (n < (sizeof (locks) / sizeof (locks[0])));
vlc_mutex_t *lock = locks + n; vlc_mutex_t *lock = locks + n;
......
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