bool LinkTracker::start() { if(vlc_clone(&(this->linkTrachThread), track, (void*)this->curInfo, VLC_THREAD_PRIORITY_LOW)) return false; if(vlc_clone(&(this->linkNotifyThread), update, (void*)this, VLC_THREAD_PRIORITY_LOW)) return false; return true; }
/* * Initializes UPNP instance. */ static int Open( vlc_object_t *p_this ) { 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; p_sd->description = _("Universal Plug'n'Play"); p_sys->p_upnp = UpnpInstanceWrapper::get( p_this, p_sd ); if ( !p_sys->p_upnp ) { free(p_sys); return VLC_EGENERIC; } /* XXX: Contrary to what the libupnp doc states, UpnpSearchAsync is * blocking (select() and send() are called). Therefore, Call * UpnpSearchAsync from an other thread. */ if ( vlc_clone( &p_sys->thread, SearchThread, p_this, VLC_THREAD_PRIORITY_LOW ) ) { p_sys->p_upnp->release( true ); free(p_sys); return VLC_EGENERIC; } return VLC_SUCCESS; }
/** * Wrap an existing X11 window to embed the video. */ static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg) { xcb_window_t window = var_InheritInteger (wnd, "drawable-xid"); if (window == 0) return VLC_EGENERIC; if (AcquireDrawable (VLC_OBJECT(wnd), window)) return VLC_EGENERIC; vout_window_sys_t *p_sys = malloc (sizeof (*p_sys)); xcb_connection_t *conn = xcb_connect (NULL, NULL); if (p_sys == NULL || xcb_connection_has_error (conn)) goto error; p_sys->embedded = true; p_sys->keys = NULL; wnd->handle.xid = window; wnd->control = Control; wnd->sys = p_sys; p_sys->conn = conn; xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply (conn, xcb_get_geometry (conn, window), NULL); if (geo == NULL) { msg_Err (wnd, "bad X11 window 0x%08"PRIx8, window); goto error; } p_sys->root = geo->root; free (geo); if (var_InheritBool (wnd, "keyboard-events")) { p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn); if (p_sys->keys != NULL) { const uint32_t mask = XCB_CW_EVENT_MASK; const uint32_t values[1] = { XCB_EVENT_MASK_KEY_PRESS, }; xcb_change_window_attributes (conn, window, mask, values); } } CacheAtoms (p_sys); if ((p_sys->keys != NULL) && vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW)) DestroyKeyHandler (p_sys->keys); xcb_flush (conn); (void) cfg; return VLC_SUCCESS; error: xcb_disconnect (conn); free (p_sys); ReleaseDrawable (VLC_OBJECT(wnd), window); return VLC_EGENERIC; }
/* Open Interface */ static int Open( vlc_object_t *p_this, bool isDialogProvider ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; #ifdef Q_WS_X11 if( !vlc_xlib_init( p_this ) ) return VLC_EGENERIC; char *display = var_CreateGetNonEmptyString( p_intf, "x11-display" ); Display *p_display = XOpenDisplay( x11_display ); if( !p_display ) { msg_Err( p_intf, "Could not connect to X server" ); free (display); return VLC_EGENERIC; } XCloseDisplay( p_display ); #else char *display = NULL; #endif QMutexLocker locker (&lock); if (busy) { msg_Err (p_this, "cannot start Qt4 multiple times"); free (display); return VLC_EGENERIC; } /* Allocations of p_sys */ intf_sys_t *p_sys = p_intf->p_sys = new intf_sys_t; p_intf->p_sys->b_isDialogProvider = isDialogProvider; p_sys->p_mi = NULL; p_sys->p_playlist = pl_Get( p_intf ); /* */ #ifdef Q_WS_X11 x11_display = display; #endif vlc_sem_init (&ready, 0); if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { delete p_sys; free (display); return VLC_ENOMEM; } /* */ vlc_sem_wait (&ready); vlc_sem_destroy (&ready); busy = active = true; if( !p_sys->b_isDialogProvider ) { playlist_t *pl = pl_Get(p_this); var_Create (pl, "qt4-iface", VLC_VAR_ADDRESS); var_SetAddress (pl, "qt4-iface", p_this); } return VLC_SUCCESS; }
// Initialize interface. static int Open(vlc_object_t* p_this) { intf_thread_t* const p_intf = (intf_thread_t*)p_this; // Limit to one instance. if (FindWindow(L"CD Art Display IPC Class", L"VLC")) { p_intf->p_sys = NULL; return VLC_SUCCESS; } OutputDebugString(L"VLC Open"); intf_sys_t* const p_sys = (intf_sys_t*)calloc(1, sizeof(intf_sys_t)); if (!p_sys) { return VLC_ENOMEM; } p_intf->p_sys = p_sys; vlc_mutex_init(&p_sys->lock); if (vlc_clone(&p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW)) { vlc_mutex_destroy(&p_sys->lock); free(p_sys); p_intf->p_sys = NULL; return VLC_ENOMEM; } var_AddCallback(pl_Get(p_intf->p_libvlc), "input-current", PlaylistEvent, p_intf); return VLC_SUCCESS; }
/***************************************************************************** * vlc_thread_create: create a thread ***************************************************************************** * Note that i_priority is only taken into account on platforms supporting * userland real-time priority threads. *****************************************************************************/ int vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line, const char *psz_name, void *(*func) ( vlc_object_t * ), int i_priority ) { int i_ret; vlc_object_internals_t *p_priv = vlc_internals( p_this ); struct vlc_thread_boot *boot = malloc (sizeof (*boot)); if (boot == NULL) return errno; boot->entry = func; boot->object = p_this; /* Make sure we don't re-create a thread if the object has already one */ assert( !p_priv->b_thread ); p_priv->b_thread = true; i_ret = vlc_clone( &p_priv->thread_id, thread_entry, boot, i_priority ); if( i_ret == 0 ) msg_Dbg( p_this, "thread (%s) created at priority %d (%s:%d)", psz_name, i_priority, psz_file, i_line ); else { p_priv->b_thread = false; errno = i_ret; msg_Err( p_this, "%s thread could not be created at %s:%d (%m)", psz_name, psz_file, i_line ); } return i_ret; }
/***************************************************************************** * OpenIntf: initialise 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( *p_sys ) ); if( unlikely(p_sys == NULL) ) return VLC_ENOMEM; p_sys->p_motion = motion_create( VLC_OBJECT( p_intf ) ); if( p_sys->p_motion == NULL ) { error: free( p_sys ); return VLC_EGENERIC; } p_intf->p_sys = p_sys; if( vlc_clone( &p_sys->thread, RunIntf, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { motion_destroy( p_sys->p_motion ); goto error; } return VLC_SUCCESS; }
static int Open(vlc_object_t *obj) { intf_thread_t *intf = (intf_thread_t *)obj; intf_sys_t *sys = malloc(sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; intf->p_sys = sys; /* Run the helper thread */ sys->ready = CreateEvent(NULL, FALSE, FALSE, NULL); if (vlc_clone(&sys->thread, HelperThread, intf, VLC_THREAD_PRIORITY_LOW)) { free(sys); msg_Err(intf, "one instance mode DISABLED " "(IPC helper thread couldn't be created)"); return VLC_ENOMEM; } WaitForSingleObject(sys->ready, INFINITE); CloseHandle(sys->ready); return VLC_SUCCESS; }
/***************************************************************************** * Open: Starts the RTSP server module *****************************************************************************/ int OpenVoD( vlc_object_t *p_this ) { vod_t *p_vod = (vod_t *)p_this; vod_sys_t *p_sys = NULL; char *psz_url; p_vod->p_sys = p_sys = malloc( sizeof( vod_sys_t ) ); if( !p_sys ) goto error; psz_url = var_InheritString( p_vod, "rtsp-host" ); if( psz_url == NULL ) p_sys->psz_rtsp_path = strdup( "/" ); else { vlc_url_t url; vlc_UrlParse( &url, psz_url, 0 ); free( psz_url ); if( url.psz_path == NULL ) p_sys->psz_rtsp_path = strdup( "/" ); else if( !( strlen( url.psz_path ) > 0 && url.psz_path[strlen( url.psz_path ) - 1] == '/' ) ) { if( asprintf( &p_sys->psz_rtsp_path, "%s/", url.psz_path ) == -1 ) { p_sys->psz_rtsp_path = NULL; vlc_UrlClean( &url ); goto error; } } else p_sys->psz_rtsp_path = strdup( url.psz_path ); vlc_UrlClean( &url ); } p_vod->pf_media_new = MediaNew; p_vod->pf_media_del = MediaAskDel; p_sys->p_fifo_cmd = block_FifoNew(); if( vlc_clone( &p_sys->thread, CommandThread, p_vod, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_vod, "cannot spawn rtsp vod thread" ); block_FifoRelease( p_sys->p_fifo_cmd ); goto error; } return VLC_SUCCESS; error: if( p_sys ) { free( p_sys->psz_rtsp_path ); free( p_sys ); } return VLC_EGENERIC; }
static MOVIESOAP_CALLBACK(InputCbState) { #ifdef MSDEBUG3 msg_Info( p_this, "!!! CALLBACK input state !!! : %s ... new: %d ... old: %d", psz_var, (int) newval.i_int, (int) oldval.i_int ); #endif // Stop or Start filter if (p_loadedFilter) { // spawn new thread to handle Filter restart if (newval.i_int == PLAYING_S) vlc_clone( &thread_for_filter_restart, EP_StartFilter, NULL, VLC_THREAD_PRIORITY_LOW ); else vlc_clone( &thread_for_filter_restart, EP_KillTimers, NULL, VLC_THREAD_PRIORITY_LOW ); } return 0; }
static int Open(vlc_object_t *obj) { intf_thread_t *intf = (intf_thread_t *)obj; intf_sys_t *sys = malloc(sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; intf->p_sys = sys; sys->server = var_InheritString(intf, "server"); sys->channel = var_InheritString(intf, "channel"); sys->nick = var_InheritString(intf, "nick"); if(sys->server == NULL) { msg_Err(intf, "No server specified, use --server"); return VLC_SUCCESS; } if(sys->channel == NULL) { msg_Err(intf, "No channel specified, use --channel"); return VLC_SUCCESS; } if(sys->nick == NULL) { msg_Err(intf, "No nickname specified, use --nick"); return VLC_SUCCESS; } if(vlc_clone(&sys->thread, Run, intf, VLC_THREAD_PRIORITY_LOW)) { return VLC_ENOMEM; } return VLC_SUCCESS; }
/** * Subscribe to the message queue. * Whenever a message is emitted, a callback will be called. * Callback invocation are serialized within a subscription. * * @param instance LibVLC instance to get messages from * @param cb callback function * @param opaque data for the callback function * @return a subscription pointer, or NULL in case of failure */ msg_subscription_t *msg_Subscribe (libvlc_int_t *instance, msg_callback_t cb, msg_cb_data_t *opaque) { msg_subscription_t *sub = malloc (sizeof (*sub)); if (sub == NULL) return NULL; sub->instance = instance; sub->func = cb; sub->opaque = opaque; sub->begin = sub->end = sub->overruns = 0; if (vlc_clone (&sub->thread, msg_thread, sub, VLC_THREAD_PRIORITY_LOW)) { free (sub); return NULL; } msg_bank_t *bank = libvlc_bank (instance); vlc_mutex_lock (&bank->lock); TAB_APPEND (bank->i_sub, bank->pp_sub, sub); vlc_mutex_unlock (&bank->lock); return sub; }
static void *vlc_timer_thread (void *data) { struct vlc_timer *timer = data; mtime_t value, interval; vlc_mutex_lock (&timer->lock); value = timer->value; interval = timer->interval; vlc_mutex_unlock (&timer->lock); for (;;) { vlc_thread_t th; mwait (value); vlc_mutex_lock (&timer->lock); if (vlc_clone (&th, vlc_timer_do, timer, VLC_THREAD_PRIORITY_INPUT)) timer->overruns++; else { vlc_detach (th); timer->users++; } vlc_mutex_unlock (&timer->lock); if (interval == 0) return NULL; value += interval; } }
struct vlc_h2_output *vlc_h2_output_create(struct vlc_tls *tls, bool client) { struct vlc_h2_output *out = malloc(sizeof (*out)); if (unlikely(out == NULL)) return NULL; out->tls = tls; out->prio.first = NULL; out->prio.last = &out->prio.first; out->queue.first = NULL; out->queue.last = &out->queue.first; out->size = 0; out->failed = false; out->closing = false; vlc_mutex_init(&out->lock); vlc_cond_init(&out->wait); void *(*cb)(void *) = client ? vlc_h2_client_output_thread : vlc_h2_output_thread; if (vlc_clone(&out->thread, cb, out, VLC_THREAD_PRIORITY_INPUT)) { vlc_cond_destroy(&out->wait); vlc_mutex_destroy(&out->lock); free(out); out = NULL; } return out; }
vlc_demux_chained_t *vlc_demux_chained_New(vlc_object_t *parent, const char *name, es_out_t *out) { vlc_demux_chained_t *dc = malloc(sizeof (*dc) + strlen(name) + 1); if (unlikely(dc == NULL)) return NULL; dc->writer = vlc_stream_fifo_New(parent, &dc->reader); if (dc->writer == NULL) { free(dc); return NULL; } dc->stats.position = 0.; dc->stats.length = 0; dc->stats.time = 0; dc->out = out; strcpy(dc->name, name); vlc_mutex_init(&dc->lock); if (vlc_clone(&dc->thread, vlc_demux_chained_Thread, dc, VLC_THREAD_PRIORITY_INPUT)) { vlc_stream_Delete(dc->reader); vlc_stream_fifo_Close(dc->writer); vlc_mutex_destroy(&dc->lock); free(dc); dc = NULL; } return dc; }
/***************************************************************************** * Open: initialize and create stuff *****************************************************************************/ static int Open( vlc_object_t *p_this ) { services_discovery_t *p_sd = ( services_discovery_t * )p_this; services_discovery_sys_t *p_sys; if( !( p_sys = malloc( sizeof( services_discovery_sys_t ) ) ) ) return VLC_ENOMEM; p_sd->p_sys = p_sys; p_sd->description = _("MTP devices"); p_sys->psz_name = NULL; vlc_mutex_lock( &mtp_lock ); if( !b_mtp_initialized ) { LIBMTP_Init(); b_mtp_initialized = true; } vlc_mutex_unlock( &mtp_lock ); if (vlc_clone (&p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW)) { free (p_sys); return VLC_EGENERIC; } return VLC_SUCCESS; }
int vlc_timer_create (vlc_timer_t *id, void (*func) (void *), void *data) { struct vlc_timer *timer = malloc (sizeof (*timer)); if (unlikely(timer == NULL)) return ENOMEM; vlc_mutex_init (&timer->lock); vlc_cond_init (&timer->reschedule); assert (func); timer->func = func; timer->data = data; timer->value = 0; timer->interval = 0; atomic_init(&timer->overruns, 0); if (vlc_clone (&timer->thread, vlc_timer_thread, timer, VLC_THREAD_PRIORITY_INPUT)) { vlc_cond_destroy (&timer->reschedule); vlc_mutex_destroy (&timer->lock); free (timer); return ENOMEM; } *id = timer; return 0; }
static sap_address_t *AddressCreate (vlc_object_t *obj, const char *group) { int fd = net_ConnectUDP (obj, group, IPPORT_SAP, 255); if (fd == -1) return NULL; sap_address_t *addr = malloc (sizeof (*addr)); if (addr == NULL) { net_Close (fd); return NULL; } strlcpy (addr->group, group, sizeof (addr->group)); addr->fd = fd; addr->origlen = sizeof (addr->orig); getsockname (fd, (struct sockaddr *)&addr->orig, &addr->origlen); addr->interval = var_CreateGetInteger (obj, "sap-interval"); vlc_mutex_init (&addr->lock); vlc_cond_init (&addr->wait); addr->session_count = 0; addr->first = NULL; if (vlc_clone (&addr->thread, RunThread, addr, VLC_THREAD_PRIORITY_LOW)) { msg_Err (obj, "unable to spawn SAP announce thread"); net_Close (fd); free (addr); return NULL; } return addr; }
/***************************************************************************** * 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)); if (!p_sys) return VLC_ENOMEM; p_intf->p_sys = p_sys; vlc_mutex_init(&p_sys->lock); vlc_cond_init(&p_sys->wait); if (vlc_clone(&p_sys->thread, Run, p_intf, VLC_THREAD_PRIORITY_LOW)) { vlc_cond_destroy(&p_sys->wait); vlc_mutex_destroy(&p_sys->lock); free(p_sys); return VLC_ENOMEM; } var_AddCallback(pl_Get(p_intf), "activity", ItemChange, p_intf); return VLC_SUCCESS; }
/** * Arm or disarm an initialized timer. * This functions overrides any previous call to itself. * * @note A timer can fire later than requested due to system scheduling * limitations. An interval timer can fail to trigger sometimes, either because * the system is busy or suspended, or because a previous iteration of the * timer is still running. See also vlc_timer_getoverrun(). * * @param timer initialized timer * @param absolute the timer value origin is the same as mdate() if true, * the timer value is relative to now if false. * @param value zero to disarm the timer, otherwise the initial time to wait * before firing the timer. * @param interval zero to fire the timer just once, otherwise the timer * repetition interval. */ void vlc_timer_schedule (vlc_timer_t timer, bool absolute, mtime_t value, mtime_t interval) { static vlc_mutex_t lock = VLC_STATIC_MUTEX; vlc_mutex_lock (&lock); vlc_mutex_lock (&timer->lock); if (timer->value) { vlc_mutex_unlock (&timer->lock); vlc_cancel (timer->thread); vlc_join (timer->thread, NULL); vlc_mutex_lock (&timer->lock); timer->value = 0; } if ((value != 0) && (vlc_clone (&timer->thread, vlc_timer_thread, timer, VLC_THREAD_PRIORITY_INPUT) == 0)) { timer->value = (absolute ? 0 : mdate ()) + value; timer->interval = interval; } vlc_mutex_unlock (&timer->lock); vlc_mutex_unlock (&lock); }
/* Set Moviesoap::p_input using a new thread */ void spawn_set_p_input(bool force_overwrite) { if (p_obj) { if (p_playlist == NULL || p_input == NULL || force_overwrite) { vlc_clone( &thread_for_getting_input_thread, EP_SetMoviesoapP_Input, NULL, VLC_THREAD_PRIORITY_LOW ); } } }
/***************************************************************************** * Open: initialize module *****************************************************************************/ static int Open( vlc_object_t *p_this, enum type_e i_type ) { services_discovery_t *p_sd = ( services_discovery_t* )p_this; services_discovery_sys_t *p_sys; const char *desc; p_sd->p_sys = p_sys = calloc( 1, sizeof( *p_sys) ); if( !p_sys ) return VLC_ENOMEM; p_sys->i_type = i_type; if( p_sys->i_type == Video ) { desc = N_("My Videos"); p_sys->psz_dir[0] = config_GetUserDir( VLC_VIDEOS_DIR ); p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" ); p_sys->psz_var = "record-file"; } else if( p_sys->i_type == Audio ) { desc = N_("My Music"); p_sys->psz_dir[0] = config_GetUserDir( VLC_MUSIC_DIR ); p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" ); p_sys->psz_var = "record-file"; } else if( p_sys->i_type == Picture ) { desc = N_("My Pictures"); p_sys->psz_dir[0] = config_GetUserDir( VLC_PICTURES_DIR ); p_sys->psz_dir[1] = var_CreateGetString( p_sd, "snapshot-path" ); p_sys->psz_var = "snapshot-file"; } else { free( p_sys ); return VLC_EGENERIC; } p_sd->description = vlc_gettext(desc); var_AddCallback( p_sd->obj.libvlc, p_sys->psz_var, onNewFileAdded, p_sd ); if( vlc_clone( &p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW ) ) { var_DelCallback( p_sd->obj.libvlc, p_sys->psz_var, onNewFileAdded, p_sd ); free( p_sys->psz_dir[1] ); free( p_sys->psz_dir[0] ); free( p_sys ); return VLC_EGENERIC; } return VLC_SUCCESS; }
/***************************************************************************** * Open: *****************************************************************************/ static int Open( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys; p_intf->p_sys = p_sys = calloc( 1, sizeof(*p_sys) ); if( !p_sys ) return VLC_ENOMEM; char *psz_display = var_CreateGetNonEmptyString( p_intf, "x11-display" ); int i_screen_default; p_sys->p_connection = xcb_connect( psz_display, &i_screen_default ); free( psz_display ); if( !p_sys->p_connection ) goto error; /* Get the root windows of the default screen */ const xcb_setup_t* xcbsetup = xcb_get_setup( p_sys->p_connection ); if( !xcbsetup ) goto error; xcb_screen_iterator_t iter = xcb_setup_roots_iterator( xcbsetup ); for( int i = 0; i < i_screen_default; i++ ) { if( !iter.rem ) break; xcb_screen_next( &iter ); } if( !iter.rem ) goto error; p_sys->root = iter.data->root; /* */ p_sys->p_symbols = xcb_key_symbols_alloc( p_sys->p_connection ); // FIXME if( !p_sys->p_symbols ) goto error; Mapping( p_intf ); Register( p_intf ); if( vlc_clone( &p_sys->thread, Thread, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { Unregister( p_intf ); free( p_sys->p_map ); goto error; } return VLC_SUCCESS; error: if( p_sys->p_symbols ) xcb_key_symbols_free( p_sys->p_symbols ); if( p_sys->p_connection ) xcb_disconnect( p_sys->p_connection ); free( p_sys ); return VLC_EGENERIC; }
/** * 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; /* Test the audio format */ if( 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 ) ) { msg_Warn( p_filter, "input and outut are not similar" ); return VLC_EGENERIC; } p_filter->pf_audio_filter = DoWork; 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; } return VLC_SUCCESS; error: vlc_sem_destroy( &p_sys->ready ); free (p_sys ); return VLC_EGENERIC; }
stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *out ) { vlc_object_t *p_obj = VLC_OBJECT(p_demux); /* We create a stream reader, and launch a thread */ stream_t *s; stream_sys_t *p_sys; s = stream_CommonNew( p_obj ); if( s == NULL ) return NULL; s->p_input = p_demux->p_input; s->pf_read = DStreamRead; s->pf_control= DStreamControl; s->pf_destroy= DStreamDelete; s->p_sys = p_sys = malloc( sizeof( *p_sys) ); if( !s->p_sys ) { stream_Delete( s ); return NULL; } p_sys->i_pos = 0; p_sys->out = out; p_sys->p_block = NULL; p_sys->psz_name = strdup( psz_demux ); p_sys->stats.position = 0.; p_sys->stats.length = 0; p_sys->stats.time = 0; /* decoder fifo */ if( ( p_sys->p_fifo = block_FifoNew() ) == NULL ) { stream_Delete( s ); free( p_sys->psz_name ); free( p_sys ); return NULL; } atomic_init( &p_sys->active, true ); vlc_mutex_init( &p_sys->lock ); if( vlc_clone( &p_sys->thread, DStreamThread, s, VLC_THREAD_PRIORITY_INPUT ) ) { vlc_mutex_destroy( &p_sys->lock ); block_FifoRelease( p_sys->p_fifo ); stream_Delete( s ); free( p_sys->psz_name ); free( p_sys ); return NULL; } return s; }
/** * Creates the main playlist thread. */ void playlist_Activate( playlist_t *p_playlist ) { playlist_private_t *p_sys = pl_priv(p_playlist); if( vlc_clone( &p_sys->thread, Thread, p_playlist, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_playlist, "cannot spawn playlist thread" ); abort(); } }
/** * 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 == NULL) return VLC_ENOMEM; /* Create the object for the thread */ vlc_sem_init(&p_sys->ready, 0); p_sys->b_error = false; p_sys->i_width = var_InheritInteger(p_filter, "glspectrum-width"); p_sys->i_height = var_InheritInteger(p_filter, "glspectrum-height"); p_sys->i_channels = aout_FormatNbChannels(&p_filter->fmt_in.audio); p_sys->i_prev_nb_samples = 0; p_sys->p_prev_s16_buff = NULL; p_sys->f_rotationAngle = 0; p_sys->f_rotationIncrement = ROTATION_INCREMENT; /* Fetch the FFT window parameters */ window_get_param( VLC_OBJECT( p_filter ), &p_sys->wind_param ); /* Create the FIFO for the audio data. */ p_sys->fifo = block_FifoNew(); if (p_sys->fifo == NULL) goto error; /* Create the thread */ if (vlc_clone(&p_sys->thread, Thread, p_filter, VLC_THREAD_PRIORITY_VIDEO)) goto error; /* Wait for the displaying thread to be ready. */ 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 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; /* Test the audio format */ if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ) { msg_Warn( p_filter, "bad input format" ); return VLC_EGENERIC; } p_sys = p_filter->p_sys = (filter_sys_t*)malloc( sizeof( *p_sys ) ); if( unlikely( !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, "vsxu-width" ); p_sys->i_height = var_InheritInteger( p_filter, "vsxu-height" ); p_sys->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio ); vlc_mutex_init( &p_sys->lock ); vlc_mutex_init( &p_sys->cyclic_block_mutex ); p_sys->vsxu_cyclic_buffer = new cyclic_block_queue(); /* 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_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; }
/** * Create the main playlist threads. * Additionally to the playlist, this thread controls : * - Statistics * - VLM * \param p_parent * \return an object with a started thread */ void playlist_Activate( playlist_t *p_playlist ) { /* */ playlist_private_t *p_sys = pl_priv(p_playlist); /* Start the playlist thread */ if( vlc_clone( &p_sys->thread, Thread, p_playlist, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_playlist, "cannot spawn playlist thread" ); } msg_Dbg( p_playlist, "playlist threads correctly activated" ); }
/* Fires when someone moves forward or backward or when program sets Time. - Restart loaded Filter. */ static MOVIESOAP_CALLBACK(InputCbTime) { #ifdef MSDEBUG3 msg_Info( p_this, "!!! CALLBACK input time !!! : %s ... new: %d ... old: %d", psz_var, (int) newval.i_int, (int) oldval.i_int ); #endif if (p_loadedFilter) { // sets new time to a heap variable target_time = newval.i_time; // spawn new thread to handle Filter restart vlc_clone( &thread_for_filter_restart, EP_StopAndStartFilter, NULL, VLC_THREAD_PRIORITY_LOW ); } return 0; }