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
+
/*
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
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,
/*.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!
{
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");
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;
}