| 11695 | //static inline uint64_t bswap_64(uint64_t x) { return (((unsigned long long)bswap_32(x&0xffffffffull))<<32) | (bswap_32(x>>32)); } |
| 11696 | |
| 11697 | void RtApi ::byteSwapBuffer(char * buffer, unsigned int samples, RtAudioFormat format) |
| 11698 | { |
| 11699 | char val; |
| 11700 | char * ptr; |
| 11701 | |
| 11702 | ptr = buffer; |
| 11703 | if (format == RTAUDIO_SINT16) |
| 11704 | { |
| 11705 | for (unsigned int i = 0; i < samples; i++) |
| 11706 | { |
| 11707 | // Swap 1st and 2nd bytes. |
| 11708 | val = *(ptr); |
| 11709 | *(ptr) = *(ptr + 1); |
| 11710 | *(ptr + 1) = val; |
| 11711 | |
| 11712 | // Increment 2 bytes. |
| 11713 | ptr += 2; |
| 11714 | } |
| 11715 | } |
| 11716 | else if (format == RTAUDIO_SINT32 || format == RTAUDIO_FLOAT32) |
| 11717 | { |
| 11718 | for (unsigned int i = 0; i < samples; i++) |
| 11719 | { |
| 11720 | // Swap 1st and 4th bytes. |
| 11721 | val = *(ptr); |
| 11722 | *(ptr) = *(ptr + 3); |
| 11723 | *(ptr + 3) = val; |
| 11724 | |
| 11725 | // Swap 2nd and 3rd bytes. |
| 11726 | ptr += 1; |
| 11727 | val = *(ptr); |
| 11728 | *(ptr) = *(ptr + 1); |
| 11729 | *(ptr + 1) = val; |
| 11730 | |
| 11731 | // Increment 3 more bytes. |
| 11732 | ptr += 3; |
| 11733 | } |
| 11734 | } |
| 11735 | else if (format == RTAUDIO_SINT24) |
| 11736 | { |
| 11737 | for (unsigned int i = 0; i < samples; i++) |
| 11738 | { |
| 11739 | // Swap 1st and 3rd bytes. |
| 11740 | val = *(ptr); |
| 11741 | *(ptr) = *(ptr + 2); |
| 11742 | *(ptr + 2) = val; |
| 11743 | |
| 11744 | // Increment 2 more bytes. |
| 11745 | ptr += 2; |
| 11746 | } |
| 11747 | } |
| 11748 | else if (format == RTAUDIO_FLOAT64) |
| 11749 | { |
| 11750 | for (unsigned int i = 0; i < samples; i++) |
| 11751 | { |
| 11752 | // Swap 1st and 8th bytes |
| 11753 | val = *(ptr); |
| 11754 | *(ptr) = *(ptr + 7); |
nothing calls this directly
no outgoing calls
no test coverage detected