The Trunk: EToys-eem.404.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: EToys-eem.404.mcz

commits-2
Eliot Miranda uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-eem.404.mcz

==================== Summary ====================

Name: EToys-eem.404
Author: eem
Time: 7 October 2020, 7:59:19.175862 pm
UUID: 92684a08-f39d-444c-b97e-8f45b7592cd1
Ancestors: EToys-eem.403

CameraInterface: on Windows the frame extent may not be known until the first frame is delivered, so defer initialization until after the semaphore has been signalled in interruptDrivenVideoTest:.

=============== Diff against EToys-eem.403 ===============

Item was changed:
  ----- Method: CameraInterface class>>interruptDrivenVideoTest: (in category 'test') -----
  interruptDrivenVideoTest: camNum
  "A quick test of video input. Displays video on the screen until the mouse is pressed.
  Answer nil if the interrupt-driven interface is unavailable."
  "self interruptDrivenVideoTest: 1"
+ "self interruptDrivenVideoTest: 2"
- "[self interruptDrivenVideoTest: 2"
  "[self interruptDrivenVideoTest: 2] fork.
   self interruptDrivenVideoTest: 1"
 
  | semaphore height |
  height := 16.
  1 to: camNum - 1 do:
  [:camIndex| "N.B. the of an unopened camera is 0@0"
  height := height + (CameraInterface frameExtent: camIndex) y + 16].
  (CameraInterface cameraIsOpen: camNum) ifFalse:
  [(CameraInterface openCamera: camNum width: 320 height: 240) ifNil:
  [self inform: 'no camera'.
  ^nil]].
  semaphore := Semaphore new.
  [CameraInterface camera: camNum setSemaphore: (Smalltalk registerExternalObject: semaphore)]
  on: Error
  do: [:err|
  Smalltalk unregisterExternalObject: semaphore.
  self inform: 'interrupt-driven camera interface unavailable: ', err messageText.
  ^nil].
  [| f n startTime frameCount msecs fps |
- (self frameExtent: camNum) x = 0 ifTrue: [self inform: 'no camera'. ^nil].
- f := Form extent: (CameraInterface frameExtent: camNum) depth: 32.
- frameCount := 0.
- startTime := nil.
  [semaphore wait.
+ "N.B. the frame extet may not be known until the delivery of the first frame.
+  Si we have to delay initialization."
+  startTime ifNil:
+ [(self frameExtent: camNum) x = 0 ifTrue: [self inform: 'no camera'. ^nil].
+ f := Form extent: (CameraInterface frameExtent: camNum) depth: 32.
+ frameCount := 0.
+ startTime := Time millisecondClockValue].
   Sensor anyButtonPressed] whileFalse:
  [n := CameraInterface getFrameForCamera: camNum into: f bits.
  n > 0 ifTrue:
+ [frameCount := frameCount + 1.
+ f displayAt: 16 @ height]].
- [startTime ifNil: [startTime := Time millisecondClockValue].
- frameCount := frameCount + 1.
- f displayAt: 16 @ height]].
  msecs := Time millisecondClockValue - startTime.
  fps := (frameCount * 1000) // msecs.
  ^frameCount printString, ' frames at ', fps printString, ' frames/sec']
  ensure:
  [CameraInterface closeCamera: camNum.
  Smalltalk unregisterExternalObject: semaphore.
  Sensor waitNoButton]!