[asterisk-commits] russell: branch russell/frame_caching r38607 - in /team/russell/frame_caching...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 31 12:30:20 MST 2006


Author: russell
Date: Mon Jul 31 14:30:20 2006
New Revision: 38607

URL: http://svn.digium.com/view/asterisk?rev=38607&view=rev
Log:
Conver ast_frame to use list macros ... this took way too long to do

Modified:
    team/russell/frame_caching/apps/app_milliwatt.c
    team/russell/frame_caching/apps/app_mixmonitor.c
    team/russell/frame_caching/channel.c
    team/russell/frame_caching/channels/chan_local.c
    team/russell/frame_caching/channels/chan_zap.c
    team/russell/frame_caching/channels/iax2-parser.h
    team/russell/frame_caching/frame.c
    team/russell/frame_caching/include/asterisk/channel.h
    team/russell/frame_caching/include/asterisk/chanspy.h
    team/russell/frame_caching/include/asterisk/frame.h
    team/russell/frame_caching/include/asterisk/slinfactory.h
    team/russell/frame_caching/slinfactory.c
    team/russell/frame_caching/udptl.c

Modified: team/russell/frame_caching/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/apps/app_milliwatt.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/apps/app_milliwatt.c (original)
+++ team/russell/frame_caching/apps/app_milliwatt.c Mon Jul 31 14:30:20 2006
@@ -67,10 +67,16 @@
 
 static int milliwatt_generate(struct ast_channel *chan, void *data, int len, int samples)
 {
-	struct ast_frame wf;
 	unsigned char buf[AST_FRIENDLY_OFFSET + 640];
 	const int maxsamples = sizeof (buf) / sizeof (buf[0]);
 	int i, *indexp = (int *) data;
+	struct ast_frame wf = {
+		.frametype = AST_FRAME_VOICE,
+		.subclass = AST_FORMAT_ULAW,
+		.offset = AST_FRIENDLY_OFFSET,
+		.data = buf + AST_FRIENDLY_OFFSET,
+		.src = __FUNCTION__,
+	};
 
 	/* Instead of len, use samples, because channel.c generator_force
 	* generate(chan, tmp, 0, 160) ignores len. In any case, len is
@@ -83,17 +89,8 @@
 		samples = maxsamples;
 	}
 	len = samples * sizeof (buf[0]);
-	wf.frametype = AST_FRAME_VOICE;
-	wf.subclass = AST_FORMAT_ULAW;
-	wf.offset = AST_FRIENDLY_OFFSET;
-	wf.mallocd = 0;
-	wf.data = buf + AST_FRIENDLY_OFFSET;
 	wf.datalen = len;
 	wf.samples = samples;
-	wf.src = "app_milliwatt";
-	wf.delivery.tv_sec = 0;
-	wf.delivery.tv_usec = 0;
-	wf.prev = wf.next = NULL;
 	/* create a buffer containing the digital milliwatt pattern */
 	for(i = 0; i < len; i++)
 	{

Modified: team/russell/frame_caching/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/apps/app_mixmonitor.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/apps/app_mixmonitor.c (original)
+++ team/russell/frame_caching/apps/app_mixmonitor.c Mon Jul 31 14:30:20 2006
@@ -192,7 +192,7 @@
 			   of frames if a queue flush was necessary, so process them
 			*/
 			for (; f; f = next) {
-				next = f->next;
+				next = AST_LIST_NEXT(f, frame_list);
 				if (write)
 					ast_writestream(mixmonitor->fs, f);
 				ast_frfree(f);

Modified: team/russell/frame_caching/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channel.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/channel.c (original)
+++ team/russell/frame_caching/channel.c Mon Jul 31 14:30:20 2006
@@ -711,7 +711,7 @@
 int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
 {
 	struct ast_frame *f;
-	struct ast_frame *prev, *cur;
+	struct ast_frame *cur;
 	int blah = 1;
 	int qlen = 0;
 
@@ -721,15 +721,13 @@
 		return -1;
 	}
 	ast_channel_lock(chan);
-	prev = NULL;
-	for (cur = chan->readq; cur; cur = cur->next) {
+	AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) {
 		if ((cur->frametype == AST_FRAME_CONTROL) && (cur->subclass == AST_CONTROL_HANGUP)) {
 			/* Don't bother actually queueing anything after a hangup */
 			ast_frfree(f);
 			ast_channel_unlock(chan);
 			return 0;
 		}
-		prev = cur;
 		qlen++;
 	}
 	/* Allow up to 96 voice frames outstanding, and up to 128 total frames */
@@ -744,10 +742,7 @@
 			return 0;
 		}
 	}
-	if (prev)
-		prev->next = f;
-	else
-		chan->readq = f;
+	AST_LIST_INSERT_TAIL(&chan->readq, f, frame_list);
 	if (chan->alertpipe[1] > -1) {
 		if (write(chan->alertpipe[1], &blah, sizeof(blah)) != sizeof(blah))
 			ast_log(LOG_WARNING, "Unable to write to alert pipe on %s, frametype/subclass %d/%d (qlen = %d): %s!\n",
@@ -978,7 +973,7 @@
 {
 	int fd;
 	struct ast_var_t *vardata;
-	struct ast_frame *f, *fp;
+	struct ast_frame *f;
 	struct varshead *headp;
 	struct ast_datastore *datastore = NULL;
 	char name[AST_CHANNEL_NAME];
@@ -1029,13 +1024,8 @@
 		close(fd);
 	if ((fd = chan->timingfd) > -1)
 		close(fd);
-	f = chan->readq;
-	chan->readq = NULL;
-	while(f) {
-		fp = f;
-		f = f->next;
-		ast_frfree(fp);
-	}
+	while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list)))
+		ast_frfree(f);
 	
 	/* Get rid of each of the data stores on the channel */
 	while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry)))
