Commit cd728cd0 authored by Laurent Aimar's avatar Laurent Aimar

Do not use 2 event manager in input.

parent b64c0866
......@@ -673,13 +673,6 @@ static inline int input_AddSubtitle( input_thread_t *p_input, const char *psz_ur
return input_Control( p_input, INPUT_ADD_SUBTITLE, psz_url, b_check_extension );
}
/**
* It will return the input event manager.
*
* You are advised to use "intf-event" instead if you want completness.
*/
VLC_EXPORT( vlc_event_manager_t *, input_GetEventManager, ( input_thread_t * ) );
/* */
typedef struct input_clock_t input_clock_t;
VLC_EXPORT( decoder_t *, input_DecoderNew, ( input_thread_t *, es_format_t *, input_clock_t *, sout_instance_t * ) );
......
......@@ -29,9 +29,6 @@
#include <vlc_vout.h>
#include "libvlc.h"
static void
input_state_changed( const vlc_event_t * event, void * p_userdata );
static int
input_seekable_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
......@@ -83,8 +80,6 @@ static void release_input_thread( libvlc_media_player_t *p_mi )
/* No one is tracking this input_thread appart us. Destroy it */
if( p_mi->b_own_its_input_thread )
{
vlc_event_manager_t * p_em = input_GetEventManager( p_input_thread );
vlc_event_detach( p_em, vlc_InputStateChanged, input_state_changed, p_mi );
var_DelCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
var_DelCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
var_DelCallback( p_input_thread, "intf-event", input_event_changed, p_mi );
......@@ -130,51 +125,6 @@ input_thread_t *libvlc_get_input_thread( libvlc_media_player_t *p_mi,
return p_input_thread;
}
/*
* input_state_changed (Private) (vlc_InputStateChanged callback)
*/
static void
input_state_changed( const vlc_event_t * event, void * p_userdata )
{
libvlc_media_player_t * p_mi = p_userdata;
libvlc_event_t forwarded_event;
libvlc_event_type_t type = event->u.input_state_changed.new_state;
switch ( type )
{
case INIT_S:
libvlc_media_set_state( p_mi->p_md, libvlc_NothingSpecial, NULL);
forwarded_event.type = libvlc_MediaPlayerNothingSpecial;
break;
case OPENING_S:
libvlc_media_set_state( p_mi->p_md, libvlc_Opening, NULL);
forwarded_event.type = libvlc_MediaPlayerOpening;
break;
case PLAYING_S:
libvlc_media_set_state( p_mi->p_md, libvlc_Playing, NULL);
forwarded_event.type = libvlc_MediaPlayerPlaying;
break;
case PAUSE_S:
libvlc_media_set_state( p_mi->p_md, libvlc_Paused, NULL);
forwarded_event.type = libvlc_MediaPlayerPaused;
break;
case END_S:
libvlc_media_set_state( p_mi->p_md, libvlc_Ended, NULL);
forwarded_event.type = libvlc_MediaPlayerEndReached;
break;
case ERROR_S:
libvlc_media_set_state( p_mi->p_md, libvlc_Error, NULL);
forwarded_event.type = libvlc_MediaPlayerEncounteredError;
break;
default:
return;
}
libvlc_event_send( p_mi->p_event_manager, &forwarded_event );
return;
}
static int
input_seekable_changed( vlc_object_t * p_this, char const * psz_cmd,
vlc_value_t oldval, vlc_value_t newval,
......@@ -223,23 +173,61 @@ input_event_changed( vlc_object_t * p_this, char const * psz_cmd,
libvlc_media_player_t * p_mi = p_userdata;
libvlc_event_t event;
if( newval.i_int != INPUT_EVENT_TIMES )
return VLC_EGENERIC;
assert( !strcmp( psz_cmd, "intf-event" ) );
assert( !strcmp(psz_cmd, "intf-event" ) );
if( newval.i_int == INPUT_EVENT_STATE )
{
libvlc_state_t libvlc_state;
if( var_GetInteger( p_input, "state" ) != PLAYING_S )
return VLC_SUCCESS; /* Don't send the position while stopped */
switch ( var_GetInteger( p_input, "state" ) )
{
case INIT_S:
libvlc_state = libvlc_NothingSpecial;
event.type = libvlc_MediaPlayerNothingSpecial;
break;
case OPENING_S:
libvlc_state = libvlc_Opening;
event.type = libvlc_MediaPlayerOpening;
break;
case PLAYING_S:
libvlc_state = libvlc_Playing;
event.type = libvlc_MediaPlayerPlaying;
break;
case PAUSE_S:
libvlc_state = libvlc_Paused;
event.type = libvlc_MediaPlayerPaused;
break;
case END_S:
libvlc_state = libvlc_Ended;
event.type = libvlc_MediaPlayerEndReached;
break;
case ERROR_S:
libvlc_state = libvlc_Error;
event.type = libvlc_MediaPlayerEncounteredError;
break;
default:
return VLC_SUCCESS;
}
/* */
event.type = libvlc_MediaPlayerPositionChanged;
event.u.media_player_position_changed.new_position = var_GetFloat( p_input, "position" );;
libvlc_event_send( p_mi->p_event_manager, &event );
libvlc_media_set_state( p_mi->p_md, libvlc_state, NULL);
libvlc_event_send( p_mi->p_event_manager, &event );
}
else if( newval.i_int == INPUT_EVENT_TIMES )
{
if( var_GetInteger( p_input, "state" ) != PLAYING_S )
return VLC_SUCCESS; /* Don't send the position while stopped */
/* */
event.type = libvlc_MediaPlayerTimeChanged;
event.u.media_player_time_changed.new_time = var_GetTime( p_input, "time" );
libvlc_event_send( p_mi->p_event_manager, &event );
/* */
event.type = libvlc_MediaPlayerPositionChanged;
event.u.media_player_position_changed.new_position = var_GetFloat( p_input, "position" );;
libvlc_event_send( p_mi->p_event_manager, &event );
/* */
event.type = libvlc_MediaPlayerTimeChanged;
event.u.media_player_time_changed.new_time = var_GetTime( p_input, "time" );
libvlc_event_send( p_mi->p_event_manager, &event );
}
return VLC_SUCCESS;
......@@ -611,9 +599,6 @@ void libvlc_media_player_play( libvlc_media_player_t *p_mi,
var_Set( p_input_thread, "drawable", val );
}
vlc_event_manager_t * p_em = input_GetEventManager( p_input_thread );
vlc_event_attach( p_em, vlc_InputStateChanged, input_state_changed, p_mi );
var_AddCallback( p_input_thread, "can-seek", input_seekable_changed, p_mi );
var_AddCallback( p_input_thread, "can-pause", input_pausable_changed, p_mi );
var_AddCallback( p_input_thread, "intf-event", input_event_changed, p_mi );
......
......@@ -147,13 +147,6 @@ void input_SendEventState( input_thread_t *p_input, int i_state )
var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_STATE );
/* FIXME remove this ugliness */
vlc_event_t event;
event.type = vlc_InputStateChanged;
event.u.input_state_changed.new_state = i_state;
vlc_event_send( &p_input->p->event_manager, &event );
}
void input_SendEventCache( input_thread_t *p_input, double f_level )
......@@ -301,11 +294,6 @@ void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL );
Trigger( p_input, INPUT_EVENT_ES );
/* FIXME to remove this ugliness */
vlc_event_t event;
event.type = vlc_InputSelectedStreamChanged;
vlc_event_send( &p_input->p->event_manager, &event );
}
void input_SendEventTeletext( input_thread_t *p_input, int i_id )
......
......@@ -162,12 +162,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input->b_preparsing = b_quick;
p_input->psz_header = psz_header ? strdup( psz_header ) : NULL;
/* Init events */
vlc_event_manager_t * p_em = &p_input->p->event_manager;
vlc_event_manager_init_with_vlc_object( p_em, p_input );
vlc_event_manager_register_event_type( p_em, vlc_InputStateChanged );
vlc_event_manager_register_event_type( p_em, vlc_InputSelectedStreamChanged );
/* Init Common fields */
p_input->b_eof = false;
p_input->b_can_pace_control = true;
......@@ -324,8 +318,6 @@ static void Destructor( input_thread_t * p_input )
free( psz_name );
#endif
vlc_event_manager_fini( &p_input->p->event_manager );
stats_TimerDump( p_input, STATS_TIMER_INPUT_LAUNCHING );
stats_TimerClean( p_input, STATS_TIMER_INPUT_LAUNCHING );
#ifdef ENABLE_SOUT
......@@ -3185,13 +3177,6 @@ void input_UpdateStatistic( input_thread_t *p_input,
}
vlc_mutex_unlock( &p_input->p->counters.counters_lock);
}
/*****************************************************************************
* input_GetEventManager
*****************************************************************************/
vlc_event_manager_t *input_GetEventManager( input_thread_t *p_input )
{
return &p_input->p->event_manager;
}
/**/
/* TODO FIXME nearly the same logic that snapshot code */
......
......@@ -75,9 +75,6 @@ typedef struct
/** Private input fields */
struct input_thread_private_t
{
/* Object's event manager */
vlc_event_manager_t event_manager;
/* Global properties */
bool b_can_pause;
bool b_can_rate_control;
......
......@@ -160,7 +160,6 @@ __input_CreateThread
input_DecoderDecode
input_DecoderDelete
input_DecoderNew
input_GetEventManager
input_GetItem
input_item_AddInfo
input_item_AddOpt
......
......@@ -224,22 +224,24 @@ static void ObjectGarbageCollector( playlist_t *p_playlist, bool b_force )
}
/* Input Callback */
static void input_state_changed( const vlc_event_t * event, void * data )
static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
(void)event;
playlist_t * p_playlist = data;
playlist_Signal( p_playlist );
}
VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
playlist_t *p_playlist = p_data;
/* Input Callback */
static void input_selected_stream_changed( const vlc_event_t * event, void * data )
{
(void)event;
playlist_t * p_playlist = data;
PL_LOCK;
pl_priv(p_playlist)->gc_date = mdate();
vlc_object_signal_unlocked( p_playlist );
PL_UNLOCK;
if( newval.i_int == INPUT_EVENT_STATE )
{
playlist_Signal( p_playlist );
}
else if( newval.i_int == INPUT_EVENT_ES )
{
PL_LOCK;
pl_priv(p_playlist)->gc_date = mdate();
vlc_object_signal_unlocked( p_playlist );
PL_UNLOCK;
}
return VLC_SUCCESS;
}
/* Internals */
......@@ -250,12 +252,8 @@ void playlist_release_current_input( playlist_t * p_playlist )
if( !pl_priv(p_playlist)->p_input ) return;
input_thread_t * p_input = pl_priv(p_playlist)->p_input;
vlc_event_manager_t * p_em = input_GetEventManager( p_input );
vlc_event_detach( p_em, vlc_InputStateChanged,
input_state_changed, p_playlist );
vlc_event_detach( p_em, vlc_InputSelectedStreamChanged,
input_selected_stream_changed, p_playlist );
var_DelCallback( p_input, "intf-event", InputEvent, p_playlist );
pl_priv(p_playlist)->p_input = NULL;
/* Release the playlist lock, because we may get stuck
......@@ -277,11 +275,8 @@ void playlist_set_current_input(
{
vlc_object_hold( p_input );
pl_priv(p_playlist)->p_input = p_input;
vlc_event_manager_t * p_em = input_GetEventManager( p_input );
vlc_event_attach( p_em, vlc_InputStateChanged,
input_state_changed, p_playlist );
vlc_event_attach( p_em, vlc_InputSelectedStreamChanged,
input_selected_stream_changed, p_playlist );
var_AddCallback( p_input, "intf-event", InputEvent, p_playlist );
}
}
......
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