aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-05-21 17:16:24 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-05-23 09:59:25 +0200
commit9905b18811af33aa87ae2920ec13e84a33dfa1dc (patch)
tree4f8584ebab10180aaec911678b50575c8e369419 /src
parent6c981176abb0aa4e0edd63a107a6fb1b8e780cbb (diff)
dtmf: Make the API more robust and avoid inconsistencies
Because of the issue parsing the MGCP request a '\0' was added to the queue. This lead to the dtmf scheduler believing that a play was in progress while the playing code didn't play anything. This lead to the queue to be stuck and nothing being played at all. Return the number of tones that should be played and stop using strlen on the tones.
Diffstat (limited to 'src')
-rw-r--r--src/dtmf_scheduler.c7
-rw-r--r--src/mgcp_ss7.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/src/dtmf_scheduler.c b/src/dtmf_scheduler.c
index a344e76..4f64eb0 100644
--- a/src/dtmf_scheduler.c
+++ b/src/dtmf_scheduler.c
@@ -1,6 +1,6 @@
/*
- * (C) 2012 by Holger Hans Peter Freyther
- * (C) 2012 by On-Waves
+ * (C) 2012-2013 by Holger Hans Peter Freyther
+ * (C) 2012-2013 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@@ -37,7 +37,7 @@ int dtmf_state_add(struct dtmf_state *state, char tone)
return 0;
}
-void dtmf_state_get_pending(struct dtmf_state *state, char *tones)
+unsigned int dtmf_state_get_pending(struct dtmf_state *state, char *tones)
{
int pos;
@@ -51,6 +51,7 @@ void dtmf_state_get_pending(struct dtmf_state *state, char *tones)
if (pos > 0)
state->playing = 1;
tones[pos] = '\0';
+ return pos;
}
void dtmf_state_played(struct dtmf_state *state)
diff --git a/src/mgcp_ss7.c b/src/mgcp_ss7.c
index e4d8799..3490a9a 100644
--- a/src/mgcp_ss7.c
+++ b/src/mgcp_ss7.c
@@ -74,18 +74,19 @@ static void play_pending_tones(struct mgcp_endpoint *endp)
{
ToneGenerationT toneGeneration;
char tones[25];
+ size_t len;
/* Check if we need to play anything? */
- dtmf_state_get_pending(&endp->dtmf_state, tones);
+ len = dtmf_state_get_pending(&endp->dtmf_state, tones);
/* nothing to play? */
- if (strlen(tones) == 0)
+ if (len == 0)
return;
/* fill out the data now */
osmo_static_assert(sizeof(tones) <= sizeof(toneGeneration.list), Enough_space_for_tones);
memset(&toneGeneration, 0, sizeof(toneGeneration));
- toneGeneration.count = strlen(tones);
+ toneGeneration.count = len;
strcpy(toneGeneration.list, tones);
MtnSaSetMOB(endp->audio_port, ChannelType_PORT,
PredefMob_C_TONE_GENERATION, (char *) &toneGeneration,