summaryrefslogtreecommitdiffstats
path: root/Whisper
diff options
context:
space:
mode:
authorKonstantin <const@const.me>2023-01-17 13:12:14 +0100
committerKonstantin <const@const.me>2023-01-17 13:12:14 +0100
commitaae8860d0e7b2bf68a1c20c6f30999fff531f03c (patch)
treef88de11d79313bd4e59958ec66b5e6d26b2e578e /Whisper
parent5f11a8275d70dfd27b5998ab91b4ffb7b15ca418 (diff)
Minor, optimized away memcpy() when running audio capture
Diffstat (limited to 'Whisper')
-rw-r--r--Whisper/MF/AudioBuffer.h6
-rw-r--r--Whisper/Whisper/ContextImpl.capture.cpp3
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();