Revision
15896
Author
anthm
Date
2009-12-10 20:24:41 -0600 (Thu, 10 Dec 2009)

Log Message

FSCORE-510

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_async.c (15895 => 15896)


--- freeswitch/trunk/src/switch_ivr_async.c	2009-12-11 02:11:04 UTC (rev 15895)
+++ freeswitch/trunk/src/switch_ivr_async.c	2009-12-11 02:24:41 UTC (rev 15896)
@@ -1553,23 +1553,23 @@
 				frame = switch_core_media_bug_get_write_replace_frame(bug);
 			}
 
-			while (switch_queue_trypop(pvt->digit_queue, &pop) == SWITCH_STATUS_SUCCESS) {
-				switch_dtmf_t *dtmf = (switch_dtmf_t *) pop;
-				char buf[2] = "";
-				int duration = dtmf->duration;
+			if (!switch_buffer_inuse(pvt->audio_buffer)) {
+				while (switch_queue_trypop(pvt->digit_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+					switch_dtmf_t *dtmf = (switch_dtmf_t *) pop;
+					char buf[2] = "";
+					int duration = dtmf->duration;
 
-				buf[0] = dtmf->digit;
-				if (duration > 8000) {
-					duration = 4000;
-					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n",
-									  switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8);
+					buf[0] = dtmf->digit;
+					if (duration > 8000) {
+						duration = 4000;
+						switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n",
+										  switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8);
+					}
+					pvt->ts.duration = duration;
+					teletone_run(&pvt->ts, buf);
+					free(pop);
 				}
-				pvt->ts.duration = duration;
-				teletone_run(&pvt->ts, buf);
-				free(pop);
-			}
-
-			if (switch_buffer_inuse(pvt->audio_buffer) && (bytes = switch_buffer_read(pvt->audio_buffer, frame->data, frame->datalen))) {
+			} else if (switch_buffer_inuse(pvt->audio_buffer) && (bytes = switch_buffer_read(pvt->audio_buffer, frame->data, frame->datalen))) {
 				if (bytes < frame->datalen) {
 					switch_byte_t *dp = frame->data;
 					memset(dp + bytes, 0, frame->datalen - bytes);