/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; if( !notify_init( APPLICATION_NAME ) ) { free( p_sys ); msg_Err( p_intf, "can't find notification daemon" ); return VLC_EGENERIC; } p_intf->p_sys = p_sys; vlc_mutex_init( &p_sys->lock ); p_sys->notification = NULL; p_sys->b_has_actions = false; GList *p_caps = notify_get_server_caps (); if( p_caps ) { for( GList *c = p_caps; c != NULL; c = c->next ) { if( !strcmp( (char*)c->data, "actions" ) ) { p_sys->b_has_actions = true; break; } } g_list_foreach( p_caps, (GFunc)g_free, NULL ); g_list_free( p_caps ); } /* */ playlist_t *p_playlist = pl_Hold( p_intf ); var_AddCallback( p_playlist, "item-current", ItemChange, p_intf ); pl_Release( p_intf ); return VLC_SUCCESS; }
/** * Open the module * @param p_this: the filter object * @return VLC_SUCCESS or vlc error codes */ static int Open( vlc_object_t * p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; p_sys = p_filter->p_sys = (filter_sys_t*)malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; /* Create the object for the thread */ vlc_sem_init( &p_sys->ready, 0 ); p_sys->b_error = false; p_sys->b_quit = false; p_sys->i_width = var_InheritInteger( p_filter, "projectm-width" ); p_sys->i_height = var_InheritInteger( p_filter, "projectm-height" ); p_sys->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio ); vlc_mutex_init( &p_sys->lock ); p_sys->p_buffer = NULL; p_sys->i_buffer_size = 0; p_sys->i_nb_samples = 0; /* Create the thread */ if( vlc_clone( &p_sys->thread, Thread, p_filter, VLC_THREAD_PRIORITY_LOW ) ) goto error; vlc_sem_wait( &p_sys->ready ); if( p_sys->b_error ) { vlc_join( p_sys->thread, NULL ); goto error; } p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32; p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->pf_audio_filter = DoWork; return VLC_SUCCESS; error: vlc_sem_destroy( &p_sys->ready ); free (p_sys ); return VLC_EGENERIC; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { playlist_t *pl = pl_Get( p_this ); services_discovery_t *p_sd = ( services_discovery_t* )p_this; services_discovery_sys_t *p_sys = malloc( sizeof( services_discovery_sys_t ) ); if( !p_sys ) return VLC_ENOMEM; p_sys->i_urls = 0; p_sys->ppsz_urls = NULL; p_sys->i_input = 0; p_sys->pp_input = NULL; p_sys->pp_items = NULL; p_sys->i_items = 0; vlc_mutex_init( &p_sys->lock ); vlc_cond_init( &p_sys->wait ); p_sys->b_update = true; p_sys->b_savedurls_loaded = false; p_sys->psz_request = NULL; p_sys->update_type = UPDATE_URLS; p_sd->p_sys = p_sys; /* Launch the callback associated with this variable */ var_Create( pl, "podcast-urls", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_AddCallback( pl, "podcast-urls", UrlsChange, p_sys ); var_Create( pl, "podcast-request", VLC_VAR_STRING ); var_AddCallback( pl, "podcast-request", Request, p_sys ); if (vlc_clone (&p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW)) { var_DelCallback( pl, "podcast-request", Request, p_sys ); var_DelCallback( pl, "podcast-urls", UrlsChange, p_sys ); vlc_cond_destroy( &p_sys->wait ); vlc_mutex_destroy( &p_sys->lock ); free (p_sys); return VLC_EGENERIC; } return VLC_SUCCESS; }
libvlc_instance_t * libvlc_new_with_builtins( int argc, const char *const *argv, const void ** builtins_module) { libvlc_instance_t *p_new = malloc (sizeof (*p_new)); if (unlikely(p_new == NULL)) return NULL; libvlc_init_threads (); const char *my_argv[argc + 2]; my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */ for( int i = 0; i < argc; i++ ) my_argv[i + 1] = argv[i]; my_argv[argc + 1] = NULL; /* C calling conventions require a NULL */ libvlc_int_t *p_libvlc_int = libvlc_InternalCreate(); if (unlikely (p_libvlc_int == NULL)) goto error; if (libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv, builtins_module )) { libvlc_InternalDestroy( p_libvlc_int ); goto error; } p_new->p_libvlc_int = p_libvlc_int; p_new->libvlc_vlm.p_vlm = NULL; p_new->libvlc_vlm.p_event_manager = NULL; p_new->libvlc_vlm.pf_release = NULL; p_new->ref_count = 1; p_new->verbosity = 1; p_new->p_callback_list = NULL; vlc_mutex_init(&p_new->instance_lock); var_Create( p_libvlc_int, "http-user-agent", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); return p_new; error: libvlc_deinit_threads (); free (p_new); return NULL; }
/***************************************************************************** * CreateFilter: allocates marquee video filter *****************************************************************************/ static int CreateFilter( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; /* Allocate structure */ p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_sys == NULL ) return VLC_ENOMEM; vlc_mutex_init( &p_sys->lock ); p_sys->p_style = text_style_New(); config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); #define CREATE_VAR( stor, type, var ) \ p_sys->stor = var_CreateGet##type##Command( p_filter, var ); \ var_AddCallback( p_filter, var, MarqueeCallback, p_sys ); p_sys->b_need_update = true; CREATE_VAR( i_xoff, Integer, "marq-x" ); CREATE_VAR( i_yoff, Integer, "marq-y" ); CREATE_VAR( i_timeout,Integer, "marq-timeout" ); p_sys->i_refresh = 1000 * var_CreateGetIntegerCommand( p_filter, "marq-refresh" ); var_AddCallback( p_filter, "marq-refresh", MarqueeCallback, p_sys ); CREATE_VAR( i_pos, Integer, "marq-position" ); CREATE_VAR( psz_marquee, String, "marq-marquee" ); p_sys->p_style->i_font_alpha = 255 - var_CreateGetIntegerCommand( p_filter, "marq-opacity" ); var_AddCallback( p_filter, "marq-opacity", MarqueeCallback, p_sys ); CREATE_VAR( p_style->i_font_color, Integer, "marq-color" ); CREATE_VAR( p_style->i_font_size, Integer, "marq-size" ); /* Misc init */ p_filter->pf_sub_filter = Filter; p_sys->last_time = 0; return VLC_SUCCESS; }
/** * Initializes an interruption context. */ void vlc_interrupt_init(vlc_interrupt_t *ctx) { vlc_rwlock_wrlock(&vlc_interrupt_lock); assert(vlc_interrupt_refs < UINT_MAX); if (vlc_interrupt_refs++ == 0) #ifndef NDEBUG vlc_threadvar_create(&vlc_interrupt_var, vlc_interrupt_destructor); #else vlc_threadvar_create(&vlc_interrupt_var, NULL); #endif vlc_rwlock_unlock(&vlc_interrupt_lock); vlc_mutex_init(&ctx->lock); ctx->interrupted = false; atomic_init(&ctx->killed, false); #ifndef NDEBUG ctx->attached = false; #endif ctx->callback = NULL; }
/***************************************************************************** * Public functions *****************************************************************************/ playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent ) { playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) ); if( !p_preparser ) return NULL; p_preparser->object = parent; p_preparser->p_fetcher = playlist_fetcher_New( parent ); if( unlikely(p_preparser->p_fetcher == NULL) ) msg_Err( parent, "cannot create fetcher" ); vlc_mutex_init( &p_preparser->lock ); vlc_cond_init( &p_preparser->wait ); vlc_sem_init( &p_preparser->item_done, 0 ); p_preparser->b_live = false; p_preparser->i_waiting = 0; p_preparser->pp_waiting = NULL; return p_preparser; }
int libvlc_InternalDialogInit(libvlc_int_t *p_libvlc) { assert(p_libvlc != NULL); vlc_dialog_provider *p_provider = malloc(sizeof(*p_provider)); if (p_provider == NULL) return VLC_EGENERIC; vlc_mutex_init(&p_provider->lock); vlc_array_init(&p_provider->dialog_array); memset(&p_provider->cbs, 0, sizeof(p_provider->cbs)); p_provider->p_cbs_data = NULL; p_provider->pf_ext_update = NULL; p_provider->p_ext_data = NULL; libvlc_priv(p_libvlc)->p_dialog_provider = p_provider; return VLC_SUCCESS; }
static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA ) { msg_Err( p_filter, "Unsupported input chroma \"%4.4s\". " "Bluescreen can only use \"YUVA\".", (char*)&p_filter->fmt_in.video.i_chroma ); return VLC_EGENERIC; } /* Allocate structure */ p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_filter->p_sys == NULL ) return VLC_ENOMEM; p_sys = p_filter->p_sys; config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); int val; vlc_mutex_init( &p_sys->lock ); #define GET_VAR( name, min, max ) \ val = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX #name ); \ p_sys->i_##name = __MIN( max, __MAX( min, val ) ); \ var_AddCallback( p_filter, CFG_PREFIX #name, BluescreenCallback, p_sys ); GET_VAR( u, 0x00, 0xff ); GET_VAR( v, 0x00, 0xff ); GET_VAR( ut, 0x00, 0xff ); GET_VAR( vt, 0x00, 0xff ); p_sys->p_at = NULL; #undef GET_VAR p_filter->pf_video_filter = Filter; return VLC_SUCCESS; }
libvlc_instance_t * libvlc_new( int argc, const char *const *argv ) { libvlc_threads_init (); libvlc_instance_t *p_new = malloc (sizeof (*p_new)); if (unlikely(p_new == NULL)) return NULL; // const char *my_argv[argc + 2]; const char **my_argv = (const char **)malloc(sizeof(char *) * (argc + 2)); // sunqueen modify my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */ for( int i = 0; i < argc; i++ ) my_argv[i + 1] = argv[i]; my_argv[argc + 1] = NULL; /* C calling conventions require a NULL */ libvlc_int_t *p_libvlc_int = libvlc_InternalCreate(); if (unlikely (p_libvlc_int == NULL)) goto error; if (libvlc_InternalInit( p_libvlc_int, argc + 1, my_argv )) { libvlc_InternalDestroy( p_libvlc_int ); goto error; } p_new->p_libvlc_int = p_libvlc_int; p_new->libvlc_vlm.p_vlm = NULL; p_new->libvlc_vlm.p_event_manager = NULL; p_new->libvlc_vlm.pf_release = NULL; p_new->ref_count = 1; p_new->p_callback_list = NULL; vlc_mutex_init(&p_new->instance_lock); free( my_argv ); // sunqueen add return p_new; error: free (p_new); free( my_argv ); // sunqueen add libvlc_threads_deinit (); return NULL; }
/***************************************************************************** * Open: initialize interface *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys = malloc( sizeof (intf_sys_t) ); if( p_sys == NULL ) return VLC_ENOMEM; p_intf->p_sys = p_sys; p_sys->hotkeyWindow = NULL; vlc_mutex_init( &p_sys->lock ); vlc_cond_init( &p_sys->wait ); if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { vlc_mutex_destroy( &p_sys->lock ); vlc_cond_destroy( &p_sys->wait ); free( p_sys ); p_intf->p_sys = NULL; return VLC_ENOMEM; } vlc_mutex_lock( &p_sys->lock ); while( p_sys->hotkeyWindow == NULL ) vlc_cond_wait( &p_sys->wait, &p_sys->lock ); if( p_sys->hotkeyWindow == INVALID_HANDLE_VALUE ) { vlc_mutex_unlock( &p_sys->lock ); vlc_join( p_sys->thread, NULL ); vlc_mutex_destroy( &p_sys->lock ); vlc_cond_destroy( &p_sys->wait ); free( p_sys ); p_intf->p_sys = NULL; return VLC_ENOMEM; } vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; }
static int Open( vlc_object_t *p_this ) { int res; services_discovery_t *p_sd = ( services_discovery_t* )p_this; services_discovery_sys_t *p_sys = ( services_discovery_sys_t * ) calloc( 1, sizeof( services_discovery_sys_t ) ); if(!(p_sd->p_sys = p_sys)) return VLC_ENOMEM; res = UpnpInit( 0, 0 ); if( res != UPNP_E_SUCCESS ) { msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) ); free( p_sys ); return VLC_EGENERIC; } p_sys->serverList = new MediaServerList( p_sd ); vlc_mutex_init( &p_sys->callbackLock ); res = UpnpRegisterClient( Callback, p_sd, &p_sys->clientHandle ); if( res != UPNP_E_SUCCESS ) { msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) ); Close( (vlc_object_t*) p_sd ); return VLC_EGENERIC; } res = UpnpSearchAsync( p_sys->clientHandle, 5, MEDIA_SERVER_DEVICE_TYPE, p_sd ); if( res != UPNP_E_SUCCESS ) { msg_Err( p_sd, "%s", UpnpGetErrorMessage( res ) ); Close( (vlc_object_t*) p_sd ); return VLC_EGENERIC; } return VLC_SUCCESS; }
/************************************************************************** * libvlc_event_async_init (private) : * * Destroy what might have been created by. **************************************************************************/ static void libvlc_event_async_init(libvlc_event_manager_t * p_em) { p_em->async_event_queue = calloc(1, sizeof(struct libvlc_event_async_queue)); int error = vlc_threadvar_create(&queue(p_em)->is_asynch_dispatch_thread_var, NULL); assert(!error); vlc_mutex_init(&queue(p_em)->lock); vlc_cond_init(&queue(p_em)->signal); vlc_cond_init(&queue(p_em)->signal_idle); error = vlc_clone (&queue(p_em)->thread, event_async_loop, p_em, VLC_THREAD_PRIORITY_LOW); if(error) { free(p_em->async_event_queue); p_em->async_event_queue = NULL; return; } }
/** * Open the filter */ static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; /* */ if( !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) ) { msg_Err( p_filter, "Input and output format does not match" ); return VLC_EGENERIC; } /* Allocate structure */ p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); p_sys->pi_order = NULL; vlc_mutex_init( &p_sys->lock ); p_sys->change.i_rows = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "rows" ); p_sys->change.i_cols = var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "cols" ); p_sys->change.b_blackslot = var_CreateGetBoolCommand( p_filter, CFG_PREFIX "black-slot" ); p_sys->b_change = true; var_AddCallback( p_filter, CFG_PREFIX "rows", PuzzleCallback, p_sys ); var_AddCallback( p_filter, CFG_PREFIX "cols", PuzzleCallback, p_sys ); var_AddCallback( p_filter, CFG_PREFIX "black-slot", PuzzleCallback, p_sys ); p_filter->pf_video_filter = Filter; p_filter->pf_video_mouse = Mouse; return VLC_SUCCESS; }
/***************************************************************************** * Create: allocates adjust video thread output method ***************************************************************************** * This function allocates and initializes a adjust vout method. *****************************************************************************/ static int Create( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; /* Allocate structure */ p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); if( p_filter->p_sys == NULL ) return VLC_ENOMEM; p_sys = p_filter->p_sys; BufferInit( &p_sys->input ); BufferInit( &p_sys->output ); QueueInit( &p_sys->atomic ); QueueInit( &p_sys->pending ); QueueInit( &p_sys->processed ); do_ListInit( &p_sys->overlays ); p_sys->i_inputfd = -1; p_sys->i_outputfd = -1; p_sys->b_updated = true; p_sys->b_atomic = false; vlc_mutex_init( &p_sys->lock ); p_filter->pf_sub_source = Filter; config_ChainParse( p_filter, "overlay-", ppsz_filter_options, p_filter->p_cfg ); p_sys->psz_inputfile = var_CreateGetStringCommand( p_filter, "overlay-input" ); p_sys->psz_outputfile = var_CreateGetStringCommand( p_filter, "overlay-output" ); var_AddCallback( p_filter, "overlay-input", AdjustCallback, p_sys ); var_AddCallback( p_filter, "overlay-output", AdjustCallback, p_sys ); RegisterCommand( p_filter ); return VLC_SUCCESS; }
static vlc_dialog_id * dialog_add_locked(vlc_dialog_provider *p_provider, enum dialog_type i_type) { vlc_dialog_id *p_id = calloc(1, sizeof(*p_id)); if (p_id == NULL) return NULL; if(vlc_array_append(&p_provider->dialog_array, p_id)) { free(p_id); return NULL; } vlc_mutex_init(&p_id->lock); vlc_cond_init(&p_id->wait); p_id->i_type = i_type; p_id->i_refcount = 2; /* provider and callbacks */ return p_id; }
module_t *vlc_module_create (vlc_object_t *obj) { module_t *module = malloc (sizeof (*module)); if (module == NULL) return NULL; module->psz_object_name = strdup( default_name ); module->next = NULL; module->submodule = NULL; module->parent = NULL; module->submodule_count = 0; vlc_gc_init (module, vlc_module_destruct); vlc_mutex_init (&module->lock); module->psz_shortname = NULL; module->psz_longname = (char*)default_name; module->psz_help = NULL; for (unsigned i = 0; i < MODULE_SHORTCUT_MAX; i++) module->pp_shortcuts[i] = NULL; module->psz_capability = (char*)""; module->i_score = 1; module->i_cpu = 0; module->b_unloadable = true; module->b_reentrant = true; module->b_submodule = false; module->pf_activate = NULL; module->pf_deactivate = NULL; module->p_config = NULL; module->confsize = 0; module->i_config_items = 0; module->i_bool_items = 0; /*module->handle = garbage */ module->psz_filename = NULL; module->b_builtin = false; module->b_loaded = false; (void)obj; return module; }
JNIEXPORT void JNICALL NAME(nativeCreate)(JNIEnv *env, jobject thiz) { initClasses(env, thiz); vlc_mutex_t *parse_lock = calloc(1, sizeof(vlc_mutex_t)); vlc_mutex_init(parse_lock); setIntValue(env, thiz, "mNativeMediaParseLock", (jint) parse_lock); vlc_cond_t *parse_cond = calloc(1, sizeof(vlc_cond_t)); vlc_cond_init(parse_cond); setIntValue(env, thiz, "mNativeMediaParseCond", (jint) parse_cond); setIntValue(env, thiz, "mNativeMediaBufferingCount", 0); const char *argv[] = {"-I", "dummy", "-vvv", "--no-plugins-cache", "--no-drop-late-frames", "--input-timeshift-path", "/data/local/tmp"}; libvlc_instance_t *instance = libvlc_new_with_builtins(sizeof(argv) / sizeof(*argv), argv, vlc_builtins_modules); setIntValue(env, thiz, "mLibVlcInstance", (jint) instance); libvlc_media_player_t *mp = libvlc_media_player_new(instance); setIntValue(env, thiz, "mLibVlcMediaPlayer", (jint) mp); /* throw? */ libvlc_event_manager_t *em = libvlc_media_player_event_manager(mp); for (int i = 0; i < sizeof(mp_listening) / sizeof(*mp_listening); i++) { libvlc_event_attach(em, mp_listening[i], vlc_event_callback, thiz); } }
/** * Allocate a libvlc instance, initialize global data if needed * It also initializes the threading system */ libvlc_int_t * libvlc_InternalCreate( void ) { libvlc_int_t *p_libvlc; libvlc_priv_t *priv; char *psz_env = NULL; /* Now that the thread system is initialized, we don't have much, but * at least we have variables */ /* Allocate a libvlc instance object */ p_libvlc = vlc_custom_create( (vlc_object_t *)NULL, sizeof (*priv), "libvlc" ); if( p_libvlc == NULL ) return NULL; priv = libvlc_priv (p_libvlc); priv->p_playlist = NULL; priv->p_ml = NULL; priv->p_dialog_provider = NULL; priv->p_vlm = NULL; /* Find verbosity from VLC_VERBOSE environment variable */ psz_env = getenv( "VLC_VERBOSE" ); if( psz_env != NULL ) priv->i_verbose = atoi( psz_env ); else priv->i_verbose = 3; #if defined( HAVE_ISATTY ) && !defined( WIN32 ) priv->b_color = isatty( 2 ); /* 2 is for stderr */ #else priv->b_color = false; #endif /* Initialize mutexes */ vlc_mutex_init( &priv->ml_lock ); vlc_ExitInit( &priv->exit ); return p_libvlc; }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 || p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 ) { p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32; p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32; msg_Warn( p_filter, "bad input or output format" ); return VLC_EGENERIC; } if ( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) ) { memcpy( &p_filter->fmt_out.audio, &p_filter->fmt_in.audio, sizeof(audio_sample_format_t) ); msg_Warn( p_filter, "input and output formats are not similar" ); return VLC_EGENERIC; } p_filter->pf_audio_filter = DoWork; /* Allocate structure */ p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; vlc_mutex_init( &p_sys->lock ); if( EqzInit( p_filter, p_filter->fmt_in.audio.i_rate ) != VLC_SUCCESS ) { vlc_mutex_destroy( &p_sys->lock ); free( p_sys ); return VLC_EGENERIC; } return VLC_SUCCESS; }
/** * Create the interface, and prepare it for main loop. * * \param p_this the calling vlc_object_t * \param psz_module a preferred interface module * \return a pointer to the created interface thread, NULL on error */ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module ) { intf_thread_t * p_intf; /* Allocate structure */ p_intf = vlc_object_create( p_this, VLC_OBJECT_INTF ); if( !p_intf ) return NULL; p_intf->b_interaction = false; #if defined( __APPLE__ ) || defined( WIN32 ) p_intf->b_should_run_on_first_thread = false; #endif /* Choose the best module */ p_intf->psz_intf = strdup( psz_module ); p_intf->p_module = module_Need( p_intf, "interface", psz_module, false ); if( p_intf->p_module == NULL ) { msg_Err( p_intf, "no suitable interface module" ); free( p_intf->psz_intf ); vlc_object_release( p_intf ); return NULL; } /* Initialize structure */ p_intf->b_menu = false; p_intf->b_menu_change = false; /* Initialize mutexes */ vlc_mutex_init( &p_intf->change_lock ); /* Attach interface to its parent object */ vlc_object_attach( p_intf, p_this ); vlc_object_set_destructor( p_intf, intf_Destroy ); return p_intf; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; playlist_t *p_playlist; intf_sys_t *p_sys = malloc( sizeof( intf_sys_t ) ); if( !p_sys ) { msg_Err( p_intf, "Out of memory" ); return VLC_ENOMEM; } p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( !p_playlist ) { msg_Err( p_intf, "could not find playlist object" ); return VLC_ENOOBJ; } var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); /* var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );*/ vlc_object_release( p_playlist ); if( !notify_init( APPLICATION_NAME ) ) { msg_Err( p_intf, "can't find notification daemon" ); return VLC_EGENERIC; } p_intf->p_sys = p_sys; vlc_mutex_init( p_this, &p_sys->lock ); p_intf->pf_run = Run; msg_Dbg( p_intf,"notify plugin started"); return VLC_SUCCESS; }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; /* Allocate structure */ filter_sys_t *p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) ); if( !p_sys ) return VLC_ENOMEM; vlc_mutex_init( &p_sys->lock ); if( EqzInit( p_filter, p_filter->fmt_in.audio.i_rate ) != VLC_SUCCESS ) { vlc_mutex_destroy( &p_sys->lock ); free( p_sys ); return VLC_EGENERIC; } p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32; p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->pf_audio_filter = DoWork; return VLC_SUCCESS; }
struct background_worker* background_worker_New( void* owner, struct background_worker_config* conf ) { struct background_worker* worker = malloc( sizeof *worker ); if( unlikely( !worker ) ) return NULL; worker->conf = *conf; worker->owner = owner; worker->head.id = NULL; worker->head.active = false; worker->head.deadline = VLC_TS_INVALID; vlc_mutex_init( &worker->lock ); vlc_cond_init( &worker->head.wait ); vlc_cond_init( &worker->head.worker_wait ); vlc_array_init( &worker->tail.data ); vlc_cond_init( &worker->tail.wait ); return worker; }
/************************************************************************** * libvlc_event_manager_new (internal) : * * Init an object's event manager. **************************************************************************/ libvlc_event_manager_t * libvlc_event_manager_new( void * p_obj, libvlc_instance_t * p_libvlc_inst ) { libvlc_event_manager_t * p_em; p_em = malloc(sizeof( libvlc_event_manager_t )); if( !p_em ) { libvlc_printerr( "Not enough memory" ); return NULL; } p_em->p_obj = p_obj; p_em->p_obj = p_obj; p_em->async_event_queue = NULL; p_em->p_libvlc_instance = p_libvlc_inst; libvlc_retain( p_libvlc_inst ); vlc_array_init( &p_em->listeners_groups ); vlc_mutex_init( &p_em->object_lock ); vlc_mutex_init_recursive( &p_em->event_sending_lock ); return p_em; }
/* Set vars, config. (Called by VLCMenuBar::createMenuBar in menus.cpp) */ void init( intf_thread_t * p_intf, MainInterface * mainInterface, QMenu * p_menu ) { // Set namespace vars Moviesoap::p_GuiMenu = (Moviesoap::Menu *) p_menu; Moviesoap::p_obj = VLC_OBJECT(p_intf); Moviesoap::p_playlist = pl_Get(p_intf); vlc_mutex_init( &lock ); #ifdef MSDEBUG1 msg_Info( p_obj, "Moviesoap::init in progress..." ); #endif // build config (tolerances) from file or defaults config.load(); // Create variable pointer to blackout config #define MOVIESOAP_BLACKOUT_CONFIG_POINTER var_CreateGetAddress( p_obj->p_libvlc, MOVIESOAP_BLACKOUT_VARNAME); var_SetAddress( p_obj->p_libvlc, MOVIESOAP_BLACKOUT_VARNAME, &blackout_config ); // Add callback(s) to playlist var_AddCallback( p_playlist, "item-change", PCB_ItemChange, NULL ); // Add callback(s) to root var_AddCallback( p_intf->p_libvlc, "key-pressed", CB_KeyEvent, p_intf ); // Check for updates vlc_clone( &thread_for_http, handleUpdateCheck, p_intf, VLC_THREAD_PRIORITY_LOW ); }
/** * Create a new update VLC struct * * \param p_this the calling vlc_object * \return pointer to new update_t or NULL */ update_t *update_New( vlc_object_t *p_this ) { update_t *p_update; assert( p_this ); p_update = (update_t *)malloc( sizeof( update_t ) ); if( !p_update ) return NULL; vlc_mutex_init( &p_update->lock ); p_update->p_libvlc = p_this->p_libvlc; p_update->release.psz_url = NULL; p_update->release.psz_desc = NULL; p_update->p_download = NULL; p_update->p_check = NULL; p_update->p_pkey = NULL; vlc_gcrypt_init(); return p_update; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open(vlc_object_t *p_this) { intf_thread_t *p_intf = (intf_thread_t*) p_this; intf_sys_t *p_sys = calloc(1, sizeof(intf_sys_t)); msg_Dbg(p_intf, "Entering Open()"); if (!p_sys) return VLC_ENOMEM; p_intf->p_sys = p_sys; vlc_mutex_init(&p_sys->lock); vlc_cond_init(&p_sys->wait); var_AddCallback(pl_Get(p_intf), "item-current", ItemChange, p_intf); msg_Dbg(p_intf, "Added Item Change Callback"); p_intf->pf_run = Run; return VLC_SUCCESS; }
static picture_t *PictureAlloc(vout_display_sys_t *sys, video_format_t *fmt, bool b_opaque) { picture_t *p_pic; picture_resource_t rsc; picture_sys_t *p_picsys = calloc(1, sizeof(*p_picsys)); if (unlikely(p_picsys == NULL)) return NULL; memset(&rsc, 0, sizeof(picture_resource_t)); rsc.p_sys = p_picsys; if (b_opaque) { p_picsys->hw.b_vd_ref = true; p_picsys->hw.p_surface = sys->p_window->p_surface; p_picsys->hw.p_jsurface = sys->p_window->p_jsurface; p_picsys->hw.i_index = -1; vlc_mutex_init(&p_picsys->hw.lock); rsc.pf_destroy = AndroidOpaquePicture_DetachVout; } else { p_picsys->sw.p_vd_sys = sys; rsc.pf_destroy = AndroidPicture_Destroy; } p_pic = picture_NewFromResource(fmt, &rsc); if (!p_pic) { free(p_picsys); return NULL; } return p_pic; }
int CommonInit( vout_thread_t *p_vout ) { vout_sys_t *p_sys = p_vout->p_sys; p_sys->hwnd = NULL; p_sys->hvideownd = NULL; p_sys->hparent = NULL; p_sys->hfswnd = NULL; p_sys->i_changes = 0; SetRectEmpty( &p_sys->rect_display ); SetRectEmpty( &p_sys->rect_parent ); vlc_mutex_init( &p_sys->lock ); var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); /* Set main window's size */ p_sys->i_window_width = p_vout->i_window_width; p_sys->i_window_height = p_vout->i_window_height; p_sys->p_event = EventThreadCreate( p_vout ); if( !p_sys->p_event ) return VLC_EGENERIC; if( EventThreadStart( p_sys->p_event ) ) return VLC_EGENERIC; /* Variable to indicate if the window should be on top of others */ /* Trigger a callback right now */ var_TriggerCallback( p_vout, "video-on-top" ); /* Why not with glwin32 */ #if !defined(UNDER_CE) && !defined(MODULE_NAME_IS_glwin32) var_Create( p_vout, "disable-screensaver", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); DisableScreensaver ( p_vout ); #endif return VLC_SUCCESS; }