freenect_stop_video() public static method

public static freenect_stop_video ( IntPtr device ) : int
device IntPtr
return int
コード例 #1
0
        /// <summary>
        /// Stop video source.
        /// </summary>
        ///
        /// <remarks><para>The method stops 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)
                    {
                        var deviceFailed = Kinect.IsDeviceFailed(deviceID);

                        if (!deviceFailed)
                        {
                            KinectNative.freenect_stop_video(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;
                }
            }
        }