#include "oscmergemodule.h" #include //#include //#include //#include #include "dllutils.h" #include "oscmergemodule.xpm" static log2T s_log_function = 0; static void logger(int level, const char* msg) { if (s_log_function) s_log_function(level, "mod_oscmergemodule", msg); } const char* getSpec(void) { return "mod_spec { name=[mod_oscmergemodule] number_of_inputs=[2] number_of_outputs=[1] deterministic=[true] }"; } const char* getInputSpec(int index) { switch(index) { case 0: return "input_spec { type=typ_OscType id=1 const=true strong_dependency=true } "; break; case 1: return "input_spec { type=typ_OscType id=2 const=true strong_dependency=true } "; break; } return 0; } const char* getOutputSpec(int index) { switch(index) { case 0: return "output_spec { type=typ_OscType id=r } "; break; } return 0; } static struct _MyInstance* s_inst = 0; static int s_ref_count = 0; void* newInstance() { Instance* inst = (Instance*) malloc(sizeof(Instance)); if (inst == 0) { logger(0, "Could not allocate memory for instance struct!\n"); return 0; } s_ref_count += 1; if (s_ref_count == 1) { s_inst = construct(); if (s_inst == 0) { free(inst); s_ref_count = 0; return 0; } } inst->my = s_inst; return inst; } void deleteInstance(void* instance) { Instance* inst = (Instance*) instance; s_ref_count -= 1; if (s_ref_count == 0) destruct(s_inst); free(inst); } int setInput(void* instance,int index,void* typePointer) { InstancePtr inst = (InstancePtr) instance; switch(index) { case 0: inst->in_1 = (OscType *) typePointer; break; case 1: inst->in_2 = (OscType *) typePointer; break; } //switch(index) return 1; } int setOutput(void* instance,int index, void* typePointer) { InstancePtr inst = (InstancePtr) instance; switch(index) { case 0: inst->out_r = (OscType* ) typePointer; break; } //switch(index) return 0; } int getInfo(char* buf,int bufLen) { static const char* INFO = "info { name=[Osc Merger] group=[Osc] inputs=[2 OSC-Stream 1 OSC-Stream 2 ] outputs=[1 OSC-Stream ] type=xpm } "; char* tmpBuf; int reqLen = 1 + strlen(INFO) + getSizeOfXPM(oscmergemodule_xpm); if (buf != 0 && reqLen <= bufLen) { char* offset; int i; int lines = getNumberOfStringsXPM(oscmergemodule_xpm); tmpBuf = (char*) malloc(reqLen); if (tmpBuf == 0) { printf("Could not allocate memory in getInfo\n"); return 0; } memcpy(tmpBuf,INFO,strlen(INFO)+1); offset = tmpBuf + strlen(INFO) + 1; for (i = 0; i < lines; ++i) { char* source = oscmergemodule_xpm[i]; memcpy(offset,source,strlen(source)+1); offset += strlen(source) + 1; } memcpy(buf,tmpBuf,reqLen); free(tmpBuf); } return reqLen; } int initSO(log2T log_function) { s_log_function = log_function; return init(logger); }