aboutsummaryrefslogtreecommitdiffstats
path: root/muted.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-05-17 07:00:21 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-05-17 07:00:21 +0000
commite6f5791a7c0dd5dc899ce9d4ad67574975a38a75 (patch)
tree8ebe9a721f256e4079fb28726bd98deec20ab0a9 /muted.c
parent39023ecb8bfb708f533396cde77fbc25478d3f59 (diff)
manage multiple subchannels per device
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2991 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'muted.c')
-rwxr-xr-xmuted.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/muted.c b/muted.c
index c4e03ddb1..135a4164b 100755
--- a/muted.c
+++ b/muted.c
@@ -36,11 +36,16 @@ static int debug = 0;
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 @@ static void check_mute(void)
struct channel *chan;
chan = channels;
while(chan) {
- if (chan->offhook) {
+ if (chan->subs) {
offhook++;
break;
}
@@ -382,12 +387,50 @@ static void check_mute(void)
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 @@ static void offhook_chan(char *channel)
struct channel *chan;
chan = find_channel(channel);
if (chan)
- chan->offhook = 1;
+ append_sub(chan, channel);
check_mute();
}