Changeset 5003
Spy list now only needs the head.
We don't have to keep the list ordered so we don't need both a head
and a tail. This allows us to save a few bytes per channel and have
more straightforward code.
This commit changes (yet again) the size and layout of the cw_channel
structure.
Committed by:
karvan
Date:
Jun 27 2008 * 22:27 (5 months ago)
Affected files:
callweaver/trunk/apps/icd/icd_command.c (diff)
callweaver/trunk/apps/icd/icd_conference.c (diff)
callweaver/trunk/corelib/channel.c (diff)
callweaver/trunk/include/callweaver/channel.h (diff)
callweaver/trunk/apps/icd/icd_command.c (unified diff)
| r4992 | r5003 | |
|---|---|---|
| 1448 | 1448 | cw_cli_command(fd, buf); |
| 1449 | 1449 | return 0; |
| 1450 | 1450 | } |
| 1451 | if(chan->spies.head != NULL){ | |
| 1451 | if(chan->spies != NULL){ | |
| 1452 | 1452 | cw_log(CW_LOG_NOTICE, "Start of recording for customer [%s] failed - already recording \n", customer_source); |
| 1453 | 1453 | manager_event(EVENT_FLAG_USER, "icd_command", |
| 1454 | 1454 | "Command: Record\r\nSubCommand: Start\r\nResult: Fail\r\nCause: Already recording\r\nCallerID: %s\r\n", |
callweaver/trunk/apps/icd/icd_conference.c (unified diff)
| r4999 | r5003 | |
|---|---|---|
| 521 | 521 | |
| 522 | 522 | /* This part of code (if) is for ZAP channels to make possible for muxmon to record 2 channels */ |
| 523 | 523 | if(!strcmp(chan->type, "DAHDI")){ |
| 524 | if (chan->spies.head && (read_frame->frametype == CW_FRAME_VOICE) | |
| 524 | if (chan->spies && (read_frame->frametype == CW_FRAME_VOICE) | |
| 525 | 525 | && (read_frame->subclass == icd_conf_format)) { |
| 526 | 526 | struct cw_channel_spy *spying; |
| 527 | for (spying = chan->spies.head; spying; spying=spying->next) { | |
| 527 | for (spying = chan->spies; spying; spying=spying->next) { | |
| 528 | 528 | cw_spy_queue_frame(spying, read_frame, 1); |
| 529 | 529 | } |
| 530 | 530 | } |
callweaver/trunk/corelib/channel.c (unified diff)
| r4999 | r5003 | |
|---|---|---|
| 1062 | 1062 | { |
| 1063 | 1063 | struct cw_channel_spy *chanspy; |
| 1064 | 1064 | |
| 1065 | for (chanspy = chan->spies.head; chanspy; chanspy = chanspy->next) | |
| 1065 | for (chanspy = chan->spies; chanspy; chanspy = chanspy->next) | |
| 1066 | 1066 | { |
| 1067 | 1067 | if (chanspy->status == CHANSPY_RUNNING) |
| 1068 | 1068 | chanspy->status = CHANSPY_DONE; |
| 1069 | 1069 | } |
| 1070 | chan->spies.head = chan->spies.tail = NULL; | |
| 1070 | chan->spies = NULL; | |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | 1073 | /*--- cw_spy_attach: Attach another spy in the given channel. */ |
| --- | --- | |
| 1082 | 1082 | struct cw_channel *peer; |
| 1083 | 1083 | |
| 1084 | 1084 | cw_mutex_lock(&chan->lock); |
| 1085 | if (chan->spies.head) { | |
| 1086 | chan->spies.tail->next = newspy; | |
| 1087 | chan->spies.tail = newspy; | |
| 1088 | } else { | |
| 1089 | chan->spies.head = chan->spies.tail = newspy; | |
| 1090 | } | |
| 1085 | newspy->next = chan->spies; | |
| 1086 | chan->spies = newspy; | |
| 1091 | 1087 | cw_mutex_unlock(&chan->lock); |
| 1092 | 1088 | if (cw_test_flag(chan, CW_FLAG_NBRIDGE) |
| 1093 | 1089 | && (peer = cw_bridged_channel(chan))) |
| --- | --- | |
| 1105 | 1101 | void cw_spy_detach(struct cw_channel *chan, struct cw_channel_spy *oldspy) |
| 1106 | 1102 | { |
| 1107 | 1103 | struct cw_channel_spy *cur, *prev = NULL; |
| 1108 | for (cur = chan->spies.head ; cur && cur != oldspy; cur = cur->next) { | |
| 1104 | for (cur = chan->spies ; cur && cur != oldspy; cur = cur->next) { | |
| 1109 | 1105 | prev = cur; |
| 1110 | 1106 | } |
| 1111 | 1107 | if (cur) { /* We found the spy in our list. */ |
| 1112 | if (chan->spies.head == cur) | |
| 1113 | chan->spies.head = cur->next; | |
| 1108 | if (chan->spies == cur) | |
| 1109 | chan->spies = cur->next; | |
| 1114 | 1110 | else |
| 1115 | 1111 | prev->next = cur->next; |
| 1116 | if (chan->spies.tail == cur) | |
| 1117 | chan->spies.tail = prev; | |
| 1118 | 1112 | } else { /* Is this ever possible? */ |
| 1119 | 1113 | cw_log(CW_LOG_WARNING, "Unknown spy in cw_spy_detach().\n"); |
| 1120 | 1114 | } |
| --- | --- | |
| 1826 | 1820 | } |
| 1827 | 1821 | else |
| 1828 | 1822 | { |
| 1829 | if (chan->spies.head) | |
| 1823 | if (chan->spies) | |
| 1830 | 1824 | { |
| 1831 | 1825 | struct cw_channel_spy *spying; |
| 1832 | 1826 | |
| 1833 | for (spying = chan->spies.head; spying; spying = spying->next) | |
| 1827 | for (spying = chan->spies; spying; spying = spying->next) | |
| 1834 | 1828 | cw_spy_queue_frame(spying, f, 0); |
| 1835 | 1829 | } |
| 1836 | 1830 | if (chan->monitor && chan->monitor->read_stream) |
| --- | --- | |
| 2254 | 2248 | * let the channel driver use a writer thread |
| 2255 | 2249 | * to actually write the stuff, for example. */ |
| 2256 | 2250 | |
| 2257 | if (f->frametype == CW_FRAME_VOICE && chan->spies.head) | |
| 2251 | if (f->frametype == CW_FRAME_VOICE && chan->spies) | |
| 2258 | 2252 | { |
| 2259 | 2253 | struct cw_channel_spy *spying; |
| 2260 | 2254 | |
| 2261 | for (spying = chan->spies.head; spying; spying = spying->next) | |
| 2255 | for (spying = chan->spies; spying; spying = spying->next) | |
| 2262 | 2256 | cw_spy_queue_frame(spying, f, 1); |
| 2263 | 2257 | } |
| 2264 | 2258 | |
| --- | --- | |
| 3652 | 3646 | if (c0->tech->bridge && |
| 3653 | 3647 | (config->timelimit == 0) && |
| 3654 | 3648 | (c0->tech->bridge == c1->tech->bridge) && |
| 3655 | !nativefailed && !c0->monitor && !c1->monitor && !c0->spies.head && !c1->spies.head) | |
| 3649 | !nativefailed && !c0->monitor && !c1->monitor && !c0->spies && !c1->spies) | |
| 3656 | 3650 | { |
| 3657 | 3651 | /* Looks like they share a bridge method */ |
| 3658 | 3652 | if (option_verbose > 2) |
callweaver/trunk/include/callweaver/channel.h (unified diff)
| r4999 | r5003 | |
|---|---|---|
| 338 | 338 | int rawwriteformat; |
| 339 | 339 | |
| 340 | 340 | /*! Chan Spy stuff */ |
| 341 | struct { | |
| 342 | struct cw_channel_spy *head; | |
| 343 | struct cw_channel_spy *tail; | |
| 344 | } spies; | |
| 341 | struct cw_channel_spy *spies; | |
| 345 | 342 | |
| 346 | 343 | /*! For easy linking */ |
| 347 | 344 | struct cw_channel *next; |
![Home changeset 5003 [home]](/images/logo.png?1180520111)
RSS Feeds