Commit c9e0e4e1 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

control/event.c: Send position event at a reasonable time precision.

parent da48f25f
...@@ -39,19 +39,23 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd, ...@@ -39,19 +39,23 @@ static int handle_event( vlc_object_t *p_this, char const *psz_cmd,
* facility for p_data */ * facility for p_data */
struct libvlc_callback_entry_t *entry = p_data; struct libvlc_callback_entry_t *entry = p_data;
libvlc_event_t event; libvlc_event_t event;
event.type = entry->i_event_type; event.type = entry->i_event_type;
switch ( event.type )
if (event.type == INPUT_POSITION_CHANGED && !strcmp(psz_cmd, "intf-change"))
{ {
case VOLUME_CHANGED: input_thread_t * p_input = (input_thread_t *)p_this;
event.value_type = BOOLEAN_EVENT; vlc_value_t val;
break; var_Get( p_input, "position", &val );
case INPUT_POSITION_CHANGED:
break; /* Only send event at a reasonable time precision (500ms) */
default: /* (FIXME: this should be configurable) */
break; if ((val.i_time % I64C(500000)) != 0)
{
/* Don't send this event */
return VLC_SUCCESS;
}
} }
event.old_value = oldval;
event.new_value = newval;
/* Call the client entry */ /* Call the client entry */
entry->f_callback( entry->p_instance, &event, entry->p_user_data ); entry->f_callback( entry->p_instance, &event, entry->p_user_data );
...@@ -95,6 +99,7 @@ static int install_input_event( vlc_object_t *p_this, char const *psz_cmd, ...@@ -95,6 +99,7 @@ static int install_input_event( vlc_object_t *p_this, char const *psz_cmd,
/* FIXME: here we shouldn't listen on intf-change, we have to provide /* FIXME: here we shouldn't listen on intf-change, we have to provide
* in vlc core a more accurate callback */ * in vlc core a more accurate callback */
var_AddCallback( p_input, "intf-change", handle_event, p_listitem->elmt ); var_AddCallback( p_input, "intf-change", handle_event, p_listitem->elmt );
var_AddCallback( p_input, "position", handle_event, p_listitem->elmt );
} }
} }
...@@ -144,6 +149,8 @@ static int remove_variable_callback( libvlc_instance_t *p_instance, ...@@ -144,6 +149,8 @@ static int remove_variable_callback( libvlc_instance_t *p_instance,
* will be a no-op */ * will be a no-op */
var_DelCallback( p_input, "intf-change", var_DelCallback( p_input, "intf-change",
handle_event, p_entry ); handle_event, p_entry );
var_DelCallback( p_input, "position",
handle_event, p_entry );
break; break;
} }
......
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