Commit 8ce688cb authored by Sam Hocevar's avatar Sam Hocevar

* ./modules/gui/ncurses/ncurses.c: added locks and checks in navigation code.

parent c39a74a5
/*****************************************************************************
* ncurses.c : NCurses plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ncurses.c,v 1.2 2002/08/08 22:28:22 sam Exp $
* Copyright (C) 2001, 2002, 2003 VideoLAN
* $Id: ncurses.c,v 1.3 2003/01/17 19:36:53 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -92,7 +92,7 @@ static int Open( vlc_object_t *p_this )
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return( 1 );
return VLC_ENOMEM;
}
p_intf->p_sys->p_input = NULL;
......@@ -113,7 +113,7 @@ static int Open( vlc_object_t *p_this )
clear();
return( 0 );
return VLC_SUCCESS;
}
/*****************************************************************************
......@@ -273,7 +273,7 @@ static int PrintFullLine ( const char *p_fmt, ... )
if ( p_buf == NULL )
{
return ( -1 );
return -1;
}
i_len = strlen( p_buf );
......@@ -505,20 +505,22 @@ static void Stop ( intf_thread_t *p_intf )
static void Next ( intf_thread_t *p_intf )
{
int i_id;
input_area_t * p_area;
int i_id;
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id+1;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;
if ( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
{
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input,
(input_area_t *) p_area );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
static void ManageSlider ( intf_thread_t *p_intf )
......@@ -569,16 +571,19 @@ static void PrevTitle ( intf_thread_t *p_intf )
input_area_t * p_area;
int i_id;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1;
/* Disallow area 0 since it is used for video_ts.vob */
if ( i_id > 0 )
{
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
static void NextTitle ( intf_thread_t *p_intf )
......@@ -586,44 +591,56 @@ static void NextTitle ( intf_thread_t *p_intf )
input_area_t * p_area;
int i_id;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1;
if ( i_id < p_intf->p_sys->p_input->stream.i_area_nb )
{
p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id];
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
static void PrevChapter ( intf_thread_t *p_intf )
{
input_area_t * p_area;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if ( p_area->i_part > 0 )
{
p_area->i_part--;
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
static void NextChapter( intf_thread_t *p_intf )
{
input_area_t * p_area;
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_area = p_intf->p_sys->p_input->stream.p_selected_area;
if ( p_area->i_part < p_area->i_part_nb )
{
p_area->i_part++;
input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
input_ChangeArea( p_intf->p_sys->p_input, p_area );
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
}
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
}
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