As described earlier, your Audio HW DLL must provide an entry point called ctrl_init(). The Organization of a Driver chapter describes the initialization that this function must do no matter what features your DLL supports.
If you're writing a custom audio mixer, the next task to perform (after ctrl_init() function has done the common part of the initialization) is to allocate and initialize a new ado_mixer_t structure.
Do this by calling ado_mixer_create(). All the information pertaining to this mixer is attached to this structure, so you need to store a copy of the returned pointer somewhere (usually in your context structure), so that you can access it later. However, ado_mixer_t is an opaque data type; your Audio HW DLL doesn't need to know what's in it.
Here's an example of initializing your Audio HW DLL if you're writing your own audio mixer:
int example_mixer (ado_card_t * card, HW_CONTEXT_T * example) { int32_t status; if ( (status = ado_mixer_create (card, "Example", &example->mixer, example)) != EOK ) return (status); return (0); } ado_ctrl_dll_init_t ctrl_init; int ctrl_init( HW_CONTEXT_T ** hw_context, ado_card_t * card, char *args ) { example_t *example; if ((example = (example_t *) ado_calloc (1, sizeof (example_t))) == NULL) { ado_error ("Unable to allocate memory (%s)\n", strerror (errno)); return -1; } *hw_context = example; /* Verify that the hardware is available here. */ if (example_mixer(card, *hw_context) != 0) return -1; else return 0; }
If you need to allocate memory for your mixer, you should create a cleanup function for io-audio to call when your mixer is destroyed. For more information, see ado_mixer_set_destroy_func().
You can also create a function to be called when the mixer's hardware is reset, but this usually isn't necessary. For more information, see ado_mixer_set_reset_func().