/** * @brief VLC module construct callback * @return */ static int y4m_open(vlc_object_t* obj) { filter_t* intf = (filter_t*)obj; // todo: defer this check until we know if its needed or not if( !intf->b_allow_fmt_out_change ) { msg_Err(intf, "picture format change isn't allowed"); return VLC_EGENERIC; } filter_sys_t* sys = malloc(sizeof(*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; intf->p_sys = sys; memset(sys, 0, sizeof(*sys)); sys->cmd = var_InheritString(intf, "y4m-cmd"); if (sys->cmd == NULL) { msg_Err(intf, "argument parse failed"); free(sys); return VLC_EGENERIC; } sys->echo = var_InheritBool(intf, "y4m-echo"); sys->stdin = -1; sys->stdout = -1; sys->bufferRatio = 1; msg_Info(intf, "open"); sys->inputFifo = picture_fifo_New(); sys->outputFifo = picture_fifo_New(); vlc_cond_init(&sys->inputCond); vlc_cond_init(&sys->outputCond); vlc_mutex_init(&sys->inputMutex); vlc_mutex_init(&sys->outputMutex); intf->pf_video_filter = y4m_filter; intf->pf_flush = y4m_flush; // todo: the conversion needed isn't known until // a frame is read back from the filter, for now // filters in/out format needs to be the same //intf->fmt_out.video.i_frame_rate *= 2; //intf->fmt_out.i_codec = VLC_CODEC_I420; //intf->fmt_out.video.i_chroma = VLC_CODEC_I420; return VLC_SUCCESS; }
/** * @brief Directory Monitoring thread loop */ void *RunMonitoringThread( void *p_this ) { monitoring_thread_t *p_mon = (monitoring_thread_t*) p_this; vlc_cond_init( &p_mon->wait ); vlc_mutex_init( &p_mon->lock ); var_Create( p_mon, "ml-recursive-scan", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); while( vlc_object_alive( p_mon ) ) { vlc_mutex_lock( &p_mon->lock ); /* Update */ UpdateLibrary( p_mon ); /* We wait MONITORING_DELAY seconds or wait that the media library signals us to do something */ vlc_cond_timedwait( &p_mon->wait, &p_mon->lock, mdate() + 1000000*MONITORING_DELAY ); vlc_mutex_unlock( &p_mon->lock ); } vlc_cond_destroy( &p_mon->wait ); vlc_mutex_destroy( &p_mon->lock ); return NULL; }
/** * Initialize messages queues * This function initializes all message queues */ void msg_Create (libvlc_int_t *p_libvlc) { libvlc_priv_t *priv = libvlc_priv (p_libvlc); msg_bank_t *bank = libvlc_bank (p_libvlc); vlc_mutex_init (&bank->lock); vlc_cond_init (&bank->wait); vlc_dictionary_init( &priv->msg_enabled_objects, 0 ); priv->msg_all_objects_enabled = true; QUEUE.i_sub = 0; QUEUE.pp_sub = NULL; #ifdef UNDER_CE QUEUE.logfile = CreateFile( L"vlc-log.txt", GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL ); SetFilePointer( QUEUE.logfile, 0, NULL, FILE_END ); #endif vlc_mutex_lock( &msg_stack_lock ); if( banks++ == 0 ) vlc_threadvar_create( &msg_context, cleanup_msg_context ); vlc_mutex_unlock( &msg_stack_lock ); }
static void test_cancel_thumbnail( libvlc_instance_t* p_vlc ) { vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create( VLC_OBJECT( p_vlc->p_libvlc_int ) ); assert( p_thumbnailer != NULL ); struct test_ctx ctx; vlc_cond_init( &ctx.cond ); vlc_mutex_init( &ctx.lock ); const char* psz_mrl = "mock://video_track_count=1;audio_track_count=1"; input_item_t* p_item = input_item_New( psz_mrl, "mock item" ); assert( p_item != NULL ); vlc_mutex_lock( &ctx.lock ); int res = 0; vlc_thumbnailer_request_t* p_req = vlc_thumbnailer_RequestByTime( p_thumbnailer, VLC_TICK_FROM_SEC( 1 ), VLC_THUMBNAILER_SEEK_PRECISE, p_item, VLC_TICK_INVALID, thumbnailer_callback_cancel, &ctx ); vlc_thumbnailer_Cancel( p_thumbnailer, p_req ); while ( ctx.b_done == false ) { vlc_tick_t timeout = vlc_tick_now() + VLC_TICK_FROM_SEC( 1 ); res = vlc_cond_timedwait( &ctx.cond, &ctx.lock, timeout ); assert( res != ETIMEDOUT ); } vlc_mutex_unlock( &ctx.lock ); input_item_Release( p_item ); vlc_thumbnailer_Release( p_thumbnailer ); }
//BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI _CRT_INIT (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) // sunqueen modify { (void) hinstDll; (void) lpvReserved; switch (fdwReason) { case DLL_PROCESS_ATTACH: InitializeCriticalSection (&clock_lock); vlc_mutex_init (&super_mutex); vlc_cond_init (&super_variable); vlc_threadvar_create (&thread_key, NULL); vlc_rwlock_init (&config_lock); vlc_CPU_init (); break; case DLL_PROCESS_DETACH: vlc_rwlock_destroy (&config_lock); vlc_threadvar_delete (&thread_key); vlc_cond_destroy (&super_variable); vlc_mutex_destroy (&super_mutex); DeleteCriticalSection (&clock_lock); break; } return TRUE; }
static struct decklink_sys_t *GetDLSys(vlc_object_t *obj) { vlc_object_t *libvlc = VLC_OBJECT(obj->p_libvlc); struct decklink_sys_t *sys; vlc_mutex_lock(&sys_lock); if (var_Type(libvlc, "decklink-sys") == VLC_VAR_ADDRESS) sys = (struct decklink_sys_t*)var_GetAddress(libvlc, "decklink-sys"); else { sys = (struct decklink_sys_t*)malloc(sizeof(*sys)); if (sys) { sys->p_output = NULL; sys->offset = 0; sys->users = 0; sys->i_rate = -1; vlc_mutex_init(&sys->lock); vlc_cond_init(&sys->cond); var_Create(libvlc, "decklink-sys", VLC_VAR_ADDRESS); var_SetAddress(libvlc, "decklink-sys", (void*)sys); } } vlc_mutex_unlock(&sys_lock); return sys; }
/* SRW (Slim Read Write) locks are available in Vista+ only */ void vlc_rwlock_init (vlc_rwlock_t *lock) { vlc_mutex_init (&lock->mutex); vlc_cond_init (&lock->wait); lock->readers = 0; /* active readers */ lock->writer = 0; /* ID of active writer */ }
/***************************************************************************** * 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; }
BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) { (void) hinstDll; (void) lpvReserved; switch (fdwReason) { case DLL_PROCESS_ATTACH: #if (_WIN32_WINNT < 0x0601) if (!QueryPerformanceFrequency (&freq)) return FALSE; #endif vlc_mutex_init (&super_mutex); vlc_cond_init (&super_variable); vlc_threadvar_create (&thread_key, NULL); vlc_rwlock_init (&config_lock); vlc_rwlock_init (&msg_lock); vlc_CPU_init (); break; case DLL_PROCESS_DETACH: vlc_rwlock_destroy (&msg_lock); vlc_rwlock_destroy (&config_lock); vlc_threadvar_delete (&thread_key); vlc_cond_destroy (&super_variable); vlc_mutex_destroy (&super_mutex); break; } return TRUE; }
int vlc_mwait_i11e(mtime_t deadline) { vlc_interrupt_t *ctx = vlc_threadvar_get(vlc_interrupt_var); if (ctx == NULL) return mwait(deadline), 0; vlc_cond_t wait; vlc_cond_init(&wait); int ret = vlc_interrupt_prepare(ctx, vlc_mwait_i11e_wake, &wait); if (ret) { vlc_cond_destroy(&wait); vlc_testcancel(); return ret; } vlc_mutex_lock(&ctx->lock); vlc_cleanup_push(vlc_mwait_i11e_cleanup, ctx); while (!ctx->interrupted && vlc_cond_timedwait(&wait, &ctx->lock, deadline) == 0); vlc_cleanup_pop(); vlc_mutex_unlock(&ctx->lock); ret = vlc_interrupt_finish(ctx); vlc_cond_destroy(&wait); return ret; }
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; }
event_thread_t *EventThreadCreate( vout_display_t *vd) { /* Create the Vout EventThread, this thread is created by us to isolate * the Win32 PeekMessage function calls. We want to do this because * Windows can stay blocked inside this call for a long time, and when * this happens it thus blocks vlc's video_output thread. * Vout EventThread will take care of the creation of the video * window (because PeekMessage has to be called from the same thread which * created the window). */ msg_Dbg( vd, "creating Vout EventThread" ); event_thread_t *p_event = malloc( sizeof(*p_event) ); if( !p_event ) return NULL; p_event->vd = vd; vlc_mutex_init( &p_event->lock ); vlc_cond_init( &p_event->wait ); p_event->is_cursor_hidden = false; p_event->button_pressed = 0; p_event->psz_title = NULL; p_event->source = vd->source; vout_display_PlacePicture(&p_event->place, &vd->source, vd->cfg, false); _snprintf( p_event->class_main, sizeof(p_event->class_main)/sizeof(*p_event->class_main), _T("VLC MSW %p"), p_event ); _snprintf( p_event->class_video, sizeof(p_event->class_video)/sizeof(*p_event->class_video), _T("VLC MSW video %p"), p_event ); return p_event; }
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; }
unsigned long _System _DLL_InitTerm(unsigned long hmod, unsigned long flag) { VLC_UNUSED (hmod); switch (flag) { case 0 : /* Initialization */ if(_CRT_init() == -1) return 0; vlc_mutex_init (&super_mutex); vlc_cond_init (&super_variable); vlc_threadvar_create (&thread_key, NULL); vlc_rwlock_init (&config_lock); vlc_rwlock_init (&msg_lock); vlc_CPU_init (); return 1; case 1 : /* Termination */ vlc_rwlock_destroy (&msg_lock); vlc_rwlock_destroy (&config_lock); vlc_threadvar_delete (&thread_key); vlc_cond_destroy (&super_variable); vlc_mutex_destroy (&super_mutex); _CRT_term(); return 1; } return 0; /* Failed */ }
/***************************************************************************** * Open: *****************************************************************************/ static int Open(vlc_object_t *p_this) { fingerprinter_thread_t *p_fingerprinter = (fingerprinter_thread_t*) p_this; fingerprinter_sys_t *p_sys = calloc(1, sizeof(fingerprinter_sys_t)); if ( !p_sys ) return VLC_ENOMEM; p_fingerprinter->p_sys = p_sys; p_sys->incoming.queue = vlc_array_new(); vlc_mutex_init( &p_sys->incoming.lock ); vlc_cond_init( &p_sys->incoming_queue_filled ); p_sys->processing.queue = vlc_array_new(); vlc_mutex_init( &p_sys->processing.lock ); p_sys->results.queue = vlc_array_new(); vlc_mutex_init( &p_sys->results.lock ); vlc_mutex_init( &p_sys->condwait.lock ); vlc_cond_init( &p_sys->condwait.wait ); p_sys->psz_uri = NULL; p_fingerprinter->pf_run = Run; p_fingerprinter->pf_enqueue = EnqueueRequest; p_fingerprinter->pf_getresults = GetResult; p_fingerprinter->pf_apply = ApplyResult; var_Create( p_fingerprinter, "results-available", VLC_VAR_BOOL ); if( p_fingerprinter->pf_run && vlc_clone( &p_sys->thread, (void *(*) (void *)) p_fingerprinter->pf_run, p_fingerprinter, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_fingerprinter, "cannot spawn fingerprinter thread" ); goto error; } return VLC_SUCCESS; error: free( p_sys ); return VLC_EGENERIC; }
CThread::CThread(vlc_object_t *pOwner) { m_bTerminated = ATMO_FALSE; vlc_mutex_init( &m_TerminateLock ); vlc_cond_init( &m_TerminateCond ); m_pOwner = pOwner; m_HasThread = ATMO_FALSE; }
static void test_thumbnails( libvlc_instance_t* p_vlc ) { vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create( VLC_OBJECT( p_vlc->p_libvlc_int ) ); assert( p_thumbnailer != NULL ); struct test_ctx ctx; vlc_cond_init( &ctx.cond ); vlc_mutex_init( &ctx.lock ); for ( size_t i = 0; i < sizeof(test_params) / sizeof(test_params[0]); ++i) { char* psz_mrl; ctx.test_idx = i; ctx.b_done = false; if ( asprintf( &psz_mrl, "mock://video_track_count=%u;audio_track_count=%u" ";length=%" PRId64 ";video_chroma=ARGB;add_video_track_at=%" PRId64, test_params[i].i_nb_video_tracks, test_params[i].i_nb_audio_tracks, MOCK_DURATION, test_params[i].i_add_video_track_at ) < 0 ) assert( !"Failed to allocate mock mrl" ); input_item_t* p_item = input_item_New( psz_mrl, "mock item" ); assert( p_item != NULL ); vlc_mutex_lock( &ctx.lock ); int res = 0; if ( test_params[i].b_use_pos ) { vlc_thumbnailer_RequestByPos( p_thumbnailer, test_params[i].f_pos, test_params[i].b_fast_seek ? VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE, p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx ); } else { vlc_thumbnailer_RequestByTime( p_thumbnailer, test_params[i].i_time, test_params[i].b_fast_seek ? VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE, p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx ); } while ( ctx.b_done == false ) { vlc_tick_t timeout = vlc_tick_now() + VLC_TICK_FROM_SEC( 1 ); res = vlc_cond_timedwait( &ctx.cond, &ctx.lock, timeout ); assert( res != ETIMEDOUT ); } vlc_mutex_unlock( &ctx.lock ); input_item_Release( p_item ); free( psz_mrl ); } vlc_thumbnailer_Release( p_thumbnailer ); }
void vout_snapshot_Init(vout_snapshot_t *snap) { vlc_mutex_init(&snap->lock); vlc_cond_init(&snap->wait); snap->is_available = true; snap->request_count = 0; snap->picture = NULL; }
static picture_t *picture_pool_ClonePicture(picture_pool_t *pool, unsigned offset) { picture_t *picture = pool->picture[offset]; uintptr_t sys = ((uintptr_t)pool) + offset; picture_resource_t res = { .p_sys = picture->p_sys, .pf_destroy = picture_pool_ReleasePicture, }; for (int i = 0; i < picture->i_planes; i++) { res.p[i].p_pixels = picture->p[i].p_pixels; res.p[i].i_lines = picture->p[i].i_lines; res.p[i].i_pitch = picture->p[i].i_pitch; } picture_t *clone = picture_NewFromResource(&picture->format, &res); if (likely(clone != NULL)) { ((picture_priv_t *)clone)->gc.opaque = (void *)sys; picture_Hold(picture); } return clone; } picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg) { if (unlikely(cfg->picture_count > pool_max)) return NULL; picture_pool_t *pool = vlc_memalign(pool_max, sizeof (*pool) + cfg->picture_count * sizeof (picture_t *)); if (unlikely(pool == NULL)) return NULL; pool->pic_lock = cfg->lock; pool->pic_unlock = cfg->unlock; vlc_mutex_init(&pool->lock); vlc_cond_init(&pool->wait); pool->available = (1ULL << cfg->picture_count) - 1; atomic_init(&pool->refs, 1); pool->picture_count = cfg->picture_count; memcpy(pool->picture, cfg->picture, cfg->picture_count * sizeof (picture_t *)); pool->canceled = false; return pool; } picture_pool_t *picture_pool_New(unsigned count, picture_t *const *tab) { picture_pool_configuration_t cfg = { .picture_count = count, .picture = tab, }; return picture_pool_NewExtended(&cfg); }
intf_sys_t::intf_sys_t(sout_stream_t * const p_this) : p_stream(p_this) , p_tls(NULL) , conn_status(CHROMECAST_DISCONNECTED) , i_receiver_requestId(0) , i_requestId(0) { vlc_mutex_init(&lock); vlc_cond_init(&loadCommandCond); }
/************************************************************************** * Create a new media descriptor object from an input_item * (libvlc internal) * That's the generic constructor **************************************************************************/ libvlc_media_t * libvlc_media_new_from_input_item( libvlc_instance_t *p_instance, input_item_t *p_input_item ) { libvlc_media_t * p_md; if (!p_input_item) { libvlc_printerr( "No input item given" ); return NULL; } p_md = calloc( 1, sizeof(libvlc_media_t) ); if( !p_md ) { libvlc_printerr( "Not enough memory" ); return NULL; } p_md->p_libvlc_instance = p_instance; p_md->p_input_item = p_input_item; p_md->i_refcount = 1; vlc_cond_init(&p_md->parsed_cond); vlc_mutex_init(&p_md->parsed_lock); vlc_mutex_init(&p_md->subitems_lock); p_md->state = libvlc_NothingSpecial; /* A media descriptor can be a playlist. When you open a playlist * It can give a bunch of item to read. */ p_md->p_subitems = NULL; p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance ); if( unlikely(p_md->p_event_manager == NULL) ) { free(p_md); return NULL; } libvlc_event_manager_t *em = p_md->p_event_manager; libvlc_event_manager_register_event_type(em, libvlc_MediaMetaChanged); libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemAdded); libvlc_event_manager_register_event_type(em, libvlc_MediaFreed); libvlc_event_manager_register_event_type(em, libvlc_MediaDurationChanged); libvlc_event_manager_register_event_type(em, libvlc_MediaStateChanged); libvlc_event_manager_register_event_type(em, libvlc_MediaParsedChanged); libvlc_event_manager_register_event_type(em, libvlc_MediaSubItemTreeAdded); vlc_gc_incref( p_md->p_input_item ); install_input_item_observer( p_md ); return p_md; }
/************************************************************************** * 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; } }
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; }
/** * Creates a stream. * * Allocates a locally-initiated stream identifier on an HTTP/2 connection and * queue stream headers for sending. * * Headers are sent asynchronously. To obtain the result and answer from the * other end, use vlc_http_stream_recv_headers(). * * \param msg HTTP message headers (including response status or request) * \return an HTTP stream, or NULL on error */ struct vlc_http_stream *vlc_h2_stream_open(struct vlc_h2_conn *conn, const struct vlc_http_msg *msg) { struct vlc_h2_stream *s = malloc(sizeof (*s)); if (unlikely(s == NULL)) return NULL; s->stream.cbs = &vlc_h2_stream_callbacks; s->conn = conn; s->newer = NULL; s->recv_end = false; s->recv_hdr = NULL; s->recv_cwnd = VLC_H2_INIT_WINDOW; s->recv_head = NULL; s->recv_tailp = &s->recv_head; vlc_cond_init(&s->recv_wait); vlc_mutex_lock(&conn->lock); assert(!conn->released); /* Caller is buggy! */ if (conn->next_id > 0x7ffffff) { /* Out of stream identifiers */ msg_Dbg(CO(conn), "no more stream identifiers"); goto error; } s->id = conn->next_id; conn->next_id += 2; struct vlc_h2_frame *f = vlc_http_msg_h2_frame(msg, s->id, true); if (f == NULL) goto error; vlc_h2_output_send(conn->out, f); s->older = conn->streams; if (s->older != NULL) s->older->newer = s; conn->streams = s; vlc_mutex_unlock(&conn->lock); return &s->stream; error: vlc_mutex_unlock(&conn->lock); vlc_cond_destroy(&s->recv_wait); free(s); return NULL; }
void mwait (mtime_t deadline) { vlc_mutex_t lock; vlc_cond_t wait; vlc_mutex_init (&lock); vlc_cond_init (&wait); vlc_mutex_lock (&lock); mutex_cleanup_push (&lock); while (!vlc_cond_timedwait (&wait, &lock, deadline)); vlc_cleanup_run (); vlc_cond_destroy (&wait); vlc_mutex_destroy (&lock); }
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; 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 */ vlc_array_append(&p_provider->dialog_array, p_id); return p_id; }
CThread::CThread(vlc_object_t *pOwner) { m_bTerminated = ATMO_FALSE; m_pAtmoThread = (atmo_thread_t *)vlc_object_create( pOwner, sizeof(atmo_thread_t) ); if(m_pAtmoThread) { m_pAtmoThread->p_thread = this; this->m_pOwner = pOwner; vlc_object_attach( m_pAtmoThread, m_pOwner); vlc_mutex_init( &m_TerminateLock ); vlc_cond_init( &m_TerminateCond ); } }
/***************************************************************************** * Public functions *****************************************************************************/ playlist_preparser_t *playlist_preparser_New( playlist_t *p_playlist, playlist_fetcher_t *p_fetcher ) { playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) ); if( !p_preparser ) return NULL; p_preparser->p_playlist = p_playlist; p_preparser->p_fetcher = p_fetcher; vlc_mutex_init( &p_preparser->lock ); vlc_cond_init( &p_preparser->wait ); p_preparser->b_live = false; p_preparser->i_art_policy = var_GetInteger( p_playlist, "album-art" ); p_preparser->i_waiting = 0; p_preparser->pp_waiting = NULL; return p_preparser; }
/************************************************************************** * new (Public) **************************************************************************/ libvlc_media_list_player_t * libvlc_media_list_player_new(libvlc_instance_t * p_instance) { libvlc_media_list_player_t * p_mlp; p_mlp = calloc( 1, sizeof(libvlc_media_list_player_t) ); if (unlikely(p_mlp == NULL)) { libvlc_printerr("Not enough memory"); return NULL; } p_mlp->i_refcount = 1; p_mlp->seek_offset = 0; vlc_mutex_init(&p_mlp->object_lock); vlc_mutex_init(&p_mlp->mp_callback_lock); vlc_cond_init(&p_mlp->seek_pending); p_mlp->p_event_manager = libvlc_event_manager_new(p_mlp); if (unlikely(p_mlp->p_event_manager == NULL)) goto error; /* Create the underlying media_player */ p_mlp->p_mi = libvlc_media_player_new(p_instance); if( p_mlp->p_mi == NULL ) { libvlc_event_manager_release(p_mlp->p_event_manager); goto error; } install_media_player_observer(p_mlp); if (vlc_clone(&p_mlp->thread, playlist_thread, p_mlp, VLC_THREAD_PRIORITY_LOW)) { libvlc_media_player_release(p_mlp->p_mi); libvlc_event_manager_release(p_mlp->p_event_manager); goto error; } return p_mlp; error: vlc_cond_destroy(&p_mlp->seek_pending); vlc_mutex_destroy(&p_mlp->mp_callback_lock); vlc_mutex_destroy(&p_mlp->object_lock); free(p_mlp); return NULL; }