Revision
16354
Author
brian
Date
2010-01-17 22:32:15 -0600 (Sun, 17 Jan 2010)

Log Message

MODENDP-282

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (16353 => 16354)


--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	2010-01-18 04:30:48 UTC (rev 16353)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	2010-01-18 04:32:15 UTC (rev 16354)
@@ -40,6 +40,7 @@
 
 #define MY_EVENT_RINGING "portaudio::ringing"
 #define MY_EVENT_MAKE_CALL "portaudio::makecall"
+#define MY_EVENT_ERROR_AUDIO_DEV "portaudio::audio_dev_error"
 #define SWITCH_PA_CALL_ID_VARIABLE "pa_call_id"
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_portaudio_load);
@@ -827,7 +828,17 @@
 		return SWITCH_STATUS_GENERR;
 	}
 
+	if (switch_event_reserve_subclass(MY_EVENT_MAKE_CALL) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
+		return SWITCH_STATUS_GENERR;
+	}
 
+	if (switch_event_reserve_subclass(MY_EVENT_ERROR_AUDIO_DEV) != SWITCH_STATUS_SUCCESS) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
+		return SWITCH_STATUS_GENERR;
+	}
+
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	portaudio_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
@@ -1002,6 +1013,8 @@
 	switch_core_hash_destroy(&globals.call_hash);
 
 	switch_event_free_subclass(MY_EVENT_RINGING);
+	switch_event_free_subclass(MY_EVENT_MAKE_CALL);
+	switch_event_free_subclass(MY_EVENT_ERROR_AUDIO_DEV);
 	
 	switch_safe_free(globals.dialplan);
 	switch_safe_free(globals.context);
@@ -1299,6 +1312,7 @@
 	PaError err;
 	int sample_rate = globals.sample_rate;
 	int codec_ms = globals.codec_ms;
+	switch_event_t *event;
 
 	switch_mutex_lock(globals.device_lock);
 	while (globals.deactivate_timer > switch_epoch_time_now(NULL)) {
@@ -1422,6 +1436,10 @@
 		switch_core_timer_destroy(&globals.read_timer);
 		switch_core_timer_destroy(&globals.write_timer);
 		switch_core_timer_destroy(&globals.hold_timer);
+		if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_ERROR_AUDIO_DEV) == SWITCH_STATUS_SUCCESS) {
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Reason", Pa_GetErrorText(err));
+			switch_event_fire(&event);
+		}
 		return SWITCH_STATUS_FALSE;
 	}