@@ -1252,14 +1242,11 @@
 
 	spy->chan = NULL;
 
-	for (f = spy->read_queue.head; f; f = spy->read_queue.head) {
-		spy->read_queue.head = f->next;
+	while ((f = AST_LIST_REMOVE_HEAD(&spy->read_queue.list, frame_list)))
 		ast_frfree(f);
-	}
-	for (f = spy->write_queue.head; f; f = spy->write_queue.head) {
-		spy->write_queue.head = f->next;
+	
+	while ((f = AST_LIST_REMOVE_HEAD(&spy->write_queue.list, frame_list)))
 		ast_frfree(f);
-	}
 
 	if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
 		ast_cond_destroy(&spy->trigger);
@@ -1342,8 +1329,6 @@
 	trans = (dir == SPY_READ) ? &chan->spies->read_translator : &chan->spies->write_translator;
 
 	AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
-		struct ast_frame *last;
-		struct ast_frame *f1;	/* the frame to append */
 		struct ast_channel_spy_queue *queue;
 
 		ast_mutex_lock(&spy->lock);
@@ -1375,7 +1360,7 @@
 					break;
 				}
 			}
-			f1 = translated_frame;
+			AST_LIST_INSERT_TAIL(&queue->list, ast_frdup(f), frame_list);
 		} else {
 			if (f->subclass != queue->format) {
 				ast_log(LOG_WARNING, "Spy '%s' on channel '%s' wants format '%s', but frame is '%s', dropping\n",
@@ -1384,17 +1369,8 @@
 				ast_mutex_unlock(&spy->lock);
 				continue;
 			}
-			f1 = f;
-		}
-		/* duplicate and append f1 to the tail */
-		f1 = ast_frdup(f1);
-
-		for (last = queue->head; last && last->next; last = last->next)
-			;
-		if (last)
-			last->next = f1;
-		else
-			queue->head = f1;
+			AST_LIST_INSERT_TAIL(&queue->list, ast_frdup(f), frame_list);
+		}
 
 		queue->samples += f->samples;
 
@@ -1430,10 +1406,8 @@
 					ast_log(LOG_DEBUG, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
 						spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
 				while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
-					struct ast_frame *drop = queue->head;
-					
+					struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list);
 					queue->samples -= drop->samples;
-					queue->head = drop->next;
 					ast_frfree(drop);
 				}
 			}
