[asterisk-commits] russell: branch russell/chan_refcount r82563 - in /team/russell/chan_refcount...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 17 01:39:08 CDT 2007
Author: russell
Date: Mon Sep 17 01:39:06 2007
New Revision: 82563
URL: http://svn.digium.com/view/asterisk?view=rev&rev=82563
Log:
convert app_zapscan and update the docs for a function
Modified:
team/russell/chan_refcount/apps/app_zapscan.c
team/russell/chan_refcount/include/asterisk/file.h
Modified: team/russell/chan_refcount/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_zapscan.c?view=diff&rev=82563&r1=82562&r2=82563
==============================================================================
--- team/russell/chan_refcount/apps/app_zapscan.c (original)
+++ team/russell/chan_refcount/apps/app_zapscan.c Mon Sep 17 01:39:06 2007
@@ -71,11 +71,13 @@
#define CONF_SIZE 160
-static struct ast_channel *get_zap_channel_locked(int num) {
+static struct ast_channel *get_zap_channel(int num)
+{
char name[80];
- snprintf(name,sizeof(name),"Zap/%d-1",num);
- return ast_get_channel_by_name_locked(name);
+ snprintf(name, sizeof(name), "Zap/%d-1", num);
+
+ return ast_channel_get_by_name(name);
}
static int careful_write(int fd, unsigned char *data, int len)
@@ -294,6 +296,7 @@
struct ast_frame *f;
char *desired_group;
int input=0,search_group=0;
+ struct ast_channel_iterator *iter;
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
@@ -304,30 +307,41 @@
search_group = 1;
}
- for (;;) {
+ iter = ast_channel_iterator_all_new();
+
+ if (!iter)
+ return -1;
+
+ for (;; tempchan ? ast_channel_unref(tempchan) : NULL) {
+ /* lastchan must not be dereferenced in this loop,
+ * as its reference has been released */
+
if (ast_waitfor(chan, 100) < 0)
break;
- f = ast_read(chan);
- if (!f)
+ if (!(f = ast_read(chan)))
break;
+
if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) {
ast_frfree(f);
break;
}
ast_frfree(f);
+
ichan = NULL;
- if(input) {
- ichan = get_zap_channel_locked(input);
+ if (input) {
+ ichan = get_zap_channel(input);
input = 0;
}
- tempchan = ichan ? ichan : ast_channel_walk_locked(tempchan);
-
- if ( !tempchan && !lastchan )
+ tempchan = ichan ? ichan : ast_channel_iterator_next(iter);
+
+ if (!tempchan)
break;
-
- if (tempchan && search_group) {
+
+ ast_channel_lock(tempchan);
+
+ if (search_group) {
const char *mygroup;
if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) {
ast_verb(3, "Found Matching Channel %s in group %s\n", tempchan->name, desired_group);
@@ -337,23 +351,29 @@
continue;
}
}
+
if (tempchan && (!strcmp(tempchan->tech->type, "Zap")) && (tempchan != chan) ) {
ast_verb(3, "Zap channel %s is in-use, monitoring...\n", tempchan->name);
ast_copy_string(confstr, tempchan->name, sizeof(confstr));
- ast_mutex_unlock(&tempchan->lock);
- if ((tmp = strchr(confstr,'-'))) {
+ if ((tmp = strchr(confstr,'-')))
*tmp = '\0';
- }
confno = atoi(strchr(confstr,'/') + 1);
ast_stopstream(chan);
+ ast_channel_unlock(tempchan);
ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language, (char *) NULL);
res = conf_run(chan, confno, confflags);
- if (res<0) break;
+ if (res < 0)
+ break;
input = res;
- } else if (tempchan)
- ast_mutex_unlock(&tempchan->lock);
- lastchan = tempchan;
- }
+ continue;
+ }
+
+ ast_channel_unlock(tempchan);
+ }
+
+ if (tempchan)
+ ast_channel_unref(tempchan);
+
return res;
}
Modified: team/russell/chan_refcount/include/asterisk/file.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/include/asterisk/file.h?view=diff&rev=82563&r1=82562&r2=82563
==============================================================================
--- team/russell/chan_refcount/include/asterisk/file.h (original)
+++ team/russell/chan_refcount/include/asterisk/file.h Mon Sep 17 01:39:06 2007
@@ -184,9 +184,14 @@
/*!
* \brief Stops a stream
+ *
* \param c The channel you wish to stop playback on
+ *
* Stop playback of a stream
- * \return 0 regardless
+ *
+ * \retval 0 always
+ *
+ * \note The channel should be locked before calling this function.
*/
int ast_stopstream(struct ast_channel *c);
More information about the asterisk-commits
mailing list