Glossary -------- Cluster minimum PCM streaming object. Cluster of samples eg a a 2 channel stream would have 2 samples in a cluster unit a processing unit which takes an stream, processes it and outputs the resulting stream output terminal any unit that will allow adding of an input terminal. input terminal source of the audio stream. Common ------- _kernel_error* create(audio_t**); void destroy(audio_t*); Output terminal --------------- _kernel_oserror *addInput(audio_t *self, int format, audio_t *input); _kernel_oserror *removeInput(audio_t *self, audio_t *input); _kernel_oserror *initialise(audio_t* self, audio_t* input); Notes if you add a chain OT -> UNIT1 -> UNIT2 to IT initialise is only called on IT with UNIT2 as the 2nd parameter. The 2nd parameter enables a chain added to a mixer to just initialise the added chain as a mixer could have more than one input. NOT SURE ABOUT THIS Input terminal -------------- _kernel_oserror *bufferFill(audio_t*, void* buffer, size_t cluster_count); _kernel_oserror *setBuffer(audio_t*, size_t max_cluster_count, size_t *minimum_buffer_size); unit ---- Output terminal interface Input terminal interface IT -> OT PCM input terminal -> PCM output terminal 1) create output terminal (OT) 2) create input terminal.(IT) addInput(OT, PCM, IT) chain complete - OT dormant 3) initialise(OT,IT) 4) OT sends setBuffer(IT, max_cluster_count, &minimum_buffer_size) 5) OT allocates buffer - OT active. 6) OT sends bufferFill(IT, buffer, cluster_size) IT -> CON -> OT mp3 input terminal -> mp3 to PCM converter -> PCM output terminal 1) create OT 2) create CON addInput(OT, PCM, CON) 3) create IT addInput(CON, MP3, IT) chain complete - OT dormant 4) initialise(OT,CON) 5) OT sends setBuffer(CON, max_cluster_count, &minimum_buffer_size) 6) CON calculates the max buffer size for its output pcm and if it is greater than *minimum_buffer_size sets *minimum_buffer_size 7) CON sends setBuffer(IT, 0, &new_minimim_buffer_size) cluster count ignored by non PCM formats 8) IT sets new_minimim_buffer_size if its needs are larger and returns 9) CON allocates a new_minimim_buffer_size buffer for its MP3 input and returns its minimum_buffer_size value 10) OT allocates a minimum_buffer_size buffer - OT active 11) OT sends bufferFill(CON, buf, cluster_count) 12) CON sends bufferFill(IT, mp3_buf, size) 13) IT fills mp3Buf and returns 14) CON converts the input mp3 buffer to the output PCM buffer and returns optionaly looping back to 12 if more data is needed