您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ switch_core_new_memory_pool函数代码示例

51自学网 2021-06-03 08:35:15
  C++
这篇教程C++ switch_core_new_memory_pool函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中switch_core_new_memory_pool函数的典型用法代码示例。如果您正苦于以下问题:C++ switch_core_new_memory_pool函数的具体用法?C++ switch_core_new_memory_pool怎么用?C++ switch_core_new_memory_pool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了switch_core_new_memory_pool函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_speech_open(switch_speech_handle_t *sh,        const char *module_name,        const char *voice_name,        unsigned int rate, unsigned int interval, switch_speech_flag_t *flags, switch_memory_pool_t *pool){    switch_status_t status;    char buf[256] = "";    char *param = NULL;    if (!sh || !flags || zstr(module_name)) {        return SWITCH_STATUS_FALSE;    }    if (strchr(module_name, ':')) {        switch_set_string(buf, module_name);        if ((param = strchr(buf, ':'))) {            *param++ = '/0';            module_name = buf;        }    }    if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid speech module [%s]!/n", module_name);        return SWITCH_STATUS_GENERR;    }    sh->flags = *flags;    if (pool) {        sh->memory_pool = pool;    } else {        if ((status = switch_core_new_memory_pool(&sh->memory_pool)) != SWITCH_STATUS_SUCCESS) {            UNPROTECT_INTERFACE(sh->speech_interface);            return status;        }        switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL);    }    sh->engine = switch_core_strdup(sh->memory_pool, module_name);    if (param) {        sh->param = switch_core_strdup(sh->memory_pool, param);    }    sh->rate = rate;    sh->name = switch_core_strdup(sh->memory_pool, module_name);    sh->samples = switch_samples_per_packet(rate, interval);    sh->samplerate = rate;    sh->native_rate = rate;    if ((status = sh->speech_interface->speech_open(sh, voice_name, rate, flags)) == SWITCH_STATUS_SUCCESS) {        switch_set_flag(sh, SWITCH_SPEECH_FLAG_OPEN);    } else {        UNPROTECT_INTERFACE(sh->speech_interface);    }    return status;}
开发者ID:bodji,项目名称:freeswitch,代码行数:56,


示例2: switch_log_printf

static dir_profile_t *load_profile(const char *profile_name){	dir_profile_t *profile = NULL;	switch_xml_t x_profiles, x_profile, cfg, xml = NULL;	switch_event_t *event = NULL;	if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed/n", global_cf);		return profile;	}	if (!(x_profiles = switch_xml_child(cfg, "profiles"))) {		goto end;	}	if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) {		switch_memory_pool_t *pool;		int count;		if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure/n");			goto end;		}		if (!(profile = switch_core_alloc(pool, sizeof(dir_profile_t)))) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure/n");			switch_core_destroy_memory_pool(&pool);			goto end;		}		profile->pool = pool;		profile_set_config(profile);		/* Add the params to the event structure */		count = (int)switch_event_import_xml(switch_xml_child(x_profile, "param"), "name", "value", &event);		if (switch_xml_config_parse_event(event, count, SWITCH_FALSE, profile->config) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to process configuration/n");			switch_core_destroy_memory_pool(&pool);			goto end;		}		switch_thread_rwlock_create(&profile->rwlock, pool);		profile->name = switch_core_strdup(pool, profile_name);		switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool);		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s/n", profile->name);		switch_core_hash_insert(globals.profile_hash, profile->name, profile);	}  end:	switch_xml_free(xml);	return profile;}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:54,


示例3: switch_core_new_memory_pool

SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, const char *subclass_name){	switch_core_new_memory_pool(&pool);		switch_queue_create(&events, 5000, pool);	node_index = 0;		if (!zstr(event_name)) {		bind(event_name, subclass_name);	}}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:12,


示例4: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_asr_open(switch_asr_handle_t *ah,													 const char *module_name,													 const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool){	switch_status_t status;	char buf[256] = "";	char *param = NULL;	if (strchr(module_name, ':')) {		switch_set_string(buf, module_name);		if ((param = strchr(buf, ':'))) {			*param++ = '/0';			module_name = buf;		}	}	switch_assert(ah != NULL);	if ((ah->asr_interface = switch_loadable_module_get_asr_interface(module_name)) == 0) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ASR module [%s]!/n", module_name);		return SWITCH_STATUS_GENERR;	}	ah->flags = *flags;	if (pool) {		ah->memory_pool = pool;	} else {		if ((status = switch_core_new_memory_pool(&ah->memory_pool)) != SWITCH_STATUS_SUCCESS) {			UNPROTECT_INTERFACE(ah->asr_interface);			return status;		}		switch_set_flag(ah, SWITCH_ASR_FLAG_FREE_POOL);	}	if (param) {		ah->param = switch_core_strdup(ah->memory_pool, param);	}	ah->rate = rate;	ah->name = switch_core_strdup(ah->memory_pool, module_name);	ah->samplerate = rate;	ah->native_rate = rate;	status = ah->asr_interface->asr_open(ah, codec, rate, dest, flags);	if (status != SWITCH_STATUS_SUCCESS) {		UNPROTECT_INTERFACE(ah->asr_interface);	}	return status;}
开发者ID:RodrigoNieves,项目名称:FreeSWITCH,代码行数:52,


示例5: SavedCondition

     SavedCondition(switch_memory_pool_t *pool=NULL):        _pool(pool),        _can_delete_pool(false)     {        if(!_pool)        {            switch_core_new_memory_pool(&_pool);            _can_delete_pool = true;        }        switch_thread_cond_create(&_condition, _pool);        switch_mutex_init(&_mutex, SWITCH_MUTEX_DEFAULT, _pool);     }
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:13,


示例6: iks_find

/** * Start execution of prompt component */static iks *start_call_prompt_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data){	iks *iq = msg->payload;	switch_core_session_t *session = (switch_core_session_t *)session_data;	switch_memory_pool_t *pool;	struct prompt_component *prompt_component = NULL;	iks *prompt = iks_find(iq, "prompt");	iks *input;	iks *output;	iks *cmd;	if (!VALIDATE_RAYO_PROMPT(prompt)) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Bad <prompt> attrib/n");		return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Bad <prompt> attrib value");	}	output = iks_find(prompt, "output");	if (!output) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Missing <output>/n");		return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing <output>");	}	input = iks_find(prompt, "input");	if (!input) {		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Missing <input>/n");		return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing <input>");	}	/* create prompt component, linked to call */	switch_core_new_memory_pool(&pool);	prompt_component = switch_core_alloc(pool, sizeof(*prompt_component));	rayo_component_init(RAYO_COMPONENT(prompt_component), pool, RAT_CALL_COMPONENT, "prompt", NULL, call, iks_find_attrib(iq, "from"));	prompt_component->iq = iks_copy(iq);	/* start output */	if (iks_find_bool_attrib(prompt, "barge-in")) {		prompt_component->state = PCS_START_OUTPUT_BARGE;	} else {		prompt_component->state = PCS_START_OUTPUT;	}	cmd = iks_new("iq");	iks_insert_attrib(cmd, "from", RAYO_JID(prompt_component));	iks_insert_attrib(cmd, "to", RAYO_JID(call));	iks_insert_attrib(cmd, "id", iks_find_attrib(iq, "id"));	iks_insert_attrib(cmd, "type", "set");	output = iks_copy_within(output, iks_stack(cmd));	iks_insert_node(cmd, output);	RAYO_SEND_MESSAGE(prompt_component, RAYO_JID(call), cmd);	return NULL;}
开发者ID:lzcykevin,项目名称:FreeSWITCH,代码行数:54,


示例7: mongo_connection_pool_create

