I have this function here and I was wondering if anybody has any ideas on how to better it? I really need every bit of speed here and I know making it smaller will likely help that? Anybody got any ideas. BTW where I have comments is where I'll call some sample conversion function. Each case MUST have a different function call.
Code:
void processData(int index, int format, void *handler) {
#ifdef LITTLE_ENDIAN
switch (format) {
case S_INT_8_LSB_1:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_8_MSB_1:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_8_NER_8:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_16_LSB:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_16_MSB:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_24_LSB:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_24_MSB:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_LSB_16:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_MSB_16:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_LSB_18:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_MSB_18:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_LSB_20:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_MSB_20:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_LSB_24:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_MSB_24:
Int32* data = new Int32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
DataProcessor<Int32>* handler = (DataProcessor<Int32>*)handler;
handler->process(data, AudioStream::input->bufferSize);
break;
case S_INT_32_LSB:
Int64* data = new Int64[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case S_INT_32_MSB:
Int64* data = new Int64[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
DataProcessor<Int64>* handler = (DataProcessor<Int64>*)handler;
handler->process(data, AudioStream::input->bufferSize);
break;
case FLOAT_32_LSB:
Float32 *data = new Float32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case FLOAT_32_MSB:
Float32 *data; new Float32[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
DataProcessor<Float32>* handler = (DataProcessor<Float32>*)handler;
handler->process(data, AudioStream::input->bufferSize);
break;
case FLOAT_64_LSB:
Float64 *data = new Float64[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
case FLOAT_64_MSB:
Float64 *data = new Float64[AudioStream::input->bufferSize];
// Convert and create convert back function pointer
DataProcessor<Float64>* handler = (DataProcessor<Float64>*)handler;
handler->process(data, AudioStream::input->bufferSize);
break;
}
// Call function pointer
#else
#error endianness not supported
#endif
}