/*****************************************************************************
* dvdnav.c: DVD module using the dvdnav library.
*****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2009 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-typedef struct
-{
- VLC_COMMON_MEMBERS
-
- demux_t *p_demux;
- vlc_mutex_t lock;
-
- bool b_still;
- int64_t i_still_end;
-
-} event_thread_t;
-
-static void* EventThread( vlc_object_t * );
-
struct demux_sys_t
{
dvdnav_t *dvdnav;
/* */
bool b_reset_pcr;
+ struct
+ {
+ bool b_created;
+ bool b_enabled;
+ vlc_mutex_t lock;
+ vlc_timer_t timer;
+ } still;
+
/* track */
ps_track_t tk[PS_TK_COUNT];
int i_mux_rate;
/* event */
vlc_object_t *p_vout;
- event_thread_t *p_ev;
/* palette for menus */
uint32_t clut[16];
static int ControlInternal( demux_t *, int, ... );
+static void StillTimer( void * );
+
static int EventKey( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int EventMouse( vlc_object_t *, char const *,
if( dvdnav_title_play( p_sys->dvdnav, 1 ) != DVDNAV_STATUS_OK )
{
msg_Err( p_demux, "cannot set title (can't decrypt DVD?)" );
- dialog_Fatal( p_demux, _("Playback failure"),
+ dialog_Fatal( p_demux, _("Playback failure"), "%s",
_("VLC cannot set the DVD's title. It possibly "
"cannot decrypt the entire disc.") );
dvdnav_close( p_sys->dvdnav );
var_Create( p_sys->p_input, "highlight", VLC_VAR_BOOL );
var_Create( p_sys->p_input, "highlight-mutex", VLC_VAR_MUTEX );
- /* Now create our event thread catcher */
- p_sys->p_ev = vlc_object_create( p_demux, sizeof( event_thread_t ) );
- p_sys->p_ev->p_demux = p_demux;
- vlc_mutex_init( &p_sys->p_ev->lock );
- p_sys->p_ev->b_still = false;
-
/* catch all key event */
var_AddCallback( p_demux->p_libvlc, "key-action", EventKey, p_demux );
/* catch vout creation event */
var_AddCallback( p_sys->p_input, "intf-event", EventIntf, p_demux );
- vlc_thread_create( p_sys->p_ev, "dvdnav event thread handler", EventThread,
- VLC_THREAD_PRIORITY_LOW );
+ p_sys->still.b_enabled = false;
+ vlc_mutex_init( &p_sys->still.lock );
+ if( !vlc_timer_create( &p_sys->still.timer, StillTimer, p_sys ) )
+ p_sys->still.b_created = true;
return VLC_SUCCESS;
}
demux_sys_t *p_sys = p_demux->p_sys;
int i;
+ /* Stop vout event handler */
var_DelCallback( p_sys->p_input, "intf-event", EventIntf, p_demux );
if( p_sys->p_vout != NULL )
{ /* Should not happen, but better be safe than sorry. */
var_DelCallback( p_sys->p_vout, "mouse-clicked", EventMouse, p_demux );
}
- /* stop the event handler */
- vlc_object_kill( p_sys->p_ev );
+ /* Stop key event handler (FIXME: should really be per-vout too) */
var_DelCallback( p_demux->p_libvlc, "key-action", EventKey, p_demux );
- vlc_thread_join( p_sys->p_ev );
- vlc_mutex_destroy( &p_sys->p_ev->lock );
- vlc_object_release( p_sys->p_ev );
+
+ /* Stop still image handler */
+ if( p_sys->still.b_created )
+ vlc_timer_destroy( &p_sys->still.timer );
+ vlc_mutex_destroy( &p_sys->still.lock );
var_Destroy( p_sys->p_input, "highlight-mutex" );
var_Destroy( p_sys->p_input, "highlight" );
switch( i_event )
{
case DVDNAV_BLOCK_OK: /* mpeg block */
- p_sys->p_ev->b_still = false;
+ vlc_mutex_lock( &p_sys->still.lock );
+ p_sys->still.b_enabled = false;
+ vlc_mutex_unlock( &p_sys->still.lock );
if( p_sys->b_reset_pcr )
{
es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
dvdnav_still_event_t *event = (dvdnav_still_event_t*)packet;
bool b_still_init = false;
- vlc_mutex_lock( &p_sys->p_ev->lock );
- if( !p_sys->p_ev->b_still )
+ vlc_mutex_lock( &p_sys->still.lock );
+ if( !p_sys->still.b_enabled )
{
msg_Dbg( p_demux, "DVDNAV_STILL_FRAME" );
msg_Dbg( p_demux, " - length=0x%x", event->length );
- p_sys->p_ev->b_still = true;
+ p_sys->still.b_enabled = true;
+
+ if( event->length != 0xff && p_sys->still.b_created )
+ {
+ mtime_t delay = event->length * CLOCK_FREQ;
+ vlc_timer_schedule( &p_sys->still.timer, false, delay, 0 );
+ }
+
b_still_init = true;
- if( event->length == 0xff )
- p_sys->p_ev->i_still_end = 0;
- else
- p_sys->p_ev->i_still_end = mdate() +
- event->length * INT64_C(1000000);
}
- vlc_mutex_unlock( &p_sys->p_ev->lock );
+ vlc_mutex_unlock( &p_sys->still.lock );
if( b_still_init )
{
if( ( p = strchr( psz_lang, ',' ) ) )
*p = '\0';
- for( pl = p_languages; pl->psz_iso639_1 != NULL; pl++ )
+ for( pl = p_languages; pl->psz_eng_name != NULL; pl++ )
{
if( *psz_lang == '\0' )
continue;
free( psz_lang );
- if( pl->psz_iso639_1 != NULL )
- return strdup( pl->psz_iso639_1 );
+ if( pl->psz_eng_name != NULL )
+ return strdup( pl->psz_eng_name );
return strdup(LANGUAGE_DEFAULT);
}
}
vlc_mutex_lock( p_mutex );
- val.i_int = hl.sx; var_Set( p_sys->p_input, "x-start", val );
- val.i_int = hl.ex; var_Set( p_sys->p_input, "x-end", val );
- val.i_int = hl.sy; var_Set( p_sys->p_input, "y-start", val );
- val.i_int = hl.ey; var_Set( p_sys->p_input, "y-end", val );
+ 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, "y-start", hl.sy );
+ var_SetInteger( p_sys->p_input, "y-end", hl.ey );
- val.p_address = (void *)p_sys->palette;
- var_Set( p_sys->p_input, "menu-palette", val );
+ var_SetAddress( p_sys->p_input, "menu-palette", p_sys->palette );
- val.b_bool = true; var_Set( p_sys->p_input, "highlight", val );
+ var_SetBool( p_sys->p_input, "highlight", true );
vlc_mutex_unlock( p_mutex );
msg_Dbg( p_demux, "buttonUpdate %d", i_button );
/* Show all */
vlc_mutex_lock( p_mutex );
- val.b_bool = false;
- var_Set( p_sys->p_input, "highlight", val );
+ var_SetBool( p_sys->p_input, "highlight", false );
vlc_mutex_unlock( p_mutex );
}
}
}
/*****************************************************************************
- * Event handler code
+ * Still image end
*****************************************************************************/
-static void* EventThread( vlc_object_t *p_this )
+static void StillTimer( void *p_data )
{
- event_thread_t *p_ev = (event_thread_t*)p_this;
- demux_sys_t *p_sys = p_ev->p_demux->p_sys;
- int canc = vlc_savecancel ();
-
- /* main loop */
- while( vlc_object_alive( p_ev ) )
- {
- vlc_mutex_lock( &p_ev->lock );
- /* VOUT part */
-
- /* Still part */
- if( p_ev->b_still )
- {
- if( p_ev->i_still_end > 0 && p_ev->i_still_end < mdate() )
- {
- p_ev->b_still = false;
- dvdnav_still_skip( p_sys->dvdnav );
- }
- }
- vlc_mutex_unlock( &p_ev->lock );
-
- /* Wait a bit */
- msleep( 10000 );
- }
- vlc_restorecancel (canc);
+ demux_sys_t *p_sys = p_data;
- return NULL;
+ vlc_mutex_lock( &p_sys->still.lock );
+ assert( p_sys->still.b_enabled );
+ p_sys->still.b_enabled = false;
+ dvdnav_still_skip( p_sys->dvdnav );
+ vlc_mutex_unlock( &p_sys->still.lock );
}
static int EventMouse( vlc_object_t *p_vout, char const *psz_var,