Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
Throttle calls to EdsOpenSession
Browse files Browse the repository at this point in the history
Together with 09acf9b this fixes #8
  • Loading branch information
bangnoise committed Aug 15, 2017
1 parent 09acf9b commit 1f33caa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Camera Live/SyPCanonDSLR.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@
SyPCanonEVFImageBuffer *_nextImage;
SyPImageBuffer *_pendingImage;
NSError *_pendingError;
NSTimeInterval _lastSession;
}
@end
7 changes: 7 additions & 0 deletions Camera Live/SyPCanonDSLR.m
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,14 @@ - (NSError *)startSessionOnQueue
if (OSAtomicCompareAndSwapPtrBarrier(NULL, self, (void **)&mSession))
{
_hasSession = YES;
// Throttle sessions or the EdsOpenSession call never returns
NSTimeInterval since = [NSDate timeIntervalSinceReferenceDate] - _lastSession;
if (since < 0.5)
{
usleep((0.5 - since) * USEC_PER_SEC);
}
EdsError result = EdsOpenSession(_camera);
_lastSession = [NSDate timeIntervalSinceReferenceDate];
error = [SyPCanonDSLR errorForEDSError:result];
}
else
Expand Down

0 comments on commit 1f33caa

Please sign in to comment.