本文整理汇总了C++中cw_mutex_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ cw_mutex_unlock函数的具体用法?C++ cw_mutex_unlock怎么用?C++ cw_mutex_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cw_mutex_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cw_log
/* 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: cw_slinfactory_feed
int cw_slinfactory_feed(struct cw_slinfactory *sf, struct cw_frame *f)
{
struct cw_frame *frame;
if (f == NULL)
return 0;
cw_mutex_lock(&(sf->lock));
if (f->subclass != CW_FORMAT_SLINEAR)
{
if (sf->trans && f->subclass != sf->format)
{
cw_translator_free_path(sf->trans);
sf->trans = NULL;
}
if (sf->trans == NULL)
{
if ((sf->trans = cw_translator_build_path(CW_FORMAT_SLINEAR, 8000, f->subclass, 8000)) == NULL)
{
cw_log(LOG_WARNING, "Cannot build a path from %s to slin\n", cw_getformatname(f->subclass));
cw_mutex_unlock(&(sf->lock));
return 0;
}
sf->format = f->subclass;
}
}
if (sf->trans)
{
if ((frame = cw_translate(sf->trans, f, 0)))
frame = cw_frdup(frame);
}
else
{
frame = cw_frdup(f);
}
if (frame)
{
int x = ++sf->queue.count;
frame->next = NULL;
if (sf->queue.tail)
sf->queue.tail->next = frame;
else
sf->queue.head = frame;
sf->queue.tail = frame;
frame->next = NULL;
sf->size += frame->datalen;
cw_mutex_unlock(&(sf->lock));
return x;
}
cw_mutex_unlock(&(sf->lock));
return 0;
}
示例5: cw_register_indication
/* add a new indication to a tone_zone. tone_zone must exist. if the indication already
* exists, it will be replaced. */
int cw_register_indication(struct tone_zone *zone, const char *indication, const char *tonelist)
{
struct tone_zone_sound *ts;
struct tone_zone_sound *ps;
/* is it an alias? stop */
if (zone->alias[0])
return -1;
if (cw_mutex_lock(&tzlock))
{
cw_log(LOG_WARNING, "Unable to lock tone_zones list\n");
return -2;
}
for (ps = NULL, ts = zone->tones; ts; ps = ts, ts = ts->next)
{
if (strcasecmp(indication, ts->name) == 0)
{
/* indication already there, replace */
free((void *) ts->name);
free((void *) ts->data);
break;
}
}
if (!ts)
{
/* not there, we have to add */
if ((ts = malloc(sizeof(struct tone_zone_sound))) == NULL)
{
cw_log(LOG_WARNING, "Out of memory\n");
cw_mutex_unlock(&tzlock);
return -2;
}
ts->next = NULL;
}
ts->name = strdup(indication);
ts->data = strdup(tonelist);
if (ts->name == NULL || ts->data == NULL)
{
cw_log(LOG_WARNING, "Out of memory\n");
cw_mutex_unlock(&tzlock);
return -2;
}
if (ps)
ps->next = ts;
else
zone->tones = ts;
cw_mutex_unlock(&tzlock);
return 0;
}
示例6: start_conference
struct cw_conference* start_conference( struct cw_conf_member* member )
{
struct cw_conference* conf = NULL ;
// check input
if ( member == NULL )
{
cw_log( LOG_WARNING, "unable to handle null member\n" ) ;
return NULL ;
}
// look for an existing conference
cw_log( CW_CONF_DEBUG, "attempting to find requested conference\n" ) ;
// acquire mutex
cw_mutex_lock( &start_stop_conf_lock ) ;
conf = find_conf( member->id ) ;
// unable to find an existing conference, try to create one
if ( conf == NULL )
{
// create a new conference
cw_log( CW_CONF_DEBUG, "attempting to create requested conference\n" ) ;
// create the new conference with one member
conf = create_conf( member->id, member ) ;
// return an error if create_conf() failed
if ( conf == NULL )
{
cw_log( LOG_ERROR, "unable to find or create requested conference\n" ) ;
cw_mutex_unlock( &start_stop_conf_lock ) ;
return NULL ;
}
}
else
{
// existing conference found, add new member to the conference
// once we call add_member(), this thread
// is responsible for calling delete_member()
//
add_member( conf, member) ;
}
// release mutex
cw_mutex_unlock( &start_stop_conf_lock ) ;
return conf ;
}
示例7: 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;
}
示例8: sccp_pbx_fixup
static int sccp_pbx_fixup(struct cw_channel *oldchan, struct cw_channel *newchan) {
sccp_channel_t * c = CS_CW_CHANNEL_PVT(newchan);
if (!c) {
cw_log(LOG_WARNING, "sccp_pbx_fixup(old: %s(%p), new: %s(%p)). no SCCP channel to fix\n", oldchan->name, oldchan, newchan->name, newchan);
return -1;
}
cw_mutex_lock(&c->lock);
if (c->owner != oldchan) {
cw_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, c->owner);
cw_mutex_unlock(&c->lock);
return -1;
}
c->owner = newchan;
cw_mutex_unlock(&c->lock);
return 0;
}
示例9: 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;
}
示例10: cw_app_group_match_get_count
int cw_app_group_match_get_count(char *groupmatch, char *category)
{
regex_t regexbuf;
struct cw_channel *chan;
int count = 0;
char *test;
char cat[80];
char *s;
if (cw_strlen_zero(groupmatch))
return 0;
/* if regex compilation fails, return zero matches */
if (regcomp(®exbuf, groupmatch, REG_EXTENDED | REG_NOSUB))
return 0;
s = (!cw_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
cw_copy_string(cat, s, sizeof(cat));
chan = NULL;
while ((chan = cw_channel_walk_locked(chan)) != NULL) {
test = pbx_builtin_getvar_helper(chan, cat);
if (test && !regexec(®exbuf, test, 0, NULL, 0))
count++;
cw_mutex_unlock(&chan->lock);
}
regfree(®exbuf);
return count;
}
示例11: 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);
}
示例12: 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;
}
示例13: 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 ;
}
示例14: cw_pbx_outgoing_exten
static void *originate(void *arg) {
struct fast_originate_helper *in = arg;
int reason=0;
int res;
struct cw_channel *chan = NULL;
res = cw_pbx_outgoing_exten(in->tech, CW_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, !cw_strlen_zero(in->cid_num) ? in->cid_num : NULL, !cw_strlen_zero(in->cid_name) ? in->cid_name : NULL, NULL, &chan);
manager_event(EVENT_FLAG_CALL, "Originate",
"ChannelRequested: %s/%s\r\n"
"Context: %s\r\n"
"Extension: %s\r\n"
"Priority: %d\r\n"
"Result: %d\r\n"
"Reason: %d\r\n"
"Reason-txt: %s\r\n",
in->tech,
in->data,
in->context,
in->exten,
in->priority,
res,
reason,
cw_control2str(reason)
);
/* Locked by cw_pbx_outgoing_exten or cw_pbx_outgoing_app */
if (chan) {
cw_mutex_unlock(&chan->lock);
}
free(in);
return NULL;
}
示例15: cw_log
static struct cw_filestream *au_open(FILE *f)
{
struct cw_filestream *tmp;
if (!(tmp = malloc(sizeof(struct cw_filestream))))
{
cw_log(LOG_ERROR, "Out of memory\n");
return NULL;
}
memset(tmp, 0, sizeof(struct cw_filestream));
if (check_header(f) < 0)
{
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;
cw_fr_init_ex(&tmp->fr, CW_FRAME_VOICE, CW_FORMAT_ULAW, NULL);
tmp->fr.data = tmp->buf;
/* datalen will vary for each frame */
tmp->fr.src = name;
localusecnt++;
cw_mutex_unlock(&au_lock);
cw_update_use_count();
return tmp;
}