Revision
14833
Author
anthm
Date
2009-09-12 12:36:34 -0500 (Sat, 12 Sep 2009)

Log Message

update to new module api

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c (14832 => 14833)


--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	2009-09-11 17:34:12 UTC (rev 14832)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	2009-09-12 17:36:34 UTC (rev 14833)
@@ -44,6 +44,8 @@
 SWITCH_MODULE_DEFINITION(mod_alsa, mod_alsa_load, mod_alsa_shutdown, NULL);
 
 static switch_memory_pool_t *module_pool = NULL;
+switch_endpoint_interface_t *alsa_endpoint_interface;
+
 //static int running = 1;
 
 #define SAMPLE_TYPE  paInt16
@@ -159,6 +161,7 @@
 
 
 
+
 /* 
    State methods they get called when the state changes to the specific state 
    returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next
@@ -720,13 +723,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_api_interface_t channel_api_interface = {
-	/*.interface_name */ "alsa",
-	/*.desc */ "Alsa",
-	/*.function */ pa_cmd,
-	/*.syntax */ "<command> [<args>]",
-	/*.next */
-};
 
 static switch_state_handler_table_t channel_event_handlers = {
 	/*.on_init */ channel_on_init,
@@ -760,15 +756,6 @@
 	/*.next */ NULL
 };
 
-static switch_loadable_module_interface_t channel_module_interface = {
-	/*.module_name */ modname,
-	/*.endpoint_interface */ &channel_endpoint_interface,
-	/*.timer_interface */ NULL,
-	/*.dialplan_interface */ NULL,
-	/*.codec_interface */ NULL,
-	/*.application_interface */ NULL,
-	/*.api_interface */ &channel_api_interface
-};
 
 /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
    that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
@@ -828,7 +815,18 @@
 {
 
 	switch_status_t status;
+	switch_api_interface_t *api_interface;
 
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+	alsa_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
+	alsa_endpoint_interface->interface_name = "alsa";
+	alsa_endpoint_interface->io_routines = &channel_io_routines;
+	alsa_endpoint_interface->state_handler = &channel_event_handlers;
+
+	SWITCH_ADD_API(api_interface, "alsa", "Alsa", pa_cmd, "<command> [<args>]");
+	
+
 	if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
 		return SWITCH_STATUS_TERM;
@@ -861,9 +859,6 @@
 	globals.cng_frame.datalen = sizeof(globals.cngbuf);
 	switch_set_flag((&globals.cng_frame), SFF_CNG);
 
-	/* connect my internal structure to the blank pointer passed to me */
-	*module_interface = &channel_module_interface;
-
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }