From a3719d97fd7c9268ef0575de6e6429759dde427c Mon Sep 17 00:00:00 2001
From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es>
Date: Fri, 15 Apr 2016 00:29:51 +0200
Subject: [PATCH] Restore buffers on kwik file close

---
 Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp b/Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp
index 69ddadc52..4646d7d41 100644
--- a/Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp
+++ b/Source/Plugins/KWIKFormat/RecordEngine/HDF5Recording.cpp
@@ -186,11 +186,14 @@ void HDF5Recording::closeFiles()
 	recordedChanToKWDChan.clear();
 	channelTimestampArray.clear();
 	channelLeftOverSamples.clear();
+	scaledBuffer.malloc(MAX_BUFFER_SIZE);
+	intBuffer.malloc(MAX_BUFFER_SIZE);
+	bufferSize = MAX_BUFFER_SIZE;
 }
 
 void HDF5Recording::writeData(int writeChannel, int realChannel, const float* buffer, int size)
 {
-	if (size > bufferSize) //Shouldn't happen, and if it happens it'll be slow, but better this than crashing. Will be reset on reset.
+	if (size > bufferSize) //Shouldn't happen, and if it happens it'll be slow, but better this than crashing. Will be reset on flie close and reset.
 	{
 		std::cerr << "Write buffer overrun, resizing to" << size << std::endl;
 		bufferSize = size;
-- 
GitLab