static void watch_toggled( DBusWatch *p_watch, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*) p_data; if( dbus_watch_get_enabled( p_watch ) ) wakeup_main_loop( p_intf ); }
static void timeout_toggled( DBusTimeout *p_timeout, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*) p_data; if( dbus_timeout_get_enabled( p_timeout ) ) wakeup_main_loop( p_intf ); }
// Get all the callbacks static int AllCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { intf_thread_t *p_intf = p_data; callback_info_t info = { .signal = SIGNAL_NONE }; // Wich event is it ? if( !strcmp( "input-current", psz_var ) ) info.signal = SIGNAL_ITEM_CURRENT; else if( !strcmp( "volume", psz_var ) ) { if( oldval.f_float != newval.f_float ) info.signal = SIGNAL_VOLUME_CHANGE; } else if( !strcmp( "mute", psz_var ) ) { if( oldval.b_bool != newval.b_bool ) info.signal = SIGNAL_VOLUME_MUTED; } else if( !strcmp( "playlist-item-append", psz_var ) ) info.signal = SIGNAL_PLAYLIST_ITEM_APPEND; else if( !strcmp( "playlist-item-deleted", psz_var ) ) info.signal = SIGNAL_PLAYLIST_ITEM_DELETED; else if( !strcmp( "random", psz_var ) ) info.signal = SIGNAL_RANDOM; else if( !strcmp( "fullscreen", psz_var ) ) info.signal = SIGNAL_FULLSCREEN; else if( !strcmp( "repeat", psz_var ) ) info.signal = SIGNAL_REPEAT; else if( !strcmp( "loop", psz_var ) ) info.signal = SIGNAL_LOOP; else if( !strcmp( "can-seek", psz_var ) ) info.signal = SIGNAL_CAN_SEEK; else if( !strcmp( "can-pause", psz_var ) ) info.signal = SIGNAL_CAN_PAUSE; else vlc_assert_unreachable(); if( info.signal == SIGNAL_NONE ) return VLC_SUCCESS; callback_info_t *p_info = malloc( sizeof( *p_info ) ); if( unlikely(p_info == NULL) ) return VLC_ENOMEM; // Append the event *p_info = info; vlc_mutex_lock( &p_intf->p_sys->lock ); vlc_array_append( p_intf->p_sys->p_events, p_info ); vlc_mutex_unlock( &p_intf->p_sys->lock ); wakeup_main_loop( p_intf ); (void) p_this; return VLC_SUCCESS; }
static void timeout_toggled( DBusTimeout *p_timeout, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*) p_data; msg_Dbg( p_intf, "Toggling dbus timeout" ); if( dbus_timeout_get_enabled( p_timeout ) ) { msg_Dbg( p_intf, "Timeout is enabled, main loop needs to wake up" ); wakeup_main_loop( p_intf ); } }
static void toggle_timeout(DBusTimeout *to, void *data) { intf_thread_t *intf = data; intf_sys_t *sys = intf->p_sys; mtime_t *expiry = dbus_timeout_get_data(to); vlc_mutex_lock(&sys->lock); if (dbus_timeout_get_enabled(to)) *expiry = mdate() + UINT64_C(1000) * dbus_timeout_get_interval(to); vlc_mutex_unlock(&sys->lock); wakeup_main_loop(intf); }
static void watch_toggled( DBusWatch *p_watch, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t*) p_data; msg_Dbg( p_intf, "Toggling dbus watch on fd %d", dbus_watch_get_unix_fd( p_watch ) ); if( dbus_watch_get_enabled( p_watch ) ) { msg_Dbg( p_intf, "Watch on fd %d has been enabled, " "the main loops needs to wake up", dbus_watch_get_unix_fd( p_watch ) ); wakeup_main_loop( p_intf ); } }
// Get all the callbacks static int AllCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { (void)p_this; (void)oldval; intf_thread_t *p_intf = (intf_thread_t*)p_data; callback_info_t *info = calloc( 1, sizeof( callback_info_t ) ); if( !info ) return VLC_ENOMEM; vlc_mutex_lock( &p_intf->p_sys->lock ); // Wich event is it ? if( !strcmp( "item-current", psz_var ) ) info->signal = SIGNAL_ITEM_CURRENT; else if( !strcmp( "intf-change", psz_var ) ) info->signal = SIGNAL_INTF_CHANGE; else if( !strcmp( "playlist-item-append", psz_var ) ) { info->signal = SIGNAL_PLAYLIST_ITEM_APPEND; info->i_node = ((playlist_add_t*)newval.p_address)->i_node; } else if( !strcmp( "playlist-item-deleted", psz_var ) ) info->signal = SIGNAL_PLAYLIST_ITEM_DELETED; else if( !strcmp( "random", psz_var ) ) info->signal = SIGNAL_RANDOM; else if( !strcmp( "repeat", psz_var ) ) info->signal = SIGNAL_REPEAT; else if( !strcmp( "loop", psz_var ) ) info->signal = SIGNAL_LOOP; else if( !strcmp( "intf-event", psz_var ) ) { int i_res; i_res = InputIntfEventCallback( p_intf, p_this, newval.i_int, info ); if( VLC_SUCCESS != i_res ) { vlc_mutex_unlock( &p_intf->p_sys->lock ); free( info ); return i_res; } } else assert(0); // Append the event vlc_array_append( p_intf->p_sys->p_events, info ); vlc_mutex_unlock( &p_intf->p_sys->lock ); msg_Dbg( p_intf, "Got a VLC event on %s. The main loop needs to wake up " "in order to process it", psz_var ); wakeup_main_loop( p_intf ); return VLC_SUCCESS; }
/* Flls a callback_info_t data structure in response * to an "intf-event" input event. * * @warning This function executes in the input thread. * * @return VLC_SUCCESS on success, VLC_E* on error. */ static int InputCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *data ) { input_thread_t *p_input = (input_thread_t *)p_this; intf_thread_t *p_intf = data; intf_sys_t *p_sys = p_intf->p_sys; dbus_int32_t i_state = PLAYBACK_STATE_INVALID; callback_info_t *p_info = calloc( 1, sizeof( callback_info_t ) ); if( unlikely(p_info == NULL) ) return VLC_ENOMEM; switch( newval.i_int ) { case INPUT_EVENT_DEAD: i_state = PLAYBACK_STATE_STOPPED; break; case INPUT_EVENT_STATE: switch( var_GetInteger( p_input, "state" ) ) { case OPENING_S: case PLAYING_S: i_state = PLAYBACK_STATE_PLAYING; break; case PAUSE_S: i_state = PLAYBACK_STATE_PAUSED; break; default: i_state = PLAYBACK_STATE_STOPPED; } break; case INPUT_EVENT_ITEM_META: p_info->signal = SIGNAL_INPUT_METADATA; break; case INPUT_EVENT_RATE: p_info->signal = SIGNAL_RATE; break; case INPUT_EVENT_POSITION: { mtime_t i_now = mdate(), i_pos, i_projected_pos, i_interval; float f_current_rate; /* Detect seeks * XXX: This is way more convoluted than it should be... */ i_pos = var_GetInteger( p_input, "time" ); if( !p_intf->p_sys->i_last_input_pos_event || !( var_GetInteger( p_input, "state" ) == PLAYING_S ) ) { p_intf->p_sys->i_last_input_pos_event = i_now; p_intf->p_sys->i_last_input_pos = i_pos; break; } f_current_rate = var_GetFloat( p_input, "rate" ); i_interval = ( i_now - p_intf->p_sys->i_last_input_pos_event ); i_projected_pos = p_intf->p_sys->i_last_input_pos + ( i_interval * f_current_rate ); p_intf->p_sys->i_last_input_pos_event = i_now; p_intf->p_sys->i_last_input_pos = i_pos; if( llabs( i_pos - i_projected_pos ) < SEEK_THRESHOLD ) break; p_info->signal = SIGNAL_SEEK; break; } default: free( p_info ); return VLC_SUCCESS; /* don't care */ } vlc_mutex_lock( &p_sys->lock ); if( i_state != PLAYBACK_STATE_INVALID && i_state != p_sys->i_playing_state ) { p_sys->i_playing_state = i_state; p_info->signal = SIGNAL_STATE; } if( p_info->signal ) vlc_array_append( p_intf->p_sys->p_events, p_info ); else free( p_info ); vlc_mutex_unlock( &p_intf->p_sys->lock ); wakeup_main_loop( p_intf ); (void)psz_var; (void)oldval; return VLC_SUCCESS; }
// Get all the callbacks static int AllCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { (void)p_this; (void)oldval; intf_thread_t *p_intf = (intf_thread_t*)p_data; callback_info_t *info = calloc( 1, sizeof( callback_info_t ) ); if( !info ) return VLC_ENOMEM; vlc_mutex_lock( &p_intf->p_sys->lock ); // Wich event is it ? if( !strcmp( "item-current", psz_var ) ) info->signal = SIGNAL_ITEM_CURRENT; else if( !strcmp( "volume", psz_var ) ) info->signal = SIGNAL_VOLUME_CHANGE; else if( !strcmp( "mute", psz_var ) ) info->signal = SIGNAL_VOLUME_MUTED; else if( !strcmp( "intf-change", psz_var ) ) info->signal = SIGNAL_INTF_CHANGE; else if( !strcmp( "playlist-item-append", psz_var ) ) { info->signal = SIGNAL_PLAYLIST_ITEM_APPEND; info->i_node = ((playlist_add_t*)newval.p_address)->i_node; } else if( !strcmp( "playlist-item-deleted", psz_var ) ) info->signal = SIGNAL_PLAYLIST_ITEM_DELETED; else if( !strcmp( "random", psz_var ) ) info->signal = SIGNAL_RANDOM; else if( !strcmp( "fullscreen", psz_var ) ) info->signal = SIGNAL_FULLSCREEN; else if( !strcmp( "repeat", psz_var ) ) info->signal = SIGNAL_REPEAT; else if( !strcmp( "loop", psz_var ) ) info->signal = SIGNAL_LOOP; else if( !strcmp( "intf-event", psz_var ) ) { int i_res = InputIntfEventCallback( p_intf, (input_thread_t*) p_this, newval.i_int, info ); if( VLC_SUCCESS != i_res ) { vlc_mutex_unlock( &p_intf->p_sys->lock ); free( info ); return i_res; } } else if( !strcmp( "can-seek", psz_var ) ) info->signal = SIGNAL_CAN_SEEK; else if( !strcmp( "can-pause", psz_var ) ) info->signal = SIGNAL_CAN_PAUSE; else assert(0); // Append the event vlc_array_append( p_intf->p_sys->p_events, info ); vlc_mutex_unlock( &p_intf->p_sys->lock ); wakeup_main_loop( p_intf ); return VLC_SUCCESS; }