diff --git a/src/flexasio/FlexASIO/flexasio.cpp b/src/flexasio/FlexASIO/flexasio.cpp index e270ff6..9d5f84c 100644 --- a/src/flexasio/FlexASIO/flexasio.cpp +++ b/src/flexasio/FlexASIO/flexasio.cpp @@ -218,20 +218,18 @@ namespace flexasio { return result; } - void CopyFromPortAudioBuffers(const std::vector& bufferInfos, const long doubleBufferIndex, const void* const* portAudioBuffers, const size_t bufferSizeInBytes) { + void CopyFromPortAudioBuffers(const std::vector& bufferInfos, const long doubleBufferIndex, const std::byte* const* portAudioBuffers, const size_t bufferSizeInBytes) { for (const auto& bufferInfo : bufferInfos) { if (!bufferInfo.isInput) continue; - void* asioBuffer = bufferInfo.buffers[doubleBufferIndex]; - memcpy(asioBuffer, portAudioBuffers[bufferInfo.channelNum], bufferSizeInBytes); + memcpy(bufferInfo.buffers[doubleBufferIndex], portAudioBuffers[bufferInfo.channelNum], bufferSizeInBytes); } } - void CopyToPortAudioBuffers(const std::vector& bufferInfos, const long doubleBufferIndex, void* const* portAudioBuffers, const size_t bufferSizeInBytes) { + void CopyToPortAudioBuffers(const std::vector& bufferInfos, const long doubleBufferIndex, std::byte* const* portAudioBuffers, const size_t bufferSizeInBytes) { for (const auto& bufferInfo : bufferInfos) { if (bufferInfo.isInput) continue; - void* asioBuffer = bufferInfo.buffers[doubleBufferIndex]; - memcpy(portAudioBuffers[bufferInfo.channelNum], asioBuffer, bufferSizeInBytes); + memcpy(portAudioBuffers[bufferInfo.channelNum], bufferInfo.buffers[doubleBufferIndex], bufferSizeInBytes); } } @@ -733,7 +731,7 @@ namespace flexasio { << inputChannelCount << "/" << outputChannelCount << " (I/O) channels per buffer set, " << bufferSizeInFrames << " samples per channel, " << inputSampleSizeInBytes << "/" << outputSampleSizeInBytes << " (I/O) bytes per sample, memory range: " - << static_cast(buffers.data()) << "-" << static_cast(buffers.data() + buffers.size()); + << buffers.data() << "-" << buffers.data() + buffers.size(); } FlexASIO::PreparedState::Buffers::~Buffers() { @@ -769,14 +767,14 @@ namespace flexasio { auto& nextBuffersChannelIndex = asioBufferInfo.isInput ? nextBuffersInputChannelIndex : nextBuffersOutputChannelIndex; const auto bufferSizeInBytes = asioBufferInfo.isInput ? buffers.GetInputBufferSizeInBytes() : buffers.GetOutputBufferSizeInBytes(); - uint8_t* first_half = (buffers.*getBuffer)(0, nextBuffersChannelIndex); - uint8_t* second_half = (buffers.*getBuffer)(1, nextBuffersChannelIndex); + std::byte* first_half = (buffers.*getBuffer)(0, nextBuffersChannelIndex); + std::byte* second_half = (buffers.*getBuffer)(1, nextBuffersChannelIndex); ++nextBuffersChannelIndex; asioBufferInfo.buffers[0] = first_half; asioBufferInfo.buffers[1] = second_half; Log() << "ASIO buffer #" << channelIndex << " is " << (asioBufferInfo.isInput ? "input" : "output") << " channel " << asioBufferInfo.channelNum - << " - first half: " << static_cast(first_half) << "-" << static_cast(first_half + bufferSizeInBytes) - << " - second half: " << static_cast(second_half) << "-" << static_cast(second_half + bufferSizeInBytes); + << " - first half: " << first_half << "-" << first_half + bufferSizeInBytes + << " - second half: " << second_half << "-" << second_half + bufferSizeInBytes; bufferInfos.push_back(asioBufferInfo); } return bufferInfos; @@ -958,8 +956,8 @@ namespace flexasio { const auto inputSampleSizeInBytes = preparedState.buffers.inputSampleSizeInBytes; const auto outputSampleSizeInBytes = preparedState.buffers.outputSampleSizeInBytes; - const void* const* input_samples = static_cast(input); - void* const* output_samples = static_cast(output); + const std::byte* const* input_samples = static_cast (input); + std::byte* const* output_samples = static_cast(output); if (output_samples) { for (int output_channel_index = 0; output_channel_index < preparedState.flexASIO.GetOutputChannelCount(); ++output_channel_index) diff --git a/src/flexasio/FlexASIO/flexasio.h b/src/flexasio/FlexASIO/flexasio.h index 999d203..dac5d0b 100644 --- a/src/flexasio/FlexASIO/flexasio.h +++ b/src/flexasio/FlexASIO/flexasio.h @@ -105,8 +105,8 @@ namespace flexasio { { Buffers(size_t bufferSetCount, size_t inputChannelCount, size_t outputChannelCount, size_t bufferSizeInFrames, size_t inputSampleSizeInBytes, size_t outputSampleSizeInBytes); ~Buffers(); - uint8_t* GetInputBuffer(size_t bufferSetIndex, size_t channelIndex) { return buffers.data() + bufferSetIndex * GetBufferSetSizeInBytes() + channelIndex * GetInputBufferSizeInBytes(); } - uint8_t* GetOutputBuffer(size_t bufferSetIndex, size_t channelIndex) { return GetInputBuffer(bufferSetIndex, inputChannelCount) + channelIndex * GetOutputBufferSizeInBytes(); } + std::byte* GetInputBuffer(size_t bufferSetIndex, size_t channelIndex) { return buffers.data() + bufferSetIndex * GetBufferSetSizeInBytes() + channelIndex * GetInputBufferSizeInBytes(); } + std::byte* GetOutputBuffer(size_t bufferSetIndex, size_t channelIndex) { return GetInputBuffer(bufferSetIndex, inputChannelCount) + channelIndex * GetOutputBufferSizeInBytes(); } size_t GetBufferSetSizeInBytes() const { return buffers.size() / bufferSetCount; } size_t GetInputBufferSizeInBytes() const { if (buffers.empty()) return 0; return bufferSizeInFrames * inputSampleSizeInBytes; } size_t GetOutputBufferSizeInBytes() const { if (buffers.empty()) return 0; return bufferSizeInFrames * outputSampleSizeInBytes; } @@ -122,7 +122,7 @@ namespace flexasio { // [ input channel 0 buffer 0 ] [ input channel 1 buffer 0 ] ... [ input channel N buffer 0 ] [ output channel 0 buffer 0 ] [ output channel 1 buffer 0 ] .. [ output channel N buffer 0 ] // [ input channel 0 buffer 1 ] [ input channel 1 buffer 1 ] ... [ input channel N buffer 1 ] [ output channel 0 buffer 1 ] [ output channel 1 buffer 1 ] .. [ output channel N buffer 1 ] // The reason why this is a giant blob is to slightly improve performance by (theroretically) improving memory locality. - std::vector buffers; + std::vector buffers; }; class RunningState {