Esempio n. 1
0
        public void ICOpenTest()
        {
            SafeHIC hic;

            Assert.That(hic = ICOpen(ICTYPE_VIDEO, WinMm.MAKEFOURCC("cvid"), ICMODE.ICMODE_DECOMPRESS), ResultIs.ValidHandle);
            Assert.That(() => hic.Dispose(), Throws.Nothing);
        }
Esempio n. 2
0
 public void Dispose()
 {
     if (SuccessfullySetResolution)
     {
         WinMm.EndPeriod(CurrentResolution);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Tries setting a given target timer resolution to the current thread.
        /// If the selected resolution can be set, a nearby value will be set instead.
        /// This must be disposed afterwards (or call EndPeriod() passing the CurrentResolution)
        /// </summary>
        /// <param name="targetResolution">The target resolution in milliseconds.</param>
        public TimerResolution(int targetResolution)
        {
            TargetResolution = (uint)targetResolution;

            //Get system limits.
            var timeCaps = new TimeCaps();

            if (WinMm.GetDevCaps(ref timeCaps, (uint)Marshal.SizeOf(typeof(TimeCaps))) != (uint)TimerResults.NoError)
            {
                return;
            }

            //Calculates resolution based on system limits.
            CurrentResolution = Math.Min(Math.Max(timeCaps.MinimumResolution, TargetResolution), timeCaps.MaximumResolution);

            //Begins the period in which the thread will run on this new timer resolution.
            if (WinMm.BeginPeriod(CurrentResolution) != (uint)TimerResults.NoError)
            {
                return;
            }

            SuccessfullySetResolution = true;

            if (CurrentResolution == TargetResolution)
            {
                SuccessfullySetTargetResolution = true;
            }
        }
Esempio n. 4
0
 public void Shutdown()
 {
     try
     {
         if (_gcHandle == null)
         {
             return;
         }
         WinMm.StopPlaying();
         _gcHandle.Value.Free();
         _gcHandle = null;
     }
     catch (Exception e)
     {
         Log.Error().WriteLine(e, "Error in deinitialize.");
     }
 }
Esempio n. 5
0
        private void PlaySound()
        {
            if (_soundBuffer == null)
            {
                return;
            }
            var soundFlags = SoundSettings.Async | SoundSettings.Memory | SoundSettings.NoWait | SoundSettings.NoStop;

            try
            {
                if (_gcHandle != null)
                {
                    WinMm.Play(_gcHandle.Value.AddrOfPinnedObject(), soundFlags);
                }
            }
            catch (Exception e)
            {
                Log.Error().WriteLine(e, "Error in play.");
            }
        }
Esempio n. 6
0
 public void ICAboutTest()
 {
     using var hic = ICOpen(ICTYPE_VIDEO, WinMm.MAKEFOURCC("cvid"), ICMODE.ICMODE_DECOMPRESS);
     Assert.That(hic, ResultIs.ValidHandle);
     Assert.That(ICAbout(hic, User32.GetDesktopWindow()), Is.EqualTo(ICERR.ICERR_OK));
 }
Esempio n. 7
0
 public void ICInfoTest()
 {
     Assert.That(ICInfo(ICTYPE_VIDEO, WinMm.MAKEFOURCC("cvid"), out var info), ResultIs.Successful);
     Assert.That(info.dwSize, Is.GreaterThan(0));
     info.WriteValues();
 }