-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImportSessionThread.cpp
More file actions
36 lines (32 loc) · 905 Bytes
/
ImportSessionThread.cpp
File metadata and controls
36 lines (32 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "ImportSessionThread.h"
#include "SessionEvent.h"
using namespace std;
ImportSessionThread::ImportSessionThread(wxString filepath, std::shared_ptr<sigrok::Session> session, std::shared_ptr<sigrok::Input> input):
wxThread(wxTHREAD_DETACHED),
offsset_(0),
file_(filepath, "rb"),
session_(session),
input_(input)
{
uint8_t buf;
input_->send(&buf, 0);
session->add_device(input->device());
if (file_.IsOpened())
offsset_ = file_.Length();
}
wxThread::ExitCode ImportSessionThread::Entry()
{
if (file_.IsOpened())
{
while(offsset_ && !TestDestroy())
{
uint8_t buf[512*1024];
size_t len = file_.Read(buf, 512*1024);
input_->send(buf, len);
offsset_ -= len;
}
input_->end();
return (wxThread::ExitCode)0; // success
}
return (wxThread::ExitCode)-1;
}