From aae8860d0e7b2bf68a1c20c6f30999fff531f03c Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 17 Jan 2023 13:12:14 +0100 Subject: Minor, optimized away memcpy() when running audio capture --- Whisper/MF/AudioBuffer.h | 6 ++++++ Whisper/Whisper/ContextImpl.capture.cpp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Whisper/MF/AudioBuffer.h b/Whisper/MF/AudioBuffer.h index 87319dd..93a6ace 100644 --- a/Whisper/MF/AudioBuffer.h +++ b/Whisper/MF/AudioBuffer.h @@ -30,6 +30,12 @@ namespace Whisper stereo.clear(); } + void swap( AudioBuffer& that ) + { + mono.swap( that.mono ); + stereo.swap( that.stereo ); + } + void resize( size_t len ) { assert( len <= mono.size() ); diff --git a/Whisper/Whisper/ContextImpl.capture.cpp b/Whisper/Whisper/ContextImpl.capture.cpp index c0d3d28..617c1f3 100644 --- a/Whisper/Whisper/ContextImpl.capture.cpp +++ b/Whisper/Whisper/ContextImpl.capture.cpp @@ -138,8 +138,7 @@ namespace workStatus = S_FALSE; buffer.currentOffset = pcmStartTime; - buffer.pcm.mono = pcm.mono; - buffer.pcm.stereo = pcm.stereo; + pcm.swap( buffer.pcm ); SubmitThreadpoolWork( work ); pcmStartTime = nextSampleTime; pcm.clear(); -- cgit v1.2.3