You might want to do the in-place conversion to save some memory. Depends on how little memory the device in question has. Therefore, you can use something like this instead of the Paul R approach:
void interleave(uint16_t buf[], const int len) { for (int i = len / 2 - 1, j = len - 1; i > 0; --i) { buf[j--] = buf[i]; buf[j--] = buf[i]; } }
When receiving audio data from a mono device, you allocate a buffer that is twice as large as necessary and transfers it to the mono device. This will fill half the mono audio buffer. Then you pass this buffer to the specified function, which converts it to stereo. And finally, you pass the buffer to stereo. You save extra allocation and therefore use 33% less memory for conversion.
source share