switch_status_t mongo_connection_pool_create(mongo_connection_pool_t **conn_pool, switch_size_t min_connections, switch_size_t max_connections,					     const char *conn_str){  switch_memory_pool_t *pool = NULL;  switch_status_t status = SWITCH_STATUS_SUCCESS;  mongo_connection_pool_t *cpool = NULL;  DBClientBase *conn = NULL;  if ((status = switch_core_new_memory_pool(&pool)) != SWITCH_STATUS_SUCCESS) {    return status;  }  if (!(cpool = (mongo_connection_pool_t *)switch_core_alloc(pool, sizeof(mongo_connection_pool_t)))) {    switch_goto_status(SWITCH_STATUS_MEMERR, done);  }  if ((status = switch_mutex_init(&cpool->mutex, SWITCH_MUTEX_NESTED, pool)) != SWITCH_STATUS_SUCCESS) {    goto done;  }   if ((status = switch_queue_create(&cpool->connections, max_connections, pool)) != SWITCH_STATUS_SUCCESS) {    goto done;  }  cpool->min_connections = min_connections;  cpool->max_connections = max_connections;  cpool->conn_str = switch_core_strdup(pool, conn_str);    cpool->pool = pool;  for (cpool->size = 0; cpool->size < min_connections; cpool->size++) {    if (mongo_connection_create(&conn, conn_str) == SWITCH_STATUS_SUCCESS) {      mongo_connection_pool_put(cpool, conn);    } else {      break;    }  } done:  if (status == SWITCH_STATUS_SUCCESS) {    *conn_pool = cpool;  } else {    switch_core_destroy_memory_pool(&pool);  }  return status;}
开发者ID:moises-silva,项目名称:mod_conference-admin,代码行数:50,


示例8: do_load

static void do_load(void){	switch_mutex_lock(MUTEX);	if (globals.pool) {		switch_core_destroy_memory_pool(&globals.pool);	}	memset(&globals, 0, sizeof(globals));	switch_core_new_memory_pool(&globals.pool);	globals.timeout = 10;	load_config();	switch_mutex_unlock(MUTEX);}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:14,


示例9: switch_core_new_memory_pool

blacklist_t *blacklist_create(const char *name) {	switch_memory_pool_t *pool = NULL;	blacklist_t *bl = NULL;		switch_core_new_memory_pool(&pool);	bl = switch_core_alloc(pool, sizeof(*bl));	switch_assert(bl);	bl->pool = pool;		switch_core_hash_init(&bl->list);	switch_mutex_init(&bl->list_mutex, SWITCH_MUTEX_NESTED, pool);		return bl;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:15,


示例10: switch_core_new_memory_pool

/** * Create new output component */static struct rayo_component *create_output_component(struct rayo_actor *actor, const char *type, iks *output, const char *client_jid){	switch_memory_pool_t *pool;	struct output_component *output_component = NULL;	switch_core_new_memory_pool(&pool);	output_component = switch_core_alloc(pool, sizeof(*output_component));	rayo_component_init((struct rayo_component *)output_component, pool, type, "output", NULL, actor, client_jid);	output_component->document = iks_copy(output);	output_component->repeat_interval = iks_find_int_attrib(output, "repeat-interval");	output_component->repeat_times = iks_find_int_attrib(output, "repeat-times");	output_component->max_time = iks_find_int_attrib(output, "max-time");	output_component->start_paused = iks_find_bool_attrib(output, "start-paused");	return (struct rayo_component *)output_component;}
开发者ID:alleywind,项目名称:FreeSWITCH,代码行数:20,


示例11: switch_core_new_memory_pool

/** * Create new output component */static struct rayo_component *create_output_component(struct rayo_actor *actor, const char *type, iks *output, const char *client_jid){	switch_memory_pool_t *pool;	struct output_component *output_component = NULL;	switch_core_new_memory_pool(&pool);	output_component = switch_core_alloc(pool, sizeof(*output_component));	output_component = OUTPUT_COMPONENT(rayo_component_init((struct rayo_component *)output_component, pool, type, "output", NULL, actor, client_jid));	if (output_component) {		output_component->document = iks_copy(output);		output_component->start_offset_ms = iks_find_int_attrib(output, "start-offset");		output_component->repeat_interval_ms = iks_find_int_attrib(output, "repeat-interval");		output_component->repeat_times = iks_find_int_attrib(output, "repeat-times");		output_component->max_time_ms = iks_find_int_attrib(output, "max-time");		output_component->start_paused = iks_find_bool_attrib(output, "start-paused");		output_component->renderer = switch_core_strdup(RAYO_POOL(output_component), iks_find_attrib_soft(output, "renderer"));		/* get custom headers */		{			switch_stream_handle_t headers = { 0 };			iks *header = NULL;			int first = 1;			SWITCH_STANDARD_STREAM(headers);			for (header = iks_find(output, "header"); header; header = iks_next_tag(header)) {				if (!strcmp("header", iks_name(header))) {					const char *name = iks_find_attrib_soft(header, "name");					const char *value = iks_find_attrib_soft(header, "value");					if (!zstr(name) && !zstr(value)) {						headers.write_function(&headers, "%s%s=%s", first ? "{" : ",", name, value);						first = 0;					}				}			}			if (headers.data) {				headers.write_function(&headers, "}");				output_component->headers = switch_core_strdup(RAYO_POOL(output_component), (char *)headers.data);				free(headers.data);			}		}	} else {		switch_core_destroy_memory_pool(&pool);	}	return RAYO_COMPONENT(output_component);}
开发者ID:odmanV2,项目名称:freecenter,代码行数:47,


示例12: iks_find_bool_attrib

/** * Create a record component */static struct rayo_component *record_component_create(struct rayo_actor *actor, const char *client_jid, iks *record){	switch_memory_pool_t *pool;	struct record_component *record_component = NULL;	char *local_file_path;	char *fs_file_path;	switch_bool_t start_paused;	/* validate record attributes */	if (!VALIDATE_RAYO_RECORD(record)) {		return NULL;	}	start_paused = iks_find_bool_attrib(record, "start-paused");	/* create record filename from session UUID and ref */	/* for example: prefix/1234-1234-1234-1234-30.wav */	local_file_path = switch_mprintf("%s%s-%i.%s",		globals.record_file_prefix,		actor->id, rayo_actor_seq_next(actor), iks_find_attrib(record, "format"));	fs_file_path = switch_mprintf("{pause=%s}fileman://%s",		start_paused ? "true" : "false",		local_file_path);	switch_core_new_memory_pool(&pool);	record_component = switch_core_alloc(pool, sizeof(*record_component));	rayo_component_init(RAYO_COMPONENT(record_component), pool, "record", fs_file_path, actor, client_jid);	record_component->max_duration = iks_find_int_attrib(record, "max-duration");	record_component->initial_timeout = iks_find_int_attrib(record, "initial-timeout");	record_component->final_timeout = iks_find_int_attrib(record, "final-timeout");	record_component->direction = switch_core_strdup(RAYO_POOL(record_component), iks_find_attrib_soft(record, "direction"));	record_component->mix = iks_find_bool_attrib(record, "mix");	record_component->start_beep = iks_find_bool_attrib(record, "start-beep");	record_component->stop_beep = iks_find_bool_attrib(record, "stop-beep");	record_component->start_time = start_paused ? 0 : switch_micro_time_now();	record_component->local_file_path = switch_core_strdup(RAYO_POOL(record_component), local_file_path);	switch_safe_free(local_file_path);	switch_safe_free(fs_file_path);	return RAYO_COMPONENT(record_component);}
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:46,


示例13: switch_name_event

SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, const char *subclass_name){	switch_name_event(event_name, &e_event_id);	switch_core_new_memory_pool(&pool);		if (!zstr(subclass_name)) {		e_subclass_name = switch_core_strdup(pool, subclass_name);	} else {		e_subclass_name = NULL;	}	switch_queue_create(&events, 5000, pool);		if (switch_event_bind_removable(__FILE__, e_event_id, e_subclass_name, event_handler, this, &node) == SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "bound to %s %s/n", event_name, switch_str_nil(e_subclass_name));	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot bind to %s %s/n", event_name, switch_str_nil(e_subclass_name));	}}
开发者ID:gujun,项目名称:sscore,代码行数:20,


示例14: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_directory_exists(const char *dirname, switch_memory_pool_t *pool){	apr_dir_t *dir_handle;	switch_memory_pool_t *our_pool = NULL;	switch_status_t status;	if (!pool) {		switch_core_new_memory_pool(&our_pool);		pool = our_pool;	}	if ((status = apr_dir_open(&dir_handle, dirname, pool)) == APR_SUCCESS) {		apr_dir_close(dir_handle);	}	if (our_pool) {		switch_core_destroy_memory_pool(&our_pool);	}	return status;}
开发者ID:gujun,项目名称:sscore,代码行数:21,


示例15: socket_construct

static JSBool socket_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval){	js_socket_obj_t *js_socket_obj = 0;	switch_memory_pool_t *pool;	switch_socket_t *socket;	switch_status_t ret;	switch_core_new_memory_pool(&pool);	ret = switch_socket_create(&socket, AF_INET, SOCK_STREAM, SWITCH_PROTO_TCP, pool);	if (ret != SWITCH_STATUS_SUCCESS) {		switch_core_destroy_memory_pool(&pool);		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Failed to create socket, reason: %d./n", ret);		return JS_FALSE;	}	// allocate information needed by JS to be able to write to the log.	// (needed since multitple js sessions can write to the same log)	js_socket_obj = switch_core_alloc(pool, sizeof(js_socket_obj_t));	js_socket_obj->pool = pool;	js_socket_obj->socket = socket;	JS_SetPrivate(cx, obj, js_socket_obj);	return JS_TRUE;}
开发者ID:DastanIqbal,项目名称:FreeSWITCH,代码行数:22,


示例16: SWITCH_DECLARE

SWITCH_DECLARE(switch_status_t) switch_core_directory_open(switch_directory_handle_t *dh,														   char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool){	switch_status_t status;	if ((dh->directory_interface = switch_loadable_module_get_directory_interface(module_name)) == 0) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid directory module [%s]!/n", module_name);		return SWITCH_STATUS_GENERR;	}	if (pool) {		dh->memory_pool = pool;	} else {		if ((status = switch_core_new_memory_pool(&dh->memory_pool)) != SWITCH_STATUS_SUCCESS) {			UNPROTECT_INTERFACE(dh->directory_interface);			return status;		}		switch_set_flag(dh, SWITCH_DIRECTORY_FLAG_FREE_POOL);	}	return dh->directory_interface->directory_open(dh, source, dsn, passwd);}
开发者ID:gujun,项目名称:sscore,代码行数:22,


示例17: bind_fetch_agent

static switch_status_t bind_fetch_agent(switch_xml_section_t section, switch_xml_binding_t **binding) {    switch_memory_pool_t *pool = NULL;    ei_xml_agent_t *agent;    /* create memory pool for this xml search binging (lives for duration of mod_kazoo runtime) */    if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory: They're not people; they're hippies!/n");        return SWITCH_STATUS_MEMERR;    }    /* allocate some memory to store the fetch bindings for this section */    if (!(agent = switch_core_alloc(pool, sizeof (*agent)))) {        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory: Oh, Jesus tap-dancing Christ!/n");        return SWITCH_STATUS_MEMERR;    }    /* try to bind to the switch */    if (switch_xml_bind_search_function_ret(fetch_handler, section, agent, binding) != SWITCH_STATUS_SUCCESS) {        switch_core_destroy_memory_pool(&pool);        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not bind to FreeSWITCH %s XML requests/n"                          ,xml_section_to_string(section));        return SWITCH_STATUS_GENERR;    }    agent->pool = pool;    agent->section = section;    switch_thread_rwlock_create(&agent->lock, pool);    agent->clients = NULL;    switch_mutex_init(&agent->current_client_mutex, SWITCH_MUTEX_DEFAULT, pool);    agent->current_client = NULL;    switch_mutex_init(&agent->replies_mutex, SWITCH_MUTEX_DEFAULT, pool);    switch_thread_cond_create(&agent->new_reply, pool);    agent->replies = NULL;    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bound to %s XML requests/n"                      ,xml_section_to_string(section));    return SWITCH_STATUS_SUCCESS;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:39,


示例18: memset

WSClientParser::WSClientParser() {	// TODO Auto-generated constructor stub	mState = WSClientState_UnKnow;	mpCallback = NULL;	mpClient = NULL;	mpUser = NULL;	mpDomain = NULL;	mpDestNumber = NULL;	mpSite = NULL;	mpCustom = NULL;	mpChannel = NULL;	memset(mWebSocketKey, '/0', sizeof(mWebSocketKey));	// 创建内存池	switch_core_new_memory_pool(&mpPool);	switch_mutex_init(&clientMutex, SWITCH_MUTEX_NESTED, mpPool);	// 生成唯一标识	switch_uuid_t uuid;	switch_uuid_get(&uuid);	switch_uuid_format(this->uuid, &uuid);}
开发者ID:KingsleyYau,项目名称:CamShareMiddleware,代码行数:23,


示例19: nlsml_init

/** * Initialize NLSML parser.  This function is not thread safe. */int nlsml_init(void){	if (globals.init) {		return 1;	}	globals.init = SWITCH_TRUE;	switch_core_new_memory_pool(&globals.pool);	switch_core_hash_init(&globals.tag_defs, globals.pool);	add_root_tag_def("result", process_attribs_ignore, process_cdata_ignore, "interpretation");	add_tag_def("interpretation", process_attribs_ignore, process_cdata_ignore, "input,model,xf:model,instance,xf:instance");	add_tag_def("input", process_attribs_ignore, process_cdata_match, "input,nomatch,noinput");	add_tag_def("noinput", process_noinput, process_cdata_bad, "");	add_tag_def("nomatch", process_nomatch, process_cdata_ignore, "");	add_tag_def("model", process_attribs_ignore, process_cdata_ignore, "ANY");	add_tag_def("xf:model", process_attribs_ignore, process_cdata_ignore, "ANY");	add_tag_def("instance", process_attribs_ignore, process_cdata_ignore, "ANY");	add_tag_def("xf:instance", process_attribs_ignore, process_cdata_ignore, "ANY");	add_tag_def("ANY", process_attribs_ignore, process_cdata_ignore, "ANY");	return 1;}
开发者ID:benlangfeld,项目名称:FreeSWITCH,代码行数:26,


示例20: SWITCH_DECLARE

SWITCH_DECLARE(void) switch_ssl_init_ssl_locks(void){	int i, num;	if (ssl_count == 0) {		num = CRYPTO_num_locks();				ssl_mutexes = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(switch_mutex_t*));		switch_assert(ssl_mutexes != NULL);		switch_core_new_memory_pool(&ssl_pool);		for (i = 0; i < num; i++) {			switch_mutex_init(&(ssl_mutexes[i]), SWITCH_MUTEX_NESTED, ssl_pool);			switch_assert(ssl_mutexes[i] != NULL);		}		CRYPTO_set_id_callback(switch_ssl_ssl_thread_id);		CRYPTO_set_locking_callback((void (*)(int, int, const char*, int))switch_ssl_ssl_lock_callback);	}	ssl_count++;}
开发者ID:odmanV2,项目名称:freecenter,代码行数:24,


示例21: task_thread_loop

static int task_thread_loop(int done){	switch_scheduler_task_container_t *tofree, *tp, *last = NULL;	switch_mutex_lock(globals.task_mutex);	for (tp = globals.task_list; tp; tp = tp->next) {		if (done) {			tp->destroyed = 1;		} else if (!tp->destroyed) {			int64_t now = switch_epoch_time_now(NULL);			if (now >= tp->task.runtime && !tp->in_thread) {				int32_t diff = (int32_t) (now - tp->task.runtime);				if (diff > 1) {					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Task was executed late by %d seconds %u %s (%s)/n",									  diff, tp->task.task_id, tp->desc, switch_str_nil(tp->task.group));				}				tp->executed = now;				if (switch_test_flag(tp, SSHF_OWN_THREAD)) {					switch_thread_t *thread;					switch_threadattr_t *thd_attr;					switch_core_new_memory_pool(&tp->pool);					switch_threadattr_create(&thd_attr, tp->pool);					switch_threadattr_detach_set(thd_attr, 1);					tp->in_thread = 1;					switch_thread_create(&thread, thd_attr, task_own_thread, tp, tp->pool);				} else {					tp->running = 1;					switch_mutex_unlock(globals.task_mutex);					switch_scheduler_execute(tp);					switch_mutex_lock(globals.task_mutex);					tp->running = 0;				}			}		}	}	switch_mutex_unlock(globals.task_mutex);	switch_mutex_lock(globals.task_mutex);	for (tp = globals.task_list; tp;) {		if (tp->destroyed && !tp->in_thread) {			switch_event_t *event;			tofree = tp;			tp = tp->next;			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting task %u %s (%s)/n",							  tofree->task.task_id, tofree->desc, switch_str_nil(tofree->task.group));			if (switch_event_create(&event, SWITCH_EVENT_DEL_SCHEDULE) == SWITCH_STATUS_SUCCESS) {				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tofree->task.task_id);				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Desc", tofree->desc);				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Task-Group", switch_str_nil(tofree->task.group));				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tofree->task.runtime);				switch_queue_push(globals.event_queue, event);				event = NULL;			}			if (last) {				last->next = tofree->next;			} else {				globals.task_list = tofree->next;			}			switch_safe_free(tofree->task.group);			if (tofree->task.cmd_arg && switch_test_flag(tofree, SSHF_FREE_ARG)) {				free(tofree->task.cmd_arg);			}			switch_safe_free(tofree->desc);			free(tofree);		} else {			last = tp;			tp = tp->next;		}	}	switch_mutex_unlock(globals.task_mutex);	return done;}
开发者ID:bodji,项目名称:freeswitch,代码行数:78,


示例22: mod_logfile_rotate

/* rotate the log file */static switch_status_t mod_logfile_rotate(logfile_profile_t *profile){	unsigned int i = 0;	char *filename = NULL;	switch_status_t stat = 0;	int64_t offset = 0;	switch_memory_pool_t *pool = NULL;	switch_time_exp_t tm;	char date[80] = "";	switch_size_t retsize;	switch_status_t status = SWITCH_STATUS_SUCCESS;	switch_mutex_lock(globals.mutex);	switch_time_exp_lt(&tm, switch_micro_time_now());	switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm);	profile->log_size = 0;	stat = switch_file_seek(profile->log_afd, SWITCH_SEEK_SET, &offset);	if (stat != SWITCH_STATUS_SUCCESS) {		status = SWITCH_STATUS_FALSE;		goto end;	}	switch_core_new_memory_pool(&pool);	filename = switch_core_alloc(pool, strlen(profile->logfile) + WARM_FUZZY_OFFSET);	if (profile->max_rot) {		char *from_filename = NULL;		char *to_filename = NULL;		from_filename = switch_core_alloc(pool, strlen(profile->logfile) + WARM_FUZZY_OFFSET);		to_filename = switch_core_alloc(pool, strlen(profile->logfile) + WARM_FUZZY_OFFSET);		for (i=profile->suffix; i>1; i--) {			sprintf((char *) to_filename, "%s.%i", profile->logfile, i);			sprintf((char *) from_filename, "%s.%i", profile->logfile, i-1);			if (switch_file_exists(to_filename, pool) == SWITCH_STATUS_SUCCESS) {				if ((status = switch_file_remove(to_filename, pool)) != SWITCH_STATUS_SUCCESS) {					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error removing log %s/n",to_filename);					goto end;				}			}			if ((status = switch_file_rename(from_filename, to_filename, pool)) != SWITCH_STATUS_SUCCESS) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s [%s]/n",								  from_filename, to_filename, strerror(errno));				goto end;			}		}		sprintf((char *) to_filename, "%s.%i", profile->logfile, i);					if (switch_file_exists(to_filename, pool) == SWITCH_STATUS_SUCCESS) {			if ((status = switch_file_remove(to_filename, pool)) != SWITCH_STATUS_SUCCESS) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error removing log %s [%s]/n", to_filename, strerror(errno));				goto end;			}		}		switch_file_close(profile->log_afd);		if ((status = switch_file_rename(profile->logfile, to_filename, pool)) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error renaming log from %s to %s [%s]/n", profile->logfile, to_filename, strerror(errno));			goto end;		}		if ((status = mod_logfile_openlogfile(profile, SWITCH_FALSE)) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error reopening log %s/n", profile->logfile);		}		if (profile->suffix < profile->max_rot) {			profile->suffix++;		}		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New log started./n");		goto end;	}	/* XXX This have no real value EXCEPT making sure if we rotate within the same second, the end index will increase */	for (i = 1; i < MAX_ROT; i++) {		sprintf((char *) filename, "%s.%s.%i", profile->logfile, date, i);		if (switch_file_exists(filename, pool) == SWITCH_STATUS_SUCCESS) {			continue;		}		switch_file_close(profile->log_afd);		switch_file_rename(profile->logfile, filename, pool);		if ((status = mod_logfile_openlogfile(profile, SWITCH_FALSE)) != SWITCH_STATUS_SUCCESS) {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Rotating Log!/n");			goto end;		}		break;	}	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New log started./n");//.........这里部分代码省略.........
开发者ID:odmanV2,项目名称:freecenter,代码行数:101,


示例23: teletone_construct

static JSBool teletone_construct(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval){	JSObject *session_obj;	struct teletone_obj *tto = NULL;	struct js_session *jss = NULL;	switch_memory_pool_t *pool;	char *timer_name = NULL;	switch_codec_implementation_t read_impl = { 0 };	if (argc > 0) {		if (JS_ValueToObject(cx, argv[0], &session_obj)) {			if (!(jss = JS_GetPrivate(cx, session_obj))) {				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Find Session [1]/n");				return JS_FALSE;			}		} else {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Find Session [2]/n");			return JS_FALSE;		}	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Session Arg/n");		return JS_FALSE;	}	if (argc > 1) {		timer_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));	}	switch_core_new_memory_pool(&pool);	if (!(tto = switch_core_alloc(pool, sizeof(*tto)))) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error/n");		return JS_FALSE;	}	switch_core_session_get_read_impl(jss->session, &read_impl);	if (switch_core_codec_init(&tto->codec,							   "L16",							   NULL,							   read_impl.actual_samples_per_second,							   read_impl.microseconds_per_packet / 1000,							   read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated/n");	} else {		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed/n");		return JS_FALSE;	}	if (timer_name) {		unsigned int ms = read_impl.microseconds_per_packet / 1000;		if (switch_core_timer_init(&tto->timer_base,								   timer_name, ms, (read_impl.samples_per_second / 50) * read_impl.number_of_channels, pool) == SWITCH_STATUS_SUCCESS) {			tto->timer = &tto->timer_base;			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Success %u/n", ms);		} else {			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Failed/n");		}	}	switch_buffer_create_dynamic(&tto->audio_buffer, JS_BLOCK_SIZE, JS_BUFFER_SIZE, 0);	tto->pool = pool;	tto->obj = obj;	tto->cx = cx;	tto->session = jss->session;	teletone_init_session(&tto->ts, 0, teletone_handler, tto);	JS_SetPrivate(cx, obj, tto);	return JS_TRUE;}
开发者ID:PauloFer1,项目名称:FreeSWITCH,代码行数:71,



注:本文中的switch_core_new_memory_pool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ switch_core_session_get_channel函数代码示例
C++ switch_core_hash_find函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。