[Freeswitch-svn] [commit] r1902 - in freeswitch/trunk: libs/libteletone/src src src/mod/applications/mod_conference src/mod/endpoints/mod_dingaling

Freeswitch SVN anthm at freeswitch.org
Mon Jul 17 10:12:07 EDT 2006


Author: anthm
Date: Mon Jul 17 10:12:07 2006
New Revision: 1902

Modified:
   freeswitch/trunk/libs/libteletone/src/libteletone_generate.c
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/switch_core.c

Log:
messaging stuff

Modified: freeswitch/trunk/libs/libteletone/src/libteletone_generate.c
==============================================================================
--- freeswitch/trunk/libs/libteletone/src/libteletone_generate.c	(original)
+++ freeswitch/trunk/libs/libteletone/src/libteletone_generate.c	Mon Jul 17 10:12:07 2006
@@ -30,6 +30,9 @@
  *
  */
 #include <libteletone.h>
+#define SMAX 32767
+#define SMIN -32768
+#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN;
 
 
 
@@ -163,6 +166,7 @@
 			for (i = 0; i < freqlen; i++) {
 				sample += ((teletone_process_t) 2 * (ts->volume > 0 ? ts->volume : 1) * cos(tones[i] * ts->samples * period));
 			}
+			normalize_to_16bit(sample);
 			ts->buffer[ts->samples] = (teletone_audio_t)sample;
 			
 			for (c = 1; c < ts->channels; c++) {

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Mon Jul 17 10:12:07 2006
@@ -704,129 +704,134 @@
 		switch_size_t file_sample_len = samples;
 		char *digit;
 		char msg[512];
+		switch_event_t *event;
 
+		if (switch_core_session_dequeue_event(member->session, &event) == SWITCH_STATUS_SUCCESS) {
+			switch_event_destroy(&event);
+		}
+
         if (switch_channel_has_dtmf(channel)) {
             switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
-        }
 
-		for (digit = dtmf; *digit; digit++) {
-			switch(*digit) {
-			case '0':
-				if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-					switch_clear_flag_locked(member, MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR);
-					if (member->conference->muted_sound) {
-						conference_member_play_file(member, member->conference->muted_sound, 0);
+			for (digit = dtmf; *digit; digit++) {
+				switch(*digit) {
+				case '0':
+					if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+						switch_clear_flag_locked(member, MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR);
+						if (member->conference->muted_sound) {
+							conference_member_play_file(member, member->conference->muted_sound, 0);
+						} else {
+							snprintf(msg, sizeof(msg), "Muted");
+							conference_member_say(member->conference, member, msg, 0);
+						}
 					} else {
-						snprintf(msg, sizeof(msg), "Muted");
-						conference_member_say(member->conference, member, msg, 0);
+						switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
+						if (member->conference->unmuted_sound) {
+							conference_member_play_file(member, member->conference->unmuted_sound, 0);
+						} else {
+							snprintf(msg, sizeof(msg), "Un-Muted");
+							conference_member_say(member->conference, member, msg, 0);
+						}
 					}
-				} else {
-					switch_set_flag_locked(member, MFLAG_CAN_SPEAK);
-					if (member->conference->unmuted_sound) {
-						conference_member_play_file(member, member->conference->unmuted_sound, 0);
+					break;
+				case '*':
+					if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+						switch_clear_flag_locked(member, MFLAG_CAN_SPEAK|MFLAG_CAN_HEAR);
+						if (member->conference->muted_sound) {
+							conference_member_play_file(member, member->conference->muted_sound, 0);
+						} else {
+							snprintf(msg, sizeof(msg), "Muted");
+							conference_member_say(member->conference, member, msg, 0);
+						}
 					} else {
-						snprintf(msg, sizeof(msg), "Un-Muted");
-						conference_member_say(member->conference, member, msg, 0);
+						switch_set_flag_locked(member, MFLAG_CAN_SPEAK|MFLAG_CAN_HEAR);
+						if (member->conference->unmuted_sound) {
+							conference_member_play_file(member, member->conference->unmuted_sound, 0);
+						} else {
+							snprintf(msg, sizeof(msg), "UN-Muted");
+							conference_member_say(member->conference, member, msg, 0);
+						}
 					}
-				}
-				break;
-			case '*':
-				if (switch_test_flag(member, MFLAG_CAN_SPEAK)) {
-					switch_clear_flag_locked(member, MFLAG_CAN_SPEAK|MFLAG_CAN_HEAR);
-					if (member->conference->muted_sound) {
-						conference_member_play_file(member, member->conference->muted_sound, 0);
-					} else {
-						snprintf(msg, sizeof(msg), "Muted");
-						conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '9':
+					switch_mutex_lock(member->flag_mutex);
+					member->energy_level += 100;
+					if (member->energy_level > 1200) {
+						member->energy_level = 1200;
 					}
-				} else {
-					switch_set_flag_locked(member, MFLAG_CAN_SPEAK|MFLAG_CAN_HEAR);
-					if (member->conference->unmuted_sound) {
-						conference_member_play_file(member, member->conference->unmuted_sound, 0);
-					} else {
-						snprintf(msg, sizeof(msg), "UN-Muted");
-						conference_member_say(member->conference, member, msg, 0);
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '8':
+					switch_mutex_lock(member->flag_mutex);
+					member->energy_level = member->conference->energy_level;
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '7':
+					switch_mutex_lock(member->flag_mutex);
+					member->energy_level -= 100;
+					if (member->energy_level < 0) {
+						member->energy_level = 0;
 					}
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '3':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_out_level++;
+					normalize_volume(member->volume_out_level);
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '2':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_out_level = 0;
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '1':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_out_level--;
+					normalize_volume(member->volume_out_level);
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '6':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_in_level++;
+					normalize_volume(member->volume_in_level);
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '5':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_in_level = 0;
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '4':
+					switch_mutex_lock(member->flag_mutex);
+					member->volume_in_level--;
+					normalize_volume(member->volume_in_level);
+					switch_mutex_unlock(member->flag_mutex);
+					snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
+					conference_member_say(member->conference, member, msg, 0);
+					break;
+				case '#':
+					switch_clear_flag_locked(member, MFLAG_RUNNING);
+					break;
+				default:
+					break;
 				}
-				break;
-			case '9':
-				switch_mutex_lock(member->flag_mutex);
-				member->energy_level += 100;
-				if (member->energy_level > 1200) {
-					member->energy_level = 1200;
-				}
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '8':
-				switch_mutex_lock(member->flag_mutex);
-				member->energy_level = member->conference->energy_level;
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '7':
-				switch_mutex_lock(member->flag_mutex);
-				member->energy_level -= 100;
-				if (member->energy_level < 0) {
-					member->energy_level = 0;
-				}
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '3':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_out_level++;
-				normalize_volume(member->volume_out_level);
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '2':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_out_level = 0;
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '1':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_out_level--;
-				normalize_volume(member->volume_out_level);
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '6':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_in_level++;
-				normalize_volume(member->volume_in_level);
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '5':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_in_level = 0;
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '4':
-				switch_mutex_lock(member->flag_mutex);
-				member->volume_in_level--;
-				normalize_volume(member->volume_in_level);
-				switch_mutex_unlock(member->flag_mutex);
-				snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
-				conference_member_say(member->conference, member, msg, 0);
-				break;
-			case '#':
-				switch_clear_flag_locked(member, MFLAG_RUNNING);
-				break;
-			default:
-				break;
 			}
 		}
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Jul 17 10:12:07 2006
@@ -1509,9 +1509,12 @@
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", from);
 			switch_event_add_header(event, SWITCH_STACK_BOTTOM, "subject", subject);
 			switch_event_add_body(event, msg);
+
 			if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
+				switch_event_add_header(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
 				switch_event_fire(&event);
 			}
+
 		}
 		break;
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Mon Jul 17 10:12:07 2006
@@ -1130,7 +1130,7 @@
 SWITCH_DECLARE(switch_status_t) switch_core_session_queue_event(switch_core_session_t *session, switch_event_t **event)
 	 
 {
-	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_status_t status = SWITCH_STATUS_FALSE;
 
 	assert(session != NULL);
 
@@ -1138,10 +1138,13 @@
 		switch_queue_create(&session->event_queue, SWITCH_EVENT_QUEUE_LEN, session->pool);
 	}
 
-	if ((status = (switch_status_t) switch_queue_push(session->event_queue, *event) == SWITCH_STATUS_SUCCESS)) {
-		*event = NULL;
-	}	
-	
+	if (session->event_queue) {
+		if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) {
+			*event = NULL;
+			status = SWITCH_STATUS_SUCCESS;
+		}
+	} 
+
 	return status;
 }
 



More information about the Freeswitch-svn mailing list