Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Eye-Tracking Classroom
/
gaze-server.cs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b72ef4e9
authored
Oct 14, 2019
by
Stefan Schreistetter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed memory leak.
parent
241680ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
TrackerBridge/DSP/GazeDecimator.cs
+7
-7
TrackerBridge/FakeTracker.cs
+9
-7
No files found.
TrackerBridge/DSP/GazeDecimator.cs
View file @
b72ef4e9
...
...
@@ -13,10 +13,10 @@ namespace TrackerBridge.DSP
private
GazeData
output
;
private
Single
outputFrequency
;
private
Timer
timer
;
private
readonly
Object
outputLock
=
new
Object
();
private
readonly
Object
valueCountLock
=
new
Object
();
private
Int64
valueCount
;
private
Task
timerTask
;
private
Int64
ValueCount
{
get
{
...
...
@@ -51,7 +51,7 @@ namespace TrackerBridge.DSP
public
GazeDecimator
(
GazeDataProcessor
dataProcessor
)
{
outputFrequency
=
dataProcessor
.
OutputFrequency
;
Task
timerTask
=
Task
.
Run
(()
=>
TriggerOutput
(
outputFrequency
)
);
SetupTimer
(
);
}
public
void
Input
(
GazeData
input
,
Object
sender
=
null
)
{
...
...
@@ -76,9 +76,11 @@ namespace TrackerBridge.DSP
ValueCount
=
0
;
}
private
void
TriggerOutput
(
Single
frequency
)
private
void
SetupTimer
(
)
{
Timer
timer
=
new
Timer
(
1000.0
/
frequency
);
//TODO: Implement Dispose
timer
?.
Stop
();
timer
?.
Dispose
();
timer
=
new
Timer
(
1000.0
/
outputFrequency
);
timer
.
Elapsed
+=
(
Object
sender
,
ElapsedEventArgs
e
)
=>
{
if
(
ValueCount
>
0
)
...
...
@@ -94,9 +96,7 @@ namespace TrackerBridge.DSP
public
void
Update
(
GazeDataProcessor
dataProcessor
)
{
outputFrequency
=
dataProcessor
.
OutputFrequency
;
//timerTask.Dispose(); //TODO: Implement proper cancellation
//TODO: Fix memory leak
timerTask
=
Task
.
Run
(()
=>
TriggerOutput
(
outputFrequency
));
SetupTimer
();
}
}
}
TrackerBridge/FakeTracker.cs
View file @
b72ef4e9
...
...
@@ -20,7 +20,7 @@ namespace TrackerBridge
}
private
readonly
GazeDataProcessor
gazeDataProcessor
;
private
Task
timerTask
;
private
System
.
Timers
.
Timer
timer
;
private
Single
trackerFrequency
;
public
Single
OutputFrequency
{
...
...
@@ -33,9 +33,8 @@ namespace TrackerBridge
return
trackerFrequency
;
}
set
{
//timerTask.Dispose(); //TODO: Proper cancellation
//TODO: Fix memory leak
timerTask
=
Task
.
Run
(()
=>
SimulateGazeDataHz
(
value
));
trackerFrequency
=
value
;
TimerSetup
();
}
}
...
...
@@ -47,12 +46,15 @@ namespace TrackerBridge
public
void
Connect
()
{
timerTask
=
Task
.
Run
(()
=>
SimulateGazeDataHz
(
trackerFrequency
)
);
TimerSetup
(
);
ConnectionEvent
?.
Invoke
(
this
);
}
private
void
SimulateGazeDataHz
(
Single
frequency
)
private
void
TimerSetup
()
{
System
.
Timers
.
Timer
timer
=
new
System
.
Timers
.
Timer
(
1000.0
/
frequency
);
//TODO: Implement Dispose
timer
?.
Stop
();
timer
?.
Dispose
();
timer
=
new
System
.
Timers
.
Timer
(
1000.0
/
trackerFrequency
);
timer
.
Elapsed
+=
(
Object
sender
,
ElapsedEventArgs
e
)
=>
{
Point
mousePosition
=
Control
.
MousePosition
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment