Skip to content

Commit 92489a6

Browse files
committed
Add warning to Kwik File Source when using KWIK record format
1 parent c6fd5ba commit 92489a6

4 files changed

Lines changed: 41 additions & 10 deletions

File tree

Source/Plugins/KWIKFormat/FileSource/KwikFileSource.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
*/
2323
#include <H5Cpp.h>
2424
#include "KwikFileSource.h"
25-
25+
#include <CoreServicesHeader.h>
2626

2727

2828
using namespace H5;
2929

3030
#define PROCESS_ERROR std::cerr << "KwikFilesource exception: " << error.getCDetailMsg() << std::endl
3131

32-
KWIKFileSource::KWIKFileSource() : samplePos(0)
32+
KWIKFileSource::KWIKFileSource() : samplePos(0), skipRecordEngineCheck(false)
3333
{
3434
}
3535

@@ -247,4 +247,32 @@ void KWIKFileSource::processChannelData(int16* inBuffer, float* outBuffer, int c
247247
*(outBuffer+i) = *(inBuffer+(n*i)+channel) * bitVolts;
248248
}
249249

250+
}
251+
252+
bool KWIKFileSource::isReady()
253+
{
254+
//HDF5 is by default not thread-safe, so we must warn the user.
255+
if ((!skipRecordEngineCheck) && (CoreServices::getSelectedRecordEngineId() == "KWIK"))
256+
{
257+
int res = AlertWindow::showYesNoCancelBox(AlertWindow::WarningIcon, "Record format conflict",
258+
"Both the selected input file for the File Reader and the output file format for recording use the HDF5 library.\n"
259+
"This library is, by default, not thread safe, so running both at the same time might cause unexpected crashes (chances increase with signal complexity and number of recorded channels).\n\n"
260+
"If you have a custom-built hdf5 library with the thread safe features turned on, you can safely continue, but performance will be reduced.\n"
261+
"More information on:\n"
262+
"https://www.hdfgroup.org/HDF5/doc/TechNotes/ThreadSafeLibrary.html\n"
263+
"https://www.hdfgroup.org/hdf5-quest.html\n\n"
264+
"Do you want to continue acquisition?", "Yes", "Yes and don't ask again", "No");
265+
switch (res)
266+
{
267+
case 2:
268+
skipRecordEngineCheck = true;
269+
case 1:
270+
return true;
271+
break;
272+
default:
273+
return false;
274+
}
275+
}
276+
else
277+
return true;
250278
}

Source/Plugins/KWIKFormat/FileSource/KwikFileSource.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,23 @@ class KWIKFileSource : public FileSource
4343
KWIKFileSource();
4444
~KWIKFileSource();
4545

46-
int readData(int16* buffer, int nSamples);
46+
int readData(int16* buffer, int nSamples) override;
4747

48-
void seekTo(int64 sample);
48+
void seekTo(int64 sample) override;
4949

50-
void processChannelData(int16* inBuffer, float* outBuffer, int channel, int64 numSamples);
50+
void processChannelData(int16* inBuffer, float* outBuffer, int channel, int64 numSamples) override;
51+
52+
bool isReady() override;
5153

5254
private:
5355
ScopedPointer<H5::H5File> sourceFile;
5456
ScopedPointer<H5::DataSet> dataSet;
55-
bool Open(File file);
56-
void fillRecordInfo();
57-
void updateActiveRecord();
57+
bool Open(File file) override;
58+
void fillRecordInfo() override;
59+
void updateActiveRecord() override;
5860
int64 samplePos;
5961
Array<int> availableDataSets;
62+
bool skipRecordEngineCheck;
6063
};
6164

6265

Source/Processors/FileReader/FileSource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool FileSource::OpenFile (File file)
141141
return fileOpened;
142142
}
143143

144-
bool FileSource::isReady() const
144+
bool FileSource::isReady()
145145
{
146146
return true;
147147
}

Source/Processors/FileReader/FileSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class PLUGIN_API FileSource
6767
virtual void processChannelData (int16* inBuffer, float* outBuffer, int channel, int64 numSamples) = 0;
6868
virtual void seekTo (int64 sample) = 0;
6969

70-
virtual bool isReady() const;
70+
virtual bool isReady();
7171

7272
protected:
7373
struct RecordInfo

0 commit comments

Comments
 (0)