conn_pool_t* conn_pool_new(int size,int lazy_init,conn_cb_t* cbs, void* args) { int i; assert(size > 0); conn_pool_t* pool = (conn_pool_t*)PCALLOC(sizeof(conn_pool_t)); pool->conns = (void**)PCALLOC(sizeof(void*)*size); pool->size = size; pool->args = args; pool->curconns = 0; pool->cbs = (conn_cb_t*)PCALLOC(sizeof(conn_cb_t)); memcpy(pool->cbs, cbs, sizeof(conn_cb_t)); if(lazy_init == 0){ pool->start = pool->end = 0; for(i=0;i<size; i++){ pool->conns[i] = new_and_connect(cbs, args,&pool->statis); if(pool->conns[i]) sync_inc(&pool->curconns); } }else{ pool->start = 0; pool->end = 0; } pthread_spin_init(&pool->spin, 0); return pool; }
mrl_metadata_t * mrl_metadata_new (mrl_resource_t res) { mrl_metadata_t *meta; meta = PCALLOC (mrl_metadata_t, 1); if (!meta) return NULL; switch (res) { case MRL_RESOURCE_CDDA: case MRL_RESOURCE_CDDB: meta->priv = mrl_metadata_cd_new (); break; case MRL_RESOURCE_DVD: case MRL_RESOURCE_DVDNAV: meta->priv = mrl_metadata_dvd_new (); break; default: break; } return meta; }
mrl_properties_video_t * mrl_properties_video_new (void) { mrl_properties_video_t *video; video = PCALLOC (mrl_properties_video_t, 1); return video; }
mrl_properties_audio_t * mrl_properties_audio_new (void) { mrl_properties_audio_t *audio; audio = PCALLOC (mrl_properties_audio_t, 1); return audio; }
static mrl_metadata_audio_t * mrl_metadata_audio_new (void) { mrl_metadata_audio_t *audio; audio = PCALLOC (mrl_metadata_audio_t, 1); return audio; }
static mrl_metadata_dvd_t * mrl_metadata_dvd_new (void) { mrl_metadata_dvd_t *dvd; dvd = PCALLOC (mrl_metadata_dvd_t, 1); return dvd; }
static mrl_metadata_sub_t * mrl_metadata_sub_new (void) { mrl_metadata_sub_t *sub; sub = PCALLOC (mrl_metadata_sub_t, 1); return sub; }
mrl_metadata_dvd_title_t * mrl_metadata_dvd_title_new (void) { mrl_metadata_dvd_title_t *title; title = PCALLOC (mrl_metadata_dvd_title_t, 1); return title; }
static mrl_metadata_cd_t * mrl_metadata_cd_new (void) { mrl_metadata_cd_t *cd; cd = PCALLOC (mrl_metadata_cd_t, 1); return cd; }
mrl_metadata_cd_track_t * mrl_metadata_cd_track_new (void) { mrl_metadata_cd_track_t *track; track = PCALLOC (mrl_metadata_cd_track_t, 1); return track; }
mrl_properties_t * mrl_properties_new (void) { mrl_properties_t *prop; prop = PCALLOC (mrl_properties_t, 1); return prop; }
playlist_t * pl_playlist_new (int shuffle, int loop, player_loop_t loop_mode) { playlist_t *playlist; playlist = PCALLOC (playlist_t, 1); if (!playlist) return NULL; pl_playlist_set_shuffle (playlist, shuffle); pl_playlist_set_loop (playlist, loop, loop_mode); return playlist; }
void kcdb_credset_buf_assert_size(kcdb_credset * cs, khm_int32 nclist) { if(cs->nc_clist < nclist) { kcdb_credset_credref * new_clist; /* nclist had better be greater than KCDB_CREDSET_INITIAL_SIZE */ nclist = KCDB_CREDSET_INITIAL_SIZE + (((nclist - (KCDB_CREDSET_INITIAL_SIZE + 1)) / KCDB_CREDSET_GROWTH_FACTOR) + 1) * KCDB_CREDSET_GROWTH_FACTOR; new_clist = PCALLOC(nclist, sizeof(kcdb_credset_credref)); memcpy(new_clist, cs->clist, cs->nclist * sizeof(kcdb_credset_credref)); PFREE(cs->clist); cs->clist = new_clist; } }
static int _init(T *thiz) { RWLOCK_INIT(LOCK); thiz->hdr = PCALLOC(SUPER->mpool, sizeof(hdr_block_t)); #if 1 thiz->hdr->fend_off = BTR_HEADER_BLK_SIZE; #else thiz->hdr->fend_off = BTR_HEADER_BLK_SIZE; thiz->hdr->version = DB_FILE_VERSION; thiz->hdr->blktype = BTR_HEADER_BLK; strncpy(thiz->hdr->magic, DB_MAGIC_NUM, sizeof(thiz->hdr->magic)); #endif thiz->rfd = -1; thiz->wfd = -1; ADD_METHOD(destroy); ADD_METHOD(store); ADD_METHOD(restore); ADD_METHOD(merge_start); ADD_METHOD(merge); ADD_METHOD(merge_flush); ADD_METHOD(merge_hdr); ADD_METHOD(merge_fin); ADD_METHOD(find); ADD_METHOD(exist); ADD_METHOD(find_in_index); ADD_METHOD(range_cmp); ADD_METHOD(krange_cmp); ADD_METHOD(pkrange_cmp); ADD_METHOD(split); ADD_METHOD(shrink); ADD_METHOD(invalid); ADD_METHOD(get_iter); return 0; }
mrl_t * mrl_sv_new (player_t *player, mrl_resource_t res, void *args) { mrl_t *mrl = NULL; int support = 0; pl_log (player, PLAYER_MSG_VERBOSE, MODULE_NAME, __FUNCTION__); if (!player || !args) return NULL; /* ensure we provide a valid resource type */ if (res == MRL_RESOURCE_UNKNOWN) return NULL; /* ensure player support this resource type */ support = libplayer_wrapper_supported_res (player->type, res); if (!support) { pl_log (player, PLAYER_MSG_WARNING, MODULE_NAME, "Unsupported resource type (%d)", res); return NULL; } mrl = PCALLOC (mrl_t, 1); if (!mrl) return NULL; mrl->resource = res; mrl->priv = args; mrl_retrieve_properties (player, mrl); mrl->type = mrl_guess_type (mrl); /* can guess only if properties exist */ return mrl; }
player_t * player_init (player_type_t type, player_verbosity_level_t verbosity, player_init_param_t *param) { player_t *player = NULL; init_status_t res = PLAYER_INIT_ERROR; supervisor_status_t sv_res; int ret; int *sv_run; pthread_t *sv_job; pthread_cond_t *sv_cond; pthread_mutex_t *sv_mutex; player = PCALLOC (player_t, 1); if (!player) return NULL; player->type = type; player->verbosity = verbosity; player->state = PLAYER_STATE_IDLE; player->playlist = pl_playlist_new (0, 0, PLAYER_LOOP_DISABLE); if (param) { player->ao = param->ao; player->vo = param->vo; player->winid = param->winid; player->x11_display = param->display; player->event_cb = param->event_cb; player->user_data = param->data; player->quality = param->quality; } pthread_mutex_init (&player->mutex_verb, NULL); switch (player->type) { #ifdef HAVE_XINE case PLAYER_TYPE_XINE: player->funcs = pl_register_functions_xine (); player->priv = pl_register_private_xine (); break; #endif /* HAVE_XINE */ #ifdef HAVE_MPLAYER case PLAYER_TYPE_MPLAYER: player->funcs = pl_register_functions_mplayer (); player->priv = pl_register_private_mplayer (); break; #endif /* HAVE_MPLAYER */ #ifdef HAVE_VLC case PLAYER_TYPE_VLC: player->funcs = pl_register_functions_vlc (); player->priv = pl_register_private_vlc (); break; #endif /* HAVE_VLC */ #ifdef HAVE_GSTREAMER case PLAYER_TYPE_GSTREAMER: player->funcs = pl_register_functions_gstreamer (); player->priv = pl_register_private_gstreamer (); break; #endif /* HAVE_GSTREAMER */ case PLAYER_TYPE_DUMMY: player->funcs = pl_register_functions_dummy (); player->priv = pl_register_private_dummy (); break; default: break; } pl_log (player, PLAYER_MSG_VERBOSE, MODULE_NAME, __FUNCTION__); if (!player->funcs || !player->priv) { pl_log (player, PLAYER_MSG_ERROR, MODULE_NAME, "no wrapper registered"); player_uninit (player); return NULL; } player->supervisor = pl_supervisor_new (); if (!player->supervisor) { player_uninit (player); return NULL; } sv_res = pl_supervisor_init (player, &sv_run, &sv_job, &sv_cond, &sv_mutex); if (sv_res != SUPERVISOR_STATUS_OK) { pl_log (player, PLAYER_MSG_ERROR, MODULE_NAME, "failed to init supervisor"); player_uninit (player); return NULL; } player->event = pl_event_handler_register (player, player_event_cb); if (!player->event) { player_uninit (player); return NULL; } pl_log (player, PLAYER_MSG_INFO, MODULE_NAME, "pl_event_handler_init"); ret = pl_event_handler_init (player->event, sv_run, sv_job, sv_cond, sv_mutex); if (ret) { pl_log (player, PLAYER_MSG_ERROR, MODULE_NAME, "failed to init event handler"); player_uninit (player); return NULL; } player->window = pl_window_register (player); pl_event_handler_enable (player->event); player_set_verbosity (player, verbosity); pl_supervisor_send (player, SV_MODE_WAIT_FOR_END, SV_FUNC_PLAYER_INIT, NULL, &res); if (res != PLAYER_INIT_OK) { player_uninit (player); return NULL; } return player; }