@@ -112,7 +112,7 @@ public class Capture extends PImage implements PConstants {
112112 protected Method sinkCopyMethod ;
113113 protected Method sinkSetMethod ;
114114 protected Method sinkDisposeMethod ;
115- protected Method sinkGetMethod ;
115+ protected Method sinkGetMethod ;
116116 protected String copyMask ;
117117 protected Buffer natBuffer = null ;
118118 protected BufferDataAppSink natSink = null ;
@@ -239,7 +239,7 @@ public Capture(PApplet parent, int requestWidth, int requestHeight,
239239
240240 /**
241241 * Disposes all the native resources associated to this capture device.
242- *
242+ *
243243 * NOTE: This is not official API and may/will be removed at any time.
244244 */
245245 public void dispose () {
@@ -271,10 +271,10 @@ public void dispose() {
271271
272272 pipeline .dispose ();
273273 pipeline = null ;
274-
274+
275275 parent .g .removeCache (this );
276276 parent .unregisterMethod ("dispose" , this );
277- parent .unregisterMethod ("post" , this );
277+ parent .unregisterMethod ("post" , this );
278278 }
279279 }
280280
@@ -308,11 +308,11 @@ public boolean available() {
308308
309309 /**
310310 * ( begin auto-generated from Capture_start.xml )
311- *
311+ *
312312 * Starts capturing frames from the selected device.
313- *
313+ *
314314 * ( end auto-generated )
315- *
315+ *
316316 * @webref capture
317317 * @brief Starts capturing frames from the selected device
318318 */
@@ -425,7 +425,7 @@ public synchronized void read() {
425425 newFrame = true ;
426426 }
427427
428-
428+
429429 public synchronized void loadPixels () {
430430 super .loadPixels ();
431431 if (useBufferSink ) {
@@ -441,33 +441,33 @@ public synchronized void loadPixels() {
441441 try {
442442 // sinkGetMethod will copy the latest buffer to the pixels array,
443443 // and the pixels will be copied to the texture when the OpenGL
444- // renderer needs to draw it.
445- sinkGetMethod .invoke (bufferSink , new Object [] { pixels });
444+ // renderer needs to draw it.
445+ sinkGetMethod .invoke (bufferSink , new Object [] { pixels });
446446 } catch (Exception e ) {
447447 e .printStackTrace ();
448- }
449- }
448+ }
449+ }
450450
451- outdatedPixels = false ;
451+ outdatedPixels = false ;
452452 }
453453 }
454-
455-
454+
455+
456456 public int get (int x , int y ) {
457457 if (outdatedPixels ) loadPixels ();
458458 return super .get (x , y );
459459 }
460-
461-
460+
461+
462462 protected void getImpl (int sourceX , int sourceY ,
463463 int sourceWidth , int sourceHeight ,
464464 PImage target , int targetX , int targetY ) {
465465 if (outdatedPixels ) loadPixels ();
466466 super .getImpl (sourceX , sourceY , sourceWidth , sourceHeight ,
467467 target , targetX , targetY );
468468 }
469-
470-
469+
470+
471471 ////////////////////////////////////////////////////////////
472472
473473 // List methods.
@@ -1019,40 +1019,37 @@ protected synchronized void invokeEvent(int w, int h, IntBuffer buffer) {
10191019 }
10201020 fireCaptureEvent ();
10211021 }
1022-
1022+
10231023
10241024 protected synchronized void invokeEvent (int w , int h , Buffer buffer ) {
10251025 available = true ;
10261026 bufWidth = w ;
10271027 bufHeight = h ;
10281028 if (natBuffer != null ) {
1029- // To handle the situation where read() is not called in the sketch, so
1030- // that the native buffers are not being sent to the sinke, and therefore, not disposed
1031- // by it.
1032- natBuffer .dispose ();
1033- }
1029+ // To handle the situation where read() is not called in the sketch,
1030+ // so that the native buffers are not being sent to the sink,
1031+ // and therefore, not disposed by it.
1032+ natBuffer .dispose ();
1033+ }
10341034 natBuffer = buffer ;
10351035 fireCaptureEvent ();
10361036 }
10371037
1038-
1039- // moved to separate method for Jython support
1040- // https://github.com/processing/processing/pull/2527
1038+
10411039 private void fireCaptureEvent () {
1042- // Creates a captureEvent.
10431040 if (captureEventMethod != null ) {
10441041 try {
10451042 captureEventMethod .invoke (eventHandler , this );
1043+
10461044 } catch (Exception e ) {
1047- System .err .println (
1048- "error, disabling captureEvent() for capture object" );
1045+ System .err .println ("error, disabling captureEvent()" );
10491046 e .printStackTrace ();
10501047 captureEventMethod = null ;
10511048 }
10521049 }
10531050 }
10541051
1055-
1052+
10561053 ////////////////////////////////////////////////////////////
10571054
10581055 // Stream query methods.
@@ -1134,7 +1131,7 @@ protected String getFrameRate(String config) {
11341131 * copy the frames to OpenGL.
11351132 *
11361133 * NOTE: This is not official API and may/will be removed at any time.
1137- *
1134+ *
11381135 * @param Object dest
11391136 */
11401137 public void setBufferSink (Object sink ) {
@@ -1145,7 +1142,7 @@ public void setBufferSink(Object sink) {
11451142
11461143 /**
11471144 * Sets the object to use as destination for the frames read from the stream.
1148- *
1145+ *
11491146 * NOTE: This is not official API and may/will be removed at any time.
11501147 *
11511148 * @param Object dest
@@ -1190,22 +1187,22 @@ protected void getSinkMethods() {
11901187 throw new RuntimeException ("Capture: provided sink object doesn't have " +
11911188 "a setBufferSource method." );
11921189 }
1193-
1190+
11941191 try {
1195- sinkDisposeMethod = bufferSink .getClass ().getMethod ("disposeSourceBuffer" ,
1192+ sinkDisposeMethod = bufferSink .getClass ().getMethod ("disposeSourceBuffer" ,
11961193 new Class [] { });
11971194 } catch (Exception e ) {
11981195 throw new RuntimeException ("Capture: provided sink object doesn't have " +
11991196 "a disposeSourceBuffer method." );
12001197 }
1201-
1198+
12021199 try {
1203- sinkGetMethod = bufferSink .getClass ().getMethod ("getBufferPixels" ,
1200+ sinkGetMethod = bufferSink .getClass ().getMethod ("getBufferPixels" ,
12041201 new Class [] { int [].class });
12051202 } catch (Exception e ) {
12061203 throw new RuntimeException ("Capture: provided sink object doesn't have " +
12071204 "a getBufferPixels method." );
1208- }
1205+ }
12091206 }
12101207
12111208
@@ -1216,8 +1213,8 @@ protected void initCopyMask() {
12161213 copyMask = "red_mask=(int)0xFF, green_mask=(int)0xFF00, blue_mask=(int)0xFF0000" ;
12171214 }
12181215 }
1219-
1220-
1216+
1217+
12211218 public synchronized void post () {
12221219 if (useBufferSink && sinkDisposeMethod != null ) {
12231220 try {
@@ -1226,5 +1223,5 @@ public synchronized void post() {
12261223 e .printStackTrace ();
12271224 }
12281225 }
1229- }
1230- }
1226+ }
1227+ }
0 commit comments