[Asterisk-cvs] asterisk muted.c,1.1,1.2
markster at lists.digium.com
markster at lists.digium.com
Mon May 17 02:48:33 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv7586
Modified Files:
muted.c
Log Message:
manage multiple subchannels per device
Index: muted.c
===================================================================
RCS file: /usr/cvsroot/asterisk/muted.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- muted.c 17 May 2004 06:31:24 -0000 1.1
+++ muted.c 17 May 2004 07:00:21 -0000 1.2
@@ -36,11 +36,16 @@
static int stepsize = 3;
static int mixchan = SOUND_MIXER_VOLUME;
+struct subchannel {
+ char *name;
+ struct subchannel *next;
+};
+
static struct channel {
char *tech;
char *location;
struct channel *next;
- int offhook;
+ struct subchannel *subs;
} *channels;
static void add_channel(char *tech, char *location)
@@ -370,7 +375,7 @@
struct channel *chan;
chan = channels;
while(chan) {
- if (chan->offhook) {
+ if (chan->subs) {
offhook++;
break;
}
@@ -382,12 +387,50 @@
unmute();
}
+static void delete_sub(struct channel *chan, char *name)
+{
+ struct subchannel *sub, *prev;
+ prev = NULL;
+ sub = chan->subs;
+ while(sub) {
+ if (!strcasecmp(sub->name, name)) {
+ if (prev)
+ prev->next = sub->next;
+ else
+ chan->subs = sub->next;
+ free(sub->name);
+ free(sub);
+ return;
+ }
+ prev = sub;
+ sub = sub->next;
+ }
+}
+
+static void append_sub(struct channel *chan, char *name)
+{
+ struct subchannel *sub;
+ sub = chan->subs;
+ while(sub) {
+ if (!strcasecmp(sub->name, name))
+ return;
+ sub = sub->next;
+ }
+ sub = malloc(sizeof(struct subchannel));
+ if (sub) {
+ memset(sub, 0, sizeof(struct subchannel));
+ sub->name = strdup(name);
+ sub->next = chan->subs;
+ chan->subs = sub;
+ }
+}
+
static void hangup_chan(char *channel)
{
struct channel *chan;
chan = find_channel(channel);
if (chan)
- chan->offhook = 0;
+ delete_sub(chan, channel);
check_mute();
}
@@ -396,7 +439,7 @@
struct channel *chan;
chan = find_channel(channel);
if (chan)
- chan->offhook = 1;
+ append_sub(chan, channel);
check_mute();
}
More information about the svn-commits
mailing list