/// <summary> /// Stop video source. /// </summary> /// /// <remarks><para>The method stop the video source, so it no longer provides new video frames /// and does not consume any resources.</para> /// </remarks> /// public void Stop( ) { lock ( sync ) { lock ( runningCameras ) { if (device != null) { bool deviceFailed = device.IsDeviceFailed(deviceID); if (!deviceFailed) { KinectNative.freenect_stop_depth(device.RawDevice); } device.Dispose( ); device = null; runningCameras.Remove(deviceID); if (PlayingFinished != null) { PlayingFinished(this, (!deviceFailed) ? ReasonToFinishPlaying.StoppedByUser : ReasonToFinishPlaying.DeviceLost); } } if (imageBuffer != IntPtr.Zero) { Marshal.FreeHGlobal(imageBuffer); imageBuffer = IntPtr.Zero; } videoCallback = null; } } }