瀏覽代碼

Merge pull request #123 from FrankBoesing/patch-1

copy_to_buffers optimize..
teensy4-core
Paul Stoffregen 8 年之前
父節點
當前提交
0d394a6e76
共有 1 個檔案被更改,包括 17 行新增3 行删除
  1. +17
    -3
      teensy3/usb_audio.cpp

+ 17
- 3
teensy3/usb_audio.cpp 查看文件

@@ -72,12 +72,26 @@ void AudioInputUSB::begin(void)

static void copy_to_buffers(const uint32_t *src, int16_t *left, int16_t *right, unsigned int len)
{
// TODO: optimize...
while (len > 0) {
uint32_t *target = (uint32_t*) src + len;
while ((src < target) && (((uintptr_t) left & 0x02) != 0)) {
uint32_t n = *src++;
*left++ = n & 0xFFFF;
*right++ = n >> 16;
}

while ((src < target - 2)) {
uint32_t n = *src++;
uint32_t n1 = *src++;
*(uint32_t *)left = n1 & 0xFFFF | ((n & 0xFFFF) << 16);
left+=2;
*(uint32_t *)right = (n1 >> 16) | ((n & 0xFFFF0000)) ;
right+=2;
}

while ((src < target)) {
uint32_t n = *src++;
*left++ = n & 0xFFFF;
*right++ = n >> 16;
len--;
}
}


Loading…
取消
儲存