static aout_instance_t *RequestAout( input_resource_t *p_resource, aout_instance_t *p_aout ) { vlc_assert_locked( &p_resource->lock ); assert( p_resource->p_input ); if( p_aout ) { msg_Dbg( p_resource->p_parent, "releasing aout" ); vlc_object_release( p_aout ); return NULL; } else { p_aout = p_resource->p_aout; if( !p_aout ) { msg_Dbg( p_resource->p_parent, "creating aout" ); p_aout = aout_New( p_resource->p_parent ); vlc_mutex_lock( &p_resource->lock_hold ); p_resource->p_aout = p_aout; vlc_mutex_unlock( &p_resource->lock_hold ); } else { msg_Dbg( p_resource->p_parent, "reusing aout" ); } if( !p_aout ) return NULL; vlc_object_hold( p_aout ); return p_aout; } }
static void HoldVouts( input_resource_t *p_resource, vout_thread_t ***ppp_vout, size_t *pi_vout ) { vout_thread_t **pp_vout; *pi_vout = 0; *ppp_vout = NULL; vlc_mutex_lock( &p_resource->lock_hold ); if( p_resource->i_vout <= 0 ) goto exit; pp_vout = malloc( p_resource->i_vout * sizeof(*pp_vout) ); if( !pp_vout ) goto exit; *ppp_vout = pp_vout; *pi_vout = p_resource->i_vout; for( int i = 0; i < p_resource->i_vout; i++ ) { pp_vout[i] = p_resource->pp_vout[i]; vlc_object_hold( pp_vout[i] ); } exit: vlc_mutex_unlock( &p_resource->lock_hold ); }
static int vlclua_get_libvlc( lua_State *L ) { libvlc_int_t *p_libvlc = vlclua_get_this( L )->obj.libvlc; vlc_object_hold( p_libvlc ); vlclua_push_vlc_object( L, p_libvlc ); return 1; }
// Callbacks for vout requests static int WindowOpen( vlc_object_t *p_this ) { int i_ret; vout_window_t *pWnd = (vout_window_t *)p_this; vlc_mutex_lock( &skin_load.mutex ); intf_thread_t *pIntf = skin_load.intf; if( pIntf ) vlc_object_hold( pIntf ); vlc_mutex_unlock( &skin_load.mutex ); if( pIntf == NULL ) return VLC_EGENERIC; vlc_mutex_lock( &serializer ); pWnd->handle.hwnd = VoutManager::getWindow( pIntf, pWnd ); if( pWnd->handle.hwnd ) { pWnd->control = &VoutManager::controlWindow; pWnd->sys = (vout_window_sys_t*)pIntf; vlc_mutex_unlock( &serializer ); return VLC_SUCCESS; } else { vlc_object_release( pIntf ); vlc_mutex_unlock( &serializer ); return VLC_EGENERIC; } }
static int VarsCommand (vlc_object_t *obj, char const *cmd, vlc_value_t oldval, vlc_value_t newval, void *data) { void *p; (void) cmd; (void) oldval; (void) data; if (sscanf (newval.psz_string, "%p", &p) == 1) { p = ObjectExists (obj, p); if (p == NULL) { msg_Err (obj, "no such object: %s", newval.psz_string); return VLC_ENOOBJ; } obj = p; } else vlc_object_hold (obj); PrintObject (obj, ""); DumpVariables (obj); vlc_object_release (obj); return VLC_SUCCESS; }
/// Callback for the systray configuration option static int onTaskBarChange( vlc_object_t *pObj, const char *pVariable, vlc_value_t oldVal, vlc_value_t newVal, void *pParam ) { intf_thread_t *pIntf; vlc_mutex_lock( &skin_load.mutex ); pIntf = skin_load.intf; if( pIntf ) vlc_object_hold( pIntf ); vlc_mutex_unlock( &skin_load.mutex ); if( pIntf == NULL ) { return VLC_EGENERIC; } AsyncQueue *pQueue = AsyncQueue::instance( pIntf ); if( newVal.b_bool ) { CmdAddInTaskBar *pCmd = new CmdAddInTaskBar( pIntf ); pQueue->push( CmdGenericPtr( pCmd ) ); } else { CmdRemoveFromTaskBar *pCmd = new CmdRemoveFromTaskBar( pIntf ); pQueue->push( CmdGenericPtr( pCmd ) ); } vlc_object_release( pIntf ); return VLC_SUCCESS; }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); } else { p_input = NULL; p_item = NULL; assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
static aout_instance_t *AllocateAout( input_resource_t *p_resource ) { aout_instance_t *p_aout; if( unlikely(p_resource->b_aout_busy) ) { msg_Dbg( p_resource->p_parent, "creating audio output" ); return aout_New( p_resource->p_parent ); } p_aout = p_resource->p_aout; if( p_aout == NULL ) { msg_Dbg( p_resource->p_parent, "creating audio output" ); p_aout = aout_New( p_resource->p_parent ); if( unlikely(p_aout == NULL) ) return NULL; vlc_mutex_lock( &p_resource->lock_hold ); p_resource->p_aout = p_aout; vlc_mutex_unlock( &p_resource->lock_hold ); } else msg_Dbg( p_resource->p_parent, "recycling audio output" ); p_resource->b_aout_busy = true; vlc_object_hold( p_aout ); return p_aout; }
/** * Perform a deep copy of an existing ACL. * * @param p_this object to attach the copy to. * @param p_acl ACL object to be copied. * * @return a new ACL object, or NULL on error. */ vlc_acl_t *ACL_Duplicate( vlc_object_t *p_this, const vlc_acl_t *p_acl ) { vlc_acl_t *p_dupacl; if( p_acl == NULL ) return NULL; p_dupacl = (vlc_acl_t *)malloc( sizeof( *p_dupacl ) ); if( p_dupacl == NULL ) return NULL; if( p_acl->i_size ) { p_dupacl->p_entries = (vlc_acl_entry_t *) malloc( p_acl->i_size * sizeof( vlc_acl_entry_t ) ); if( p_dupacl->p_entries == NULL ) { free( p_dupacl ); return NULL; } memcpy( p_dupacl->p_entries, p_acl->p_entries, p_acl->i_size * sizeof( vlc_acl_entry_t ) ); } else p_dupacl->p_entries = NULL; vlc_object_hold( p_this ); p_dupacl->p_owner = p_this; p_dupacl->i_size = p_acl->i_size; p_dupacl->b_allow_default = p_acl->b_allow_default; return p_dupacl; }
/** Get current playing input. */ input_thread_t * playlist_CurrentInput( playlist_t * p_playlist ) { input_thread_t * p_input; PL_LOCK; p_input = pl_priv(p_playlist)->p_input; if( p_input ) vlc_object_hold( p_input ); PL_UNLOCK; return p_input; }
/* Define the Input used. Add the callbacks on input p_input is held once here */ void InputManager::setInput( input_thread_t *_p_input ) { delInput(); p_input = _p_input; if( p_input != NULL ) { msg_Dbg( p_intf, "IM: Setting an input" ); vlc_object_hold( p_input ); addCallbacks(); UpdateStatus(); UpdateName(); UpdateArt(); UpdateTeletext(); UpdateNavigation(); UpdateVout(); p_item = input_GetItem( p_input ); emit rateChanged( var_GetFloat( p_input, "rate" ) ); /* Get Saved Time */ if( p_item->i_type == ITEM_TYPE_FILE ) { char *uri = input_item_GetURI( p_item ); int i_time = RecentsMRL::getInstance( p_intf )->time( qfu(uri) ); if( i_time > 0 && qfu( uri ) != lastURI && !var_GetFloat( p_input, "run-time" ) && !var_GetFloat( p_input, "start-time" ) && !var_GetFloat( p_input, "stop-time" ) ) { emit resumePlayback( (int64_t)i_time * 1000 ); } playlist_Lock( THEPL ); // Add root items only playlist_item_t* p_node = playlist_CurrentPlayingItem( THEPL ); if ( p_node != NULL && p_node->p_parent != NULL && p_node->p_parent->i_id == THEPL->p_playing->i_id ) { // Save the latest URI to avoid asking to restore the // position on the same input file. lastURI = qfu( uri ); RecentsMRL::getInstance( p_intf )->addRecent( lastURI ); } playlist_Unlock( THEPL ); free( uri ); } } else { p_item = NULL; lastURI.clear(); assert( !p_input_vbi ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); } }
static vlc_object_t *FindParent (vlc_object_t *p_this, int i_type) { for (vlc_object_t *parent = p_this->p_parent; parent != NULL; parent = parent->p_parent) { if (vlc_internals (parent)->i_object_type == i_type) return vlc_object_hold (parent); } return NULL; }
/** * Registers a new session with the announce handler, using a pregenerated SDP * * \param obj a VLC object * \param psz_sdp the SDP to register * \param psz_dst session address (needed for SAP address auto detection) * \param p_method an announce method descriptor * \return the new session descriptor structure */ session_descriptor_t * sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp, const char *psz_dst, announce_method_t *p_method ) { assert (p_method == &sap_method); (void) p_method; session_descriptor_t *p_session = calloc( 1, sizeof (*p_session) ); if( !p_session ) return NULL; p_session->psz_sdp = strdup( psz_sdp ); /* GRUIK. We should not convert back-and-forth from string to numbers */ struct addrinfo *res; if (vlc_getaddrinfo (obj, psz_dst, 0, NULL, &res) == 0) { if (res->ai_addrlen <= sizeof (p_session->addr)) memcpy (&p_session->addr, res->ai_addr, p_session->addrlen = res->ai_addrlen); vlc_freeaddrinfo (res); } vlc_mutex_lock (&sap_mutex); sap_handler_t *p_sap = libvlc_priv (obj->p_libvlc)->p_sap; if (p_sap == NULL) { p_sap = SAP_Create (VLC_OBJECT (obj->p_libvlc)); libvlc_priv (obj->p_libvlc)->p_sap = p_sap; vlc_object_set_destructor ((vlc_object_t *)p_sap, sap_destroy); } else vlc_object_hold ((vlc_object_t *)p_sap); vlc_mutex_unlock (&sap_mutex); if (p_sap == NULL) goto error; msg_Dbg (obj, "adding SAP session"); if (SAP_Add (p_sap, p_session)) { vlc_mutex_lock (&sap_mutex); vlc_object_release ((vlc_object_t *)p_sap); vlc_mutex_unlock (&sap_mutex); goto error; } return p_session; error: free (p_session->psz_sdp); free (p_session); return NULL; }
QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type, bool inherit) : object (obj), name (qfu(varname)) { vlc_object_hold (object); if (inherit) type |= VLC_VAR_DOINHERIT; var_Create (object, qtu(name), type); var_AddCallback (object, qtu(name), callback, this); }
static int vlclua_get_playlist( lua_State *L ) { playlist_t *p_playlist = vlclua_get_playlist_internal( L ); if( p_playlist ) { vlclua_push_vlc_object( L, p_playlist, vlclua_gc_release ); vlc_object_hold( p_playlist ); } else lua_pushnil( L ); return 1; }
static vlc_object_t *dialog_GetProvider (vlc_object_t *obj) { libvlc_priv_t *priv = libvlc_priv (obj->p_libvlc); vlc_object_t *provider; vlc_mutex_lock (&provider_lock); if ((provider = priv->p_dialog_provider) != NULL) vlc_object_hold (provider); vlc_mutex_unlock (&provider_lock); return provider; }
audio_output_t *input_resource_HoldAout( input_resource_t *p_resource ) { audio_output_t *p_aout; vlc_mutex_lock( &p_resource->lock_hold ); p_aout = p_resource->p_aout; if( p_aout != NULL ) vlc_object_hold( p_aout ); vlc_mutex_unlock( &p_resource->lock_hold ); return p_aout; }
static vlc_object_t *FindParentName (vlc_object_t *p_this, const char *name) { for (vlc_object_t *parent = p_this->p_parent; parent != NULL; parent = parent->p_parent) { const char *objname = vlc_internals (parent)->psz_name; if (objname && !strcmp (objname, name)) return vlc_object_hold (parent); } return NULL; }
static aout_instance_t *HoldAout( input_resource_t *p_resource ) { vlc_mutex_lock( &p_resource->lock_hold ); aout_instance_t *p_aout = p_resource->p_aout; if( p_aout ) vlc_object_hold( p_aout ); vlc_mutex_unlock( &p_resource->lock_hold ); return p_aout; }
VoutWindow::VoutWindow( intf_thread_t *pIntf, vout_window_t* pWnd, int width, int height, GenericWindow* pParent ) : GenericWindow( pIntf, 0, 0, false, false, pParent ), m_pWnd( pWnd ), original_width( width ), original_height( height ), m_pParentWindow( pParent ), m_pCtrlVideo( NULL ), m_bFullscreen( false ) { // counter for debug count++; if( m_pWnd ) vlc_object_hold( m_pWnd ); }
foreach( vout_thread_t *p_vout, add ) { vlc_object_hold( VLC_OBJECT(p_vout) ); vlc_mutex_lock( &lock ); vout.append( p_vout ); var_AddCallback( p_vout, "fullscreen", FullscreenControllerWidget::FullscreenChanged, this ); /* I miss a add and fire */ fullscreenChanged( p_vout, var_GetBool( THEPL, "fullscreen" ), var_GetInteger( p_vout, "mouse-hide-timeout" ) ); vlc_mutex_unlock( &lock ); }
static vlc_object_t *FindChild (vlc_object_internals_t *priv, int i_type) { for (priv = priv->first; priv != NULL; priv = priv->next) { if (priv->i_object_type == i_type) return vlc_object_hold (vlc_externals (priv)); vlc_object_t *found = FindChild (priv, i_type); if (found != NULL) return found; } return NULL; }
static int WindowOpen( vout_window_t *pWnd, const vout_window_cfg_t *cfg ) { vout_window_sys_t* sys; vlc_mutex_lock( &skin_load.mutex ); intf_thread_t *pIntf = skin_load.intf; if( pIntf ) vlc_object_hold( pIntf ); vlc_mutex_unlock( &skin_load.mutex ); if( pIntf == NULL ) return VLC_EGENERIC; if( !vlc_object_alive( pIntf ) || !var_InheritBool( pIntf, "skinned-video") || cfg->is_standalone ) { vlc_object_release( pIntf ); return VLC_EGENERIC; } sys = (vout_window_sys_t*)calloc( 1, sizeof( *sys ) ); if( !sys ) { vlc_object_release( pIntf ); return VLC_ENOMEM; } pWnd->sys = sys; pWnd->sys->cfg = *cfg; pWnd->sys->pIntf = pIntf; pWnd->control = WindowControl; // force execution in the skins2 thread context CmdExecuteBlock* cmd = new CmdExecuteBlock( pIntf, VLC_OBJECT( pWnd ), WindowOpenLocal ); CmdExecuteBlock::executeWait( CmdGenericPtr( cmd ) ); #ifdef X11_SKINS if( !pWnd->handle.xid ) #else if( !pWnd->handle.hwnd ) #endif { free( sys ); vlc_object_release( pIntf ); return VLC_EGENERIC; } return VLC_SUCCESS; }
static int PlaylistEvent( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t val, void *p_data ) { intf_thread_t *p_intf = (intf_thread_t *)p_data; // sunqueen modify intf_sys_t *p_sys = p_intf->p_sys; input_thread_t *p_input = (input_thread_t *)val.p_address; // sunqueen modify (void) p_this; (void) psz_var; (void) oldval; var_AddCallback( p_input, "intf-event", InputEvent, p_intf ); assert( p_sys->p_input == NULL ); p_sys->p_input = (input_thread_t *)vlc_object_hold( p_input ); // sunqueen modify return VLC_SUCCESS; }
static vlc_object_t *FindChildName (vlc_object_internals_t *priv, const char *name) { for (priv = priv->first; priv != NULL; priv = priv->next) { if (priv->psz_name && !strcmp (priv->psz_name, name)) return vlc_object_hold (vlc_externals (priv)); vlc_object_t *found = FindChildName (priv, name); if (found != NULL) return found; } return NULL; }
input_thread_t * vlclua_get_input_internal( lua_State *L ) { extension_t *p_extension = vlclua_extension_get( L ); if( p_extension ) { input_thread_t *p_input = p_extension->p_sys->p_input; if( p_input ) { vlc_object_hold(p_input); return p_input; } } playlist_t *p_playlist = vlclua_get_playlist_internal( L ); input_thread_t *p_input = playlist_CurrentInput( p_playlist ); return p_input; }
/** * Creates an empty ACL. * * @param b_allow whether to grant (true) or deny (false) access * by default (ie if none of the ACL entries matched). * * @return an ACL object. NULL in case of error. */ vlc_acl_t *ACL_Create( vlc_object_t *p_this, bool b_allow ) { vlc_acl_t *p_acl; p_acl = (vlc_acl_t *)malloc( sizeof( *p_acl ) ); if( p_acl == NULL ) return NULL; vlc_object_hold( p_this ); p_acl->p_owner = p_this; p_acl->i_size = 0; p_acl->p_entries = NULL; p_acl->b_allow_default = b_allow; return p_acl; }
/* * Retrieve the input thread. Be sure to release the object * once you are done with it. (libvlc Internal) */ input_thread_t *libvlc_get_input_thread( libvlc_media_player_t *p_mi ) { input_thread_t *p_input_thread; assert( p_mi ); lock_input(p_mi); p_input_thread = p_mi->input.p_thread; if( p_input_thread ) vlc_object_hold( p_input_thread ); else libvlc_printerr( "No active input" ); unlock_input(p_mi); return p_input_thread; }
/***************************************************************************** * ItemChange: Playlist item change callback *****************************************************************************/ static int ItemChange(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; intf_sys_t *p_sys = p_intf->p_sys; input_thread_t *p_input = newval.p_address; VLC_UNUSED(p_this); VLC_UNUSED(psz_var); VLC_UNUSED(oldval); p_sys->b_meta_read = false; p_sys->b_submit = false; if (p_sys->p_input != NULL) { var_DelCallback(p_sys->p_input, "intf-event", PlayingChange, p_intf); vlc_object_release(p_sys->p_input); p_sys->p_input = NULL; } if (p_input == NULL) return VLC_SUCCESS; input_item_t *p_item = input_GetItem(p_input); if (p_item == NULL) return VLC_SUCCESS; if (var_CountChoices(p_input, "video-es")) { msg_Dbg(p_this, "Not an audio-only input, not submitting"); return VLC_SUCCESS; } p_sys->time_total_pauses = 0; time(&p_sys->p_current_song.date); /* to be sent to last.fm */ p_sys->p_current_song.i_start = mdate(); /* only used locally */ p_sys->p_input = vlc_object_hold(p_input); var_AddCallback(p_input, "intf-event", PlayingChange, p_intf); if (input_item_IsPreparsed(p_item)) ReadMetaData(p_intf, p_input); /* if the input item was not preparsed, we'll do it in PlayingChange() * callback, when "state" == PLAYING_S */ return VLC_SUCCESS; }
static vlc_object_t *ObjectExists (vlc_object_t *root, void *obj) { if (root == obj) return vlc_object_hold (root); vlc_object_internals_t *priv = vlc_internals(root); vlc_object_t *ret = NULL; /* NOTE: nested locking here (due to recursive call) */ vlc_mutex_lock (&vlc_internals(root)->tree_lock); for (priv = priv->first; priv != NULL && ret == NULL; priv = priv->next) ret = ObjectExists (vlc_externals (priv), obj); vlc_mutex_unlock (&vlc_internals(root)->tree_lock); return ret; }