update to new module api

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14833 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-09-12 17:36:34 +00:00
parent dce827321d
commit 66d290c1c4

View File

@ -44,6 +44,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_alsa_shutdown);
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 @@ SWITCH_STANDARD_API(pa_cmd);
/*
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 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
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 @@ static switch_endpoint_interface_t channel_endpoint_interface = {
/*.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,6 +815,17 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_alsa_load)
{
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");
@ -861,9 +859,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_alsa_load)
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;
}