本文整理汇总了C++中cw_mutex_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ cw_mutex_lock函数的具体用法?C++ cw_mutex_lock怎么用?C++ cw_mutex_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cw_mutex_lock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: config_load
static int config_load(void)
{
struct cw_config *cfg;
char *cat;
struct osp_provider *osp, *prev = NULL, *next;
cw_mutex_lock(&osplock);
osp = providers;
while(osp) {
osp->dead = 1;
osp = osp->next;
}
cw_mutex_unlock(&osplock);
cfg = cw_config_load("osp.conf");
if (cfg) {
if (!initialized) {
cat = cw_variable_retrieve(cfg, "general", "accelerate");
if (cat && cw_true(cat))
if (OSPPInit(1)) {
cw_log(LOG_WARNING, "Failed to enable hardware accelleration, falling back to software mode\n");
OSPPInit(0);
} else
hardware = 1;
else
OSPPInit(0);
initialized = 1;
}
cat = cw_variable_retrieve(cfg, "general", "tokenformat");
if (cat) {
if ((sscanf(cat, "%d", &tokenformat) != 1) || (tokenformat < TOKEN_ALGO_SIGNED) || (tokenformat > TOKEN_ALGO_BOTH)) {
tokenformat = TOKEN_ALGO_SIGNED;
cw_log(LOG_WARNING, "tokenformat should be an integer from 0 to 2, not '%s'\n", cat);
}
}
cat = cw_category_browse(cfg, NULL);
while(cat) {
if (strcasecmp(cat, "general"))
osp_build(cfg, cat);
cat = cw_category_browse(cfg, cat);
}
cw_config_destroy(cfg);
} else
cw_log(LOG_NOTICE, "No OSP configuration found. OSP support disabled\n");
cw_mutex_lock(&osplock);
osp = providers;
while(osp) {
next = osp->next;
if (osp->dead) {
if (prev)
prev->next = next;
else
providers = next;
/* XXX Cleanup OSP structure first XXX */
free(osp);
} else
prev = osp;
osp = next;
}
cw_mutex_unlock(&osplock);
return 0;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:60,代码来源:res_osp.c
示例2:
/* locate a tone_zone_sound, given the tone_zone. if tone_zone == NULL, use the default tone_zone */
struct tone_zone_sound *cw_get_indication_tone(const struct tone_zone *zone, const char *indication)
{
struct tone_zone_sound *ts;
/* we need some tonezone, pick the first */
if (zone == NULL && current_tonezone)
zone = current_tonezone; /* default country? */
if (zone == NULL && tone_zones)
zone = tone_zones; /* any country? */
if (zone == NULL)
return 0; /* not a single country insight */
if (cw_mutex_lock(&tzlock))
{
cw_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return 0;
}
for (ts = zone->tones; ts; ts = ts->next)
{
if (strcasecmp(indication, ts->name) == 0)
{
/* found indication! */
cw_mutex_unlock(&tzlock);
return ts;
}
}
/* nothing found, sorry */
cw_mutex_unlock(&tzlock);
return 0;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:31,代码来源:indications.c
示例3: memset
static struct cw_filestream *g726_16_rewrite(FILE *f, const char *comment)
{
/* We don't have any header to read or anything really, but
if we did, it would go here. We also might want to check
and be sure it's a valid file. */
struct cw_filestream *tmp;
if ((tmp = malloc(sizeof(struct cw_filestream)))) {
memset(tmp, 0, sizeof(struct cw_filestream));
if (cw_mutex_lock(&g726_lock)) {
cw_log(LOG_WARNING, "Unable to lock g726 list.\n");
free(tmp);
return NULL;
}
tmp->f = f;
tmp->rate = RATE_16;
glistcnt++;
if (option_debug)
cw_log(LOG_DEBUG, "Created filestream G.726-%dk.\n",
40 - tmp->rate * 8);
cw_mutex_unlock(&g726_lock);
cw_update_use_count();
} else
cw_log(LOG_WARNING, "Out of memory\n");
return tmp;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:25,代码来源:format_g726.c
示例4: cw_log
static struct cw_filestream *au_rewrite(FILE *f, const char *comment)
{
struct cw_filestream *tmp;
if ((tmp = malloc(sizeof(struct cw_filestream))) == NULL)
{
cw_log(LOG_ERROR, "Out of memory\n");
return NULL;
}
memset(tmp, 0, sizeof(struct cw_filestream));
if (write_header(f))
{
free(tmp);
return NULL;
}
if (cw_mutex_lock(&au_lock))
{
cw_log(LOG_WARNING, "Unable to lock au count\n");
free(tmp);
return NULL;
}
tmp->f = f;
localusecnt++;
cw_mutex_unlock(&au_lock);
cw_update_use_count();
return tmp;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:28,代码来源:format_au.c
示例5: show_osp
static int show_osp(int fd, int argc, char *argv[])
{
struct osp_provider *osp;
char *search = NULL;
int x;
int found = 0;
char *tokenalgo;
if ((argc < 2) || (argc > 3))
return RESULT_SHOWUSAGE;
if (argc > 2)
search = argv[2];
if (!search) {
switch (tokenformat) {
case TOKEN_ALGO_BOTH:
tokenalgo = "Both";
break;
case TOKEN_ALGO_UNSIGNED:
tokenalgo = "Unsigned";
break;
case TOKEN_ALGO_SIGNED:
default:
tokenalgo = "Signed";
break;
}
cw_cli(fd, "OSP: %s %s %s\n", initialized ? "Initialized" : "Uninitialized", hardware ? "Accelerated" : "Normal", tokenalgo);
}
cw_mutex_lock(&osplock);
osp = providers;
while(osp) {
if (!search || !strcasecmp(osp->name, search)) {
if (found)
cw_cli(fd, "\n");
cw_cli(fd, " == OSP Provider '%s' ==\n", osp->name);
cw_cli(fd, "Local Private Key: %s\n", osp->localpvtkey);
cw_cli(fd, "Local Certificate: %s\n", osp->localcert);
for (x=0;x<osp->cacount;x++)
cw_cli(fd, "CA Certificate %d: %s\n", x + 1, osp->cacerts[x]);
for (x=0;x<osp->spcount;x++)
cw_cli(fd, "Service Point %d: %s\n", x + 1, osp->servicepoints[x]);
cw_cli(fd, "Max Connections: %d\n", osp->maxconnections);
cw_cli(fd, "Retry Delay: %d seconds\n", osp->retrydelay);
cw_cli(fd, "Retry Limit: %d\n", osp->retrylimit);
cw_cli(fd, "Timeout: %d milliseconds\n", osp->timeout);
cw_cli(fd, "Source: %s\n", strlen(osp->source) ? osp->source : "<unspecified>");
cw_cli(fd, "OSP Handle: %d\n", osp->handle);
found++;
}
osp = osp->next;
}
cw_mutex_unlock(&osplock);
if (!found) {
if (search)
cw_cli(fd, "Unable to find OSP provider '%s'\n", search);
else
cw_cli(fd, "No OSP providers configured\n");
}
return RESULT_SUCCESS;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:60,代码来源:res_osp.c
示例6: cw_mutex_lock
static void *database_queue_thread_main(void *data) {
cw_mutex_lock(&db_condition_lock);
for ( ;; ) {
if ( db_list_head ) {
//cw_log(LOG_ERROR,"DB DO SAVE OUR LIST\n");
database_flush_cache();
sleep( CACHE_COMMIT_INTERVAL );
}
else
{
cw_cond_wait(&db_condition_save, &db_condition_lock);
/*
//cw_log(LOG_ERROR,"DB SAVE CONDITION RECEIVED\n");
db_list_t *e = db_list_head;
cw_log(LOG_ERROR,"QUEUE NOW IS:\n");
while ( e ) {
if ( e->sql )
cw_log(LOG_ERROR,"ITEM: %s\n",e->sql);
e = e->next;
}
*/
}
}
cw_mutex_unlock(&db_condition_lock);
return NULL;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:31,代码来源:db.c
示例7: memset
static struct cw_filestream *pcm_rewrite(FILE *f, const char *comment)
{
/* We don't have any header to read or anything really, but
if we did, it would go here. We also might want to check
and be sure it's a valid file. */
struct cw_filestream *tmp;
if ((tmp = malloc(sizeof(struct cw_filestream))))
{
memset(tmp, 0, sizeof(struct cw_filestream));
if (cw_mutex_lock(&pcm_lock))
{
cw_log(LOG_WARNING, "Unable to lock pcm list\n");
free(tmp);
return NULL;
}
tmp->f = f;
glistcnt++;
cw_mutex_unlock(&pcm_lock);
cw_update_use_count();
}
else
{
cw_log(LOG_WARNING, "Out of memory\n");
}
return tmp;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:27,代码来源:format_pcm.c
示例8: cw_mutex_lock
static void *service_thread(void *data)
{
struct sched_context *con = data;
cw_mutex_lock(&con->lock);
pthread_cleanup_push((void (*)(void *))cw_mutex_unlock, &con->lock);
for (;;) {
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
if (con->schedq) {
struct timespec tick;
tick.tv_sec = con->schedq->when.tv_sec;
tick.tv_nsec = 1000 * con->schedq->when.tv_usec;
while (cw_cond_timedwait(&con->service, &con->lock, &tick) < 0 && errno == EINTR);
} else {
while (cw_cond_wait(&con->service, &con->lock) < 0 && errno == EINTR);
}
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
cw_sched_runq(con);
}
pthread_cleanup_pop(1);
return NULL;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:27,代码来源:sched.c
示例9: cw_sched_add_variable
int cw_sched_add_variable(struct sched_context *con, int when, cw_sched_cb callback, void *data, int variable)
{
/*
* Schedule callback(data) to happen when ms into the future
*/
struct sched *tmp;
int res = -1;
#ifdef DEBUG_SCHED
DEBUG_LOG(cw_log(LOG_DEBUG, "cw_sched_add_variable()\n"));
#endif
cw_mutex_lock(&con->lock);
if ((tmp = sched_alloc(con))) {
if ((tmp->id = con->eventcnt++) < 0)
tmp->id = con->eventcnt = 0;
tmp->callback = callback;
tmp->data = data;
tmp->resched = when;
tmp->variable = variable;
tmp->when = cw_tvadd(cw_tvnow(), cw_samp2tv(when, 1000));
schedule(con, tmp);
res = tmp->id;
}
#ifdef DUMP_SCHEDULER
/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
cw_sched_dump(con);
#endif
cw_mutex_unlock(&con->lock);
return res;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:31,代码来源:sched.c
示例10: ogg_vorbis_close
/*!
* \brief Close a OGG/Vorbis filestream.
* \param s A OGG/Vorbis filestream.
*/
static void ogg_vorbis_close(struct cw_filestream *s)
{
if (cw_mutex_lock(&ogg_vorbis_lock)) {
cw_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
return;
}
glistcnt--;
cw_mutex_unlock(&ogg_vorbis_lock);
cw_update_use_count();
if (s->writing) {
/* Tell the Vorbis encoder that the stream is finished
* and write out the rest of the data */
vorbis_analysis_wrote(&s->vd, 0);
write_stream(s);
}
ogg_stream_clear(&s->os);
vorbis_block_clear(&s->vb);
vorbis_dsp_clear(&s->vd);
vorbis_comment_clear(&s->vc);
vorbis_info_clear(&s->vi);
if (s->writing) {
ogg_sync_clear(&s->oy);
}
fclose(s->fp);
free(s);
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:34,代码来源:format_ogg_vorbis.c
示例11: cw_log
static struct cw_filestream *h263_open(FILE *f)
{
/* We don't have any header to read or anything really, but
if we did, it would go here. We also might want to check
and be sure it's a valid file. */
struct cw_filestream *tmp;
unsigned int ts;
int res;
if ((res = fread(&ts, 1, sizeof(ts), f)) < sizeof(ts))
{
cw_log(LOG_WARNING, "Empty file!\n");
return NULL;
}
if ((tmp = malloc(sizeof(struct cw_filestream))))
{
memset(tmp, 0, sizeof(struct cw_filestream));
if (cw_mutex_lock(&h263_lock))
{
cw_log(LOG_WARNING, "Unable to lock h263 list\n");
free(tmp);
return NULL;
}
tmp->f = f;
cw_fr_init_ex(&tmp->fr, CW_FRAME_VIDEO, CW_FORMAT_H263, name);
tmp->fr.data = tmp->h263;
/* datalen will vary for each frame */
glistcnt++;
cw_mutex_unlock(&h263_lock);
cw_update_use_count();
}
return tmp;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:34,代码来源:format_h263.c
示例12: cw_autoservice_stop
int cw_autoservice_stop(struct cw_channel *chan)
{
int res = -1;
struct asent *as, *prev;
cw_mutex_lock(&autolock);
as = aslist;
prev = NULL;
while(as) {
if (as->chan == chan)
break;
prev = as;
as = as->next;
}
if (as) {
if (prev)
prev->next = as->next;
else
aslist = as->next;
free(as);
if (!chan->_softhangup)
res = 0;
}
if (asthread != CW_PTHREADT_NULL)
pthread_kill(asthread, SIGURG);
cw_mutex_unlock(&autolock);
/* Wait for it to un-block */
while(cw_test_flag(chan, CW_FLAG_BLOCKING))
usleep(1000);
return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:30,代码来源:autoservice.c
示例13: sccp_pbx_write
static int sccp_pbx_write(struct cw_channel *ast, struct cw_frame *frame) {
sccp_channel_t * c = CS_CW_CHANNEL_PVT(ast);
if (!c)
return 0;
int res = 0;
if (frame->frametype != CW_FRAME_VOICE) {
if (frame->frametype == CW_FRAME_IMAGE)
return 0;
else {
cw_log(LOG_WARNING, "%s: Can't send %d type frames with SCCP write on channel %d\n", DEV_ID_LOG(c->device), frame->frametype, (c) ? c->callid : 0);
return 0;
}
} else {
if (!(frame->subclass & ast->nativeformats)) {
cw_log(LOG_WARNING, "%s: Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
DEV_ID_LOG(c->device), frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
return -1;
}
}
if (c) {
cw_mutex_lock(&c->lock);
if (c->rtp) {
res = cw_rtp_write(c->rtp, frame);
}
cw_mutex_unlock(&c->lock);
}
return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:30,代码来源:sccp_pbx.c
示例14: cw_autoservice_start
int cw_autoservice_start(struct cw_channel *chan)
{
int res = -1;
struct asent *as;
int needstart;
cw_mutex_lock(&autolock);
needstart = (asthread == CW_PTHREADT_NULL) ? 1 : 0 /* aslist ? 0 : 1 */;
as = aslist;
while(as) {
if (as->chan == chan)
break;
as = as->next;
}
if (!as) {
as = malloc(sizeof(struct asent));
if (as) {
memset(as, 0, sizeof(struct asent));
as->chan = chan;
as->next = aslist;
aslist = as;
res = 0;
if (needstart) {
if (cw_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
cw_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
free(aslist);
aslist = NULL;
res = -1;
} else
pthread_kill(asthread, SIGURG);
}
}
}
cw_mutex_unlock(&autolock);
return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:35,代码来源:autoservice.c
示例15: sched_context_destroy
void sched_context_destroy(struct sched_context *con)
{
struct sched *s, *sl;
if (!pthread_equal(con->tid, CW_PTHREADT_NULL)) {
pthread_cancel(con->tid);
pthread_join(con->tid, NULL);
cw_cond_destroy(&con->service);
}
cw_mutex_lock(&con->lock);
#ifdef SCHED_MAX_CACHE
/* Eliminate the cache */
s = con->schedc;
while(s) {
sl = s;
s = s->next;
free(sl);
}
#endif
/* And the queue */
s = con->schedq;
while(s) {
sl = s;
s = s->next;
free(sl);
}
/* And the context */
cw_mutex_unlock(&con->lock);
cw_mutex_destroy(&con->lock);
free(con);
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:34,代码来源:sched.c
示例16: conference_stop_sounds
int conference_stop_sounds( struct cw_conf_member *member )
{
struct cw_conf_soundq *sound;
struct cw_conf_soundq *next;
if( member == NULL ) {
cw_log(LOG_WARNING, "Member is null. Cannot play\n");
return 0;
}
// clear all sounds
cw_mutex_lock(&member->lock);
sound = member->soundq;
member->soundq = NULL;
while(sound) {
next = sound->next;
free(sound);
sound = next;
}
cw_mutex_unlock(&member->lock);
cw_log(CW_CONF_DEBUG,"Stopped sounds to member %s\n", member->chan->name);
return 0 ;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:30,代码来源:sounds.c
示例17: crypto_load
static void crypto_load(int ifd, int ofd)
{
struct cw_key *key, *nkey, *last;
DIR *dir = NULL;
struct dirent *ent;
int note = 0;
/* Mark all keys for deletion */
cw_mutex_lock(&keylock);
key = keys;
while(key) {
key->delme = 1;
key = key->next;
}
cw_mutex_unlock(&keylock);
/* Load new keys */
dir = opendir((char *)cw_config_CW_KEY_DIR);
if (dir) {
while((ent = readdir(dir))) {
try_load_key((char *)cw_config_CW_KEY_DIR, ent->d_name, ifd, ofd, ¬e);
}
closedir(dir);
} else
cw_log(LOG_WARNING, "Unable to open key directory '%s'\n", (char *)cw_config_CW_KEY_DIR);
if (note) {
cw_log(LOG_NOTICE, "Please run the command 'init keys' to enter the passcodes for the keys\n");
}
cw_mutex_lock(&keylock);
key = keys;
last = NULL;
while(key) {
nkey = key->next;
if (key->delme) {
cw_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype);
/* Do the delete */
if (last)
last->next = nkey;
else
keys = nkey;
if (key->rsa)
RSA_free(key->rsa);
free(key);
} else
last = key;
key = nkey;
}
cw_mutex_unlock(&keylock);
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:47,代码来源:res_crypto.c
示例18: sccp_pbx_indicate
static int sccp_pbx_indicate(struct cw_channel *ast, int ind) {
sccp_channel_t * c = CS_CW_CHANNEL_PVT(ast);
int res = 0;
if (!c)
return -1;
cw_mutex_lock(&c->lock);
sccp_log(10)(VERBOSE_PREFIX_3 "%s: CallWeaver indicate '%d' (%s) condition on channel %s\n", DEV_ID_LOG(c->device), ind, sccp_control2str(ind), ast->name);
if (c->state == SCCP_CHANNELSTATE_CONNECTED) {
/* let's callweaver emulate it */
cw_mutex_unlock(&c->lock);
return -1;
}
/* when the rtp media stream is open we will let callweaver emulate the tones */
if (c->rtp)
res = -1;
switch(ind) {
case CW_CONTROL_RINGING:
sccp_indicate_nolock(c, SCCP_CHANNELSTATE_RINGOUT);
break;
case CW_CONTROL_BUSY:
sccp_indicate_nolock(c, SCCP_CHANNELSTATE_BUSY);
break;
case CW_CONTROL_CONGESTION:
sccp_indicate_nolock(c, SCCP_CHANNELSTATE_CONGESTION);
break;
case CW_CONTROL_PROGRESS:
case CW_CONTROL_PROCEEDING:
sccp_indicate_nolock(c, SCCP_CHANNELSTATE_PROCEED);
res = 0;
break;
/* when the bridged channel hold/unhold the call we are notified here */
case CW_CONTROL_HOLD:
res = 0;
break;
case CW_CONTROL_UNHOLD:
res = 0;
break;
case -1:
break;
default:
cw_log(LOG_WARNING, "SCCP: Don't know how to indicate condition %d\n", ind);
res = -1;
}
cw_mutex_unlock(&c->lock);
return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:58,代码来源:sccp_pbx.c
示例19: cw_osp_validate
int cw_osp_validate(char *provider, char *token, int *handle, unsigned int *timelimit, char *callerid, struct in_addr addr, char *extension)
{
char tmp[256]="", *l, *n;
char iabuf[INET_ADDRSTRLEN];
char source[OSP_MAX] = ""; /* Same length as osp->source */
char *token2;
int tokenlen;
struct osp_provider *osp;
int res = 0;
unsigned int authorised, dummy;
if (!provider || !strlen(provider))
provider = "default";
token2 = cw_strdupa(token);
tokenlen = cw_base64decode(token2, token, strlen(token));
*handle = -1;
if (!callerid)
callerid = "";
cw_copy_string(tmp, callerid, sizeof(tmp));
cw_callerid_parse(tmp, &n, &l);
if (!l)
l = "";
else {
cw_shrink_phone_number(l);
if (!cw_isphonenumber(l))
l = "";
}
callerid = l;
cw_mutex_lock(&osplock);
cw_inet_ntoa(iabuf, sizeof(iabuf), addr);
osp = providers;
while(osp) {
if (!strcasecmp(osp->name, provider)) {
if (OSPPTransactionNew(osp->handle, handle)) {
cw_log(LOG_WARNING, "Unable to create OSP Transaction handle!\n");
} else {
cw_copy_string(source, osp->source, sizeof(source));
res = 1;
}
break;
}
osp = osp->next;
}
cw_mutex_unlock(&osplock);
if (res) {
res = 0;
dummy = 0;
if (!OSPPTransactionValidateAuthorisation(*handle, iabuf, source, NULL, NULL,
callerid, OSPC_E164, extension, OSPC_E164, 0, "", tokenlen, token2, &authorised, timelimit, &dummy, NULL, tokenformat)) {
if (authorised) {
cw_log(LOG_DEBUG, "Validated token for '%s' from '%[email protected]%s'\n", extension, callerid, iabuf);
res = 1;
}
}
}
return res;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:58,代码来源:res_osp.c
示例20: sccp_pbx_read
static struct cw_frame * sccp_pbx_read(struct cw_channel *ast) {
sccp_channel_t * c = CS_CW_CHANNEL_PVT(ast);
if (!c)
return NULL;
struct cw_frame *fr;
cw_mutex_lock(&c->lock);
fr = sccp_rtp_read(c);
cw_mutex_unlock(&c->lock);
return fr;
}
开发者ID:wildzero-cw,项目名称:callweaver,代码行数:10,代码来源:sccp_pbx.c
注:本文中的cw_mutex_lock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论