@@ -1943,7 +1917,7 @@
 			blah = ZT_EVENT_TIMER_EXPIRED;
 
 		if (blah == ZT_EVENT_TIMER_PING) {
-			if (!chan->readq || !chan->readq->next) {
+			if (AST_LIST_EMPTY(&chan->readq) || !AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) {
 				/* Acknowledge PONG unless we need it again */
 				if (ioctl(chan->timingfd, ZT_TIMERPONG, &blah)) {
 					ast_log(LOG_WARNING, "Failed to pong timer on '%s': %s\n", chan->name, strerror(errno));
@@ -1982,10 +1956,8 @@
 	}
 
 	/* Check for pending read queue */
-	if (chan->readq) {
-		f = chan->readq;
-		chan->readq = f->next;
-		f->next = NULL;
+	if (!AST_LIST_EMPTY(&chan->readq)) {
+		f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list);
 		/* Interpret hangup and return NULL */
 		/* XXX why not the same for frames from the channel ? */
 		if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
@@ -2011,11 +1983,13 @@
 
 	if (f) {
 		/* if the channel driver returned more than one frame, stuff the excess
-		   into the readq for the next ast_read call
+		   into the readq for the next ast_read call (note that we can safely assume
+		   that the readq is empty, because otherwise we would not have called into
+		   the channel driver and f would be only a single frame)
 		*/
-		if (f->next) {
-			chan->readq = f->next;
-			f->next = NULL;
+		if (AST_LIST_NEXT(f, frame_list)) {
+			AST_LIST_HEAD_SET_NOLOCK(&chan->readq, AST_LIST_NEXT(f, frame_list));
+			AST_LIST_NEXT(f, frame_list) = NULL;
 		}
 
 		switch (f->frametype) {
@@ -3065,7 +3039,7 @@
 	int x,i;
 	int res=0;
 	int origstate;
-	struct ast_frame *cur, *prev;
+	struct ast_frame *cur;
 	const struct ast_channel_tech *t;
 	void *t_pvt;
 	struct ast_callerid tmpcid;
@@ -3129,9 +3103,9 @@
 	clone->tech_pvt = t_pvt;
 
 	/* Swap the readq's */
-	cur = original->readq;
-	original->readq = clone->readq;
-	clone->readq = cur;
+	cur = AST_LIST_FIRST(&original->readq);
+	AST_LIST_HEAD_SET_NOLOCK(&original->readq, AST_LIST_FIRST(&clone->readq));
+	AST_LIST_HEAD_SET_NOLOCK(&clone->readq, cur);
 
 	/* Swap the alertpipes */
 	for (i = 0; i < 2; i++) {
@@ -3150,23 +3124,22 @@
 
 	/* Save any pending frames on both sides.  Start by counting
 	 * how many we're going to need... */
-	prev = NULL;
 	x = 0;
-	for (cur = clone->readq; cur; cur = cur->next) {
-		x++;
-		prev = cur;
-	}
-	/* If we had any, prepend them to the ones already in the queue, and
+	if (original->alertpipe[1] > -1) {
+		AST_LIST_TRAVERSE(&clone->readq, cur, frame_list)
+			x++;
+	}
+
+	/* If we had any, prepend them to the ones already in the queue, and 
 	 * load up the alertpipe */
-	if (prev) {
-		prev->next = original->readq;
-		original->readq = clone->readq;
-		clone->readq = NULL;
-		if (original->alertpipe[1] > -1) {
-			for (i = 0; i < x; i++)
-				write(original->alertpipe[1], &x, sizeof(x));
-		}
-	}
+	if (AST_LIST_FIRST(&clone->readq)) {
+		AST_LIST_INSERT_TAIL(&clone->readq, AST_LIST_FIRST(&original->readq), frame_list);
+		AST_LIST_HEAD_SET_NOLOCK(&original->readq, AST_LIST_FIRST(&clone->readq));
+		AST_LIST_HEAD_SET_NOLOCK(&clone->readq, NULL);
+		for (i = 0; i < x; i++)
+			write(original->alertpipe[1], &x, sizeof(x));
+	}
+	
 	clone->_softhangup = AST_SOFTHANGUP_DEV;
 
 
@@ -4053,9 +4026,7 @@
 	int bytestocopy;
 
 	while (samples) {
-		f = queue->head;
-
-		if (!f) {
+		if (!(f = AST_LIST_FIRST(&queue->list))) {
 			ast_log(LOG_ERROR, "Ran out of frames before buffer filled!\n");
 			break;
 		}
@@ -4070,10 +4041,9 @@
 		f->datalen -= bytestocopy;
 		f->offset += bytestocopy;
 		queue->samples -= tocopy;
-		if (!f->samples) {
-			queue->head = f->next;
-			ast_frfree(f);
-		}
+
+		if (!f->samples)
+			ast_frfree(AST_LIST_REMOVE_HEAD(&queue->list, frame_list));
 	}
 }
 
@@ -4103,19 +4073,19 @@
 	if (ast_test_flag(spy, CHANSPY_TRIGGER_FLUSH)) {
 		if (spy->read_queue.samples > spy->write_queue.samples) {
 			if (ast_test_flag(spy, CHANSPY_READ_VOLADJUST)) {
-				for (result = spy->read_queue.head; result; result = result->next)
+				AST_LIST_TRAVERSE(&spy->read_queue.list, result, frame_list)
 					ast_frame_adjust_volume(result, spy->read_vol_adjustment);
 			}
-			result = spy->read_queue.head;
-			spy->read_queue.head = NULL;
+			result = AST_LIST_FIRST(&spy->read_queue.list);
+			AST_LIST_HEAD_SET_NOLOCK(&spy->read_queue.list, NULL);
 			spy->read_queue.samples = 0;
 		} else {
 			if (ast_test_flag(spy, CHANSPY_WRITE_VOLADJUST)) {
-				for (result = spy->write_queue.head; result; result = result->next)
+				AST_LIST_TRAVERSE(&spy->write_queue.list, result, frame_list)
 					ast_frame_adjust_volume(result, spy->write_vol_adjustment);
 			}
-			result = spy->write_queue.head;
-			spy->write_queue.head = NULL;
+			result = AST_LIST_FIRST(&spy->write_queue.list);
+			AST_LIST_HEAD_SET_NOLOCK(&spy->write_queue.list, NULL);
 			spy->write_queue.samples = 0;
 		}
 		ast_clear_flag(spy, CHANSPY_TRIGGER_FLUSH);
@@ -4126,15 +4096,10 @@
 		return NULL;
 
 	/* short-circuit if both head frames have exactly what we want */
-	if ((spy->read_queue.head->samples == samples) &&
-	    (spy->write_queue.head->samples == samples)) {
-		read_frame = spy->read_queue.head;
-		spy->read_queue.head = read_frame->next;
-		read_frame->next = NULL;
-
-		write_frame = spy->write_queue.head;
-		spy->write_queue.head = write_frame->next;
-		write_frame->next = NULL;
+	if ((AST_LIST_FIRST(&spy->read_queue.list)->samples == samples) &&
+	    (AST_LIST_FIRST(&spy->write_queue.list)->samples == samples)) {
+		read_frame = AST_LIST_REMOVE_HEAD(&spy->read_queue.list, frame_list);
+		write_frame = AST_LIST_REMOVE_HEAD(&spy->write_queue.list, frame_list);
 
 		spy->read_queue.samples -= samples;
 		spy->write_queue.samples -= samples;
@@ -4167,10 +4132,10 @@
 	} else {
 		if (need_dup) {
 			result = ast_frdup(read_frame);
-			result->next = ast_frdup(write_frame);
+			AST_LIST_NEXT(result, frame_list) = ast_frdup(write_frame);
 		} else {
 			result = read_frame;
-			result->next = write_frame;
+			AST_LIST_NEXT(result, frame_list) = write_frame;
 		}
 	}
 

Modified: team/russell/frame_caching/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channels/chan_local.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/channels/chan_local.c (original)
+++ team/russell/frame_caching/channels/chan_local.c Mon Jul 31 14:30:20 2006
@@ -224,7 +224,7 @@
 	   frames on the owner channel (because they would be transferred to the
 	   outbound channel during the masquerade)
 	*/
-	if (isoutbound && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && !p->owner->readq) {
+	if (isoutbound && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && AST_LIST_EMPTY(&p->owner->readq)) {
 		/* Masquerade bridged channel into owner */
 		/* Lock everything we need, one by one, and give up if
 		   we can't get everything.  Remember, we'll get another
@@ -246,7 +246,7 @@
 	   when the local channels go away.
 	*/
 #if 0
-	} else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && !p->chan->readq) {
+	} else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && AST_LIST_EMPTY(&p->chan->readq)) {
 		/* Masquerade bridged channel into chan */
 		if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
 			if (!p->owner->_bridge->_softhangup) {

Modified: team/russell/frame_caching/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channels/chan_zap.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/channels/chan_zap.c (original)
+++ team/russell/frame_caching/channels/chan_zap.c Mon Jul 31 14:30:20 2006
@@ -3518,7 +3518,6 @@
 	pthread_t threadid;
 	pthread_attr_t attr;
 	struct ast_channel *chan;
-	struct ast_frame dtmf_frame = { .frametype = AST_FRAME_DTMF };
 
 	pthread_attr_init(&attr);
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
@@ -3560,10 +3559,8 @@
 			   and a DTMF_BEGIN event for channels that handle variable duration
 			   DTMF events
 			*/
-			p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
+			p->subs[index].f.frametype = AST_FRAME_DTMF;
 			p->subs[index].f.subclass = res & 0xff;
-			dtmf_frame.subclass = res & 0xff;
-			p->subs[index].f.next = ast_frdup(&dtmf_frame);
 #ifdef HAVE_PRI
 		}
 #endif

Modified: team/russell/frame_caching/channels/iax2-parser.h
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channels/iax2-parser.h?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/channels/iax2-parser.h (original)
+++ team/russell/frame_caching/channels/iax2-parser.h Mon Jul 31 14:30:20 2006
@@ -119,6 +119,8 @@
 	struct iax_frame *prev;
 	/* Actual, isolated frame header */
 	struct ast_frame af;
+	/*! Amount of space _allocated_ for data */
+	size_t mallocd_datalen;
 	unsigned char unused[AST_FRIENDLY_OFFSET];
 	unsigned char afdata[0];	/* Data for frame */
 };

Modified: team/russell/frame_caching/frame.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/frame.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/frame.c (original)
+++ team/russell/frame_caching/frame.c Mon Jul 31 14:30:20 2006
@@ -46,8 +46,7 @@
 
 #ifdef TRACE_FRAMES
 static int headers = 0;
-static struct ast_frame *headerlist = NULL;
-AST_MUTEX_DEFINE_STATIC(framelock);
+static AST_LIST_HEAD_STATIC(headerlist, ast_frame);
 #endif
 
 static unsigned int mallocd_header_data_src = 0;
@@ -293,13 +292,10 @@
 
 	f->mallocd_hdr_len = sizeof(*f);
 #ifdef TRACE_FRAMES
-	ast_mutex_lock(&framelock);
+	AST_LIST_LOCK(&headerlist);
 	headers++;
-	f->next = headerlist;
-	if (headerlist)
-		headerlist->prev = f;
-	headerlist = f;
-	ast_mutex_unlock(&framelock);
+	AST_LIST_INSERT_HEAD(&headerlist, f, frame_list);
+	AST_LIST_UNLOCK(&headerlist);
 #endif	
 	
 	return f;
@@ -369,15 +365,10 @@
 	}
 	if (fr->mallocd & AST_MALLOCD_HDR) {
 #ifdef TRACE_FRAMES
-		ast_mutex_lock(&framelock);
+		AST_LIST_LOCK(&headerlist);
 		headers--;
-		if (fr->next)
-			fr->next->prev = fr->prev;
-		if (fr->prev)
-			fr->prev->next = fr->next;
-		else
-			headerlist = fr->next;
-		ast_mutex_unlock(&framelock);
+		AST_LIST_REMOVE(&headerlist, fr, frame_list);
+		AST_LIST_UNLOCK(&headerlist);
 #endif			
 		free(fr);
 	}
@@ -963,15 +954,14 @@
 	int x=1;
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-	ast_mutex_lock(&framelock);
+	AST_LIST_LOCK(&headerlist);
 	ast_cli(fd, "     Framer Statistics     \n");
 	ast_cli(fd, "---------------------------\n");
 	ast_cli(fd, "Total allocated headers: %d\n", headers);
 	ast_cli(fd, "Queue Dump:\n");
-	for (f=headerlist; f; f = f->next) {
+	AST_LIST_TRAVERSE(&headerlist, f, frame_list)
 		ast_cli(fd, "%d.  Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
-	}
-	ast_mutex_unlock(&framelock);
+	AST_LIST_UNLOCK(&headerlist);
 	return RESULT_SUCCESS;
 }
 
@@ -1477,28 +1467,3 @@
 
 	return 0;
 }
-
-struct ast_frame *ast_frame_enqueue(struct ast_frame *head, struct ast_frame *f, int maxlen, int dupe)
-{
-	struct ast_frame *cur, *oldhead;
-	int len=0;
-	if (f && dupe)
-		f = ast_frdup(f);
-	if (!f)
-		return head;
-
-	f->next = NULL;
-	if (!head) 
-		return f;
-	cur = head;
-	while(cur->next) {
-		cur = cur->next;
-		len++;
-		if (len >= maxlen) {
-			oldhead = head;
-			head = head->next;
-			ast_frfree(oldhead);
-		}
-	}
-	return head;
-}

Modified: team/russell/frame_caching/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/include/asterisk/channel.h?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/include/asterisk/channel.h (original)
+++ team/russell/frame_caching/include/asterisk/channel.h Mon Jul 31 14:30:20 2006
@@ -372,7 +372,7 @@
 	unsigned int pickupgroup;			/*!< Pickup group - which calls groups can be picked up? */
 	unsigned int flags;				/*!< channel flags of AST_FLAG_ type */
 	unsigned short transfercapability;		/*!< ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */
-	struct ast_frame *readq;
+	AST_LIST_HEAD_NOLOCK(, ast_frame) readq;
 	int alertpipe[2];
 
 	int nativeformats;				/*!< Kinds of data this channel can natively handle */

Modified: team/russell/frame_caching/include/asterisk/chanspy.h
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/include/asterisk/chanspy.h?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/include/asterisk/chanspy.h (original)
+++ team/russell/frame_caching/include/asterisk/chanspy.h Mon Jul 31 14:30:20 2006
@@ -49,7 +49,7 @@
 };
 
 struct ast_channel_spy_queue {
-	struct ast_frame *head;
+	AST_LIST_HEAD_NOLOCK(, ast_frame) list;
 	unsigned int samples;
 	unsigned int format;
 };

Modified: team/russell/frame_caching/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/include/asterisk/frame.h?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/include/asterisk/frame.h (original)
+++ team/russell/frame_caching/include/asterisk/frame.h Mon Jul 31 14:30:20 2006
@@ -108,11 +108,7 @@
 	void *data;		
 	/*! Global delivery time */		
 	struct timeval delivery;
-	/*! Next/Prev for linking stand alone frames */
-	struct ast_frame *prev;			
-	/*! Next/Prev for linking stand alone frames */
-	struct ast_frame *next;			
-	/*! XXX This should replace the next/prev pointers XXX */
+	/*! For placing in a linked list */
 	AST_LIST_ENTRY(ast_frame) frame_list;
 	/*! Timing data flag */
 	int has_timing_info;

Modified: team/russell/frame_caching/include/asterisk/slinfactory.h
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/include/asterisk/slinfactory.h?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/include/asterisk/slinfactory.h (original)
+++ team/russell/frame_caching/include/asterisk/slinfactory.h Mon Jul 31 14:30:20 2006
@@ -32,7 +32,7 @@
 #endif
 
 struct ast_slinfactory {
-	struct ast_frame *queue;
+	AST_LIST_HEAD_NOLOCK(, ast_frame) queue;
 	struct ast_trans_pvt *trans;
 	short hold[1280];
 	short *offset;

Modified: team/russell/frame_caching/slinfactory.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/slinfactory.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/slinfactory.c (original)
+++ team/russell/frame_caching/slinfactory.c Mon Jul 31 14:30:20 2006
@@ -39,7 +39,6 @@
 {
 	memset(sf, 0, sizeof(*sf));
 	sf->offset = sf->hold;
-	sf->queue = NULL;
 }
 
 void ast_slinfactory_destroy(struct ast_slinfactory *sf) 
@@ -51,10 +50,8 @@
 		sf->trans = NULL;
 	}
 
-	while ((f = sf->queue)) {
-		sf->queue = f->next;
+	while ((f = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list)))
 		ast_frfree(f);
-	}
 }
 
 int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
@@ -85,15 +82,12 @@
 	if (!frame)
 		return 0;
 
-	for (x = 0, frame_ptr = sf->queue; frame_ptr && frame_ptr->next; frame_ptr = frame_ptr->next)
+	x = 0;
+	AST_LIST_TRAVERSE(&sf->queue, frame_ptr, frame_list)
 		x++;
 
-	if (frame_ptr)
-		frame_ptr->next = frame;
-	else
-		sf->queue = frame;
+	AST_LIST_INSERT_TAIL(&sf->queue, frame, frame_list);
 
-	frame->next = NULL;
 	sf->size += frame->samples;
 
 	return x;
@@ -125,8 +119,7 @@
 			continue;
 		}
 		
-		if ((frame_ptr = sf->queue)) {
-			sf->queue = frame_ptr->next;
+		if ((frame_ptr = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list))) {
 			frame_data = frame_ptr->data;
 			
 			if ((sofar + frame_ptr->samples) <= ineed) {

Modified: team/russell/frame_caching/udptl.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/udptl.c?rev=38607&r1=38606&r2=38607&view=diff
==============================================================================
--- team/russell/frame_caching/udptl.c (original)
+++ team/russell/frame_caching/udptl.c Mon Jul 31 14:30:20 2006
@@ -296,8 +296,7 @@
 
 	ptr = 0;
 	ifp_no = 0;
-	s->f[0].prev = NULL;
-	s->f[0].next = NULL;
+	memset(&s->f[0], 0, sizeof(s->f[0]));
 
 	/* Decode seq_number */
 	if (ptr + 2 > len)
@@ -342,11 +341,9 @@
 					s->f[ifp_no].data = (uint8_t *) bufs[i - 1];
 					s->f[ifp_no].offset = 0;
 					s->f[ifp_no].src = "UDPTL";
-					if (ifp_no > 0) {
-						s->f[ifp_no].prev = &s->f[ifp_no - 1];
-						s->f[ifp_no - 1].next = &s->f[ifp_no];
-					}
-					s->f[ifp_no].next = NULL;
+					if (ifp_no > 0)
+						AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+					AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
 					ifp_no++;
 				}
 			}
@@ -364,11 +361,9 @@
 			s->f[ifp_no].data = (uint8_t *) ifp;
 			s->f[ifp_no].offset = 0;
 			s->f[ifp_no].src = "UDPTL";
-			if (ifp_no > 0) {
-				s->f[ifp_no].prev = &s->f[ifp_no - 1];
-				s->f[ifp_no - 1].next = &s->f[ifp_no];
-			}
-			s->f[ifp_no].next = NULL;
+			if (ifp_no > 0)
+				AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+			AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
 		}
 	}
 	else
@@ -465,11 +460,9 @@
 				s->f[ifp_no].data = s->rx[l].buf;
 				s->f[ifp_no].offset = 0;
 				s->f[ifp_no].src = "UDPTL";
-				if (ifp_no > 0) {
-					s->f[ifp_no].prev = &s->f[ifp_no - 1];
-					s->f[ifp_no - 1].next = &s->f[ifp_no];
-				}
-				s->f[ifp_no].next = NULL;
+				if (ifp_no > 0)
+					AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+				AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
 				ifp_no++;
 			}
 		}
@@ -483,11 +476,9 @@
 		s->f[ifp_no].data = (uint8_t *) ifp;
 		s->f[ifp_no].offset = 0;
 		s->f[ifp_no].src = "UDPTL";
-		if (ifp_no > 0) {
-			s->f[ifp_no].prev = &s->f[ifp_no - 1];
-			s->f[ifp_no - 1].next = &s->f[ifp_no];
-		}
-		s->f[ifp_no].next = NULL;
+		if (ifp_no > 0)
+			AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
+		AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
 	}
 
 	s->rx_seq_no = seq_no + 1;



More information about the asterisk-commits mailing list