Ejemplo n.º 1
0
        public void SetDevice(int?DeviceId)
        {
            CurrentDeviceID = DeviceId.HasValue ? DeviceId.Value : -1;

            if (_initialized)
            {
                FreeHandles();
                Bass.Free();
                _initialized = false;
            }

            _initialized = Bass.Init(CurrentDeviceID, _configuration.Frequency, DeviceInitFlags.Frequency, IntPtr.Zero);
            if (_initialized)
            {
                Bass.Start();

                if (_configuration.RememberDeviceId)
                {
                    _configuration.LastDeviceId = CurrentDeviceID;
                }
            }
            else
            {
                ExceptionFactory.Create(Bass.LastError, "Output init error");
            }
        }
Ejemplo n.º 2
0
        public void Send_Where_OutputPathDoesntExist_Expected_PathCreatedAndActionIvoked()
        {
            var tmpOutputPath = new FileInfo(GetUniqueOutputPath(".txt"));

            if (tmpOutputPath.Directory != null)
            {
                string newOutputFolder = Path.Combine(tmpOutputPath.Directory.FullName, Guid.NewGuid().ToString());
                string newOutputpath   = Path.Combine(newOutputFolder, tmpOutputPath.Name);

                var vm = new ExceptionViewModel {
                    OutputPath = newOutputpath, OutputText = ExceptionFactory.Create(GetException()).ToString()
                };

                var mockEmailAction = new Mock <IFeedbackAction>();
                mockEmailAction.Setup(c => c.StartFeedback()).Verifiable();

                var mockInvoker = new Mock <IFeedbackInvoker>();
                mockInvoker.Setup(i => i.InvokeFeedback(It.IsAny <IFeedbackAction>())).Verifiable();

                vm.FeedbackAction  = mockEmailAction.Object;
                vm.FeedbackInvoker = mockInvoker.Object;

                vm.SendReport();

                mockInvoker.Verify(a => a.InvokeFeedback(It.IsAny <IFeedbackAction>()), Times.Once());
                Assert.AreEqual(Directory.Exists(newOutputFolder), true);
            }
        }
        public void ExceptionFactoryCreateDefaultExceptionsExpectedCorrectExceptionsReturned()
        {
            //Initialization
            var e = GetException();

            //Execute
            var vm = ExceptionFactory.Create(e);

            //Assert
            Assert.AreEqual(StringResources.ErrorPrefix + "Test Exception", vm.Message, "Exception view model is displaying an incorrect default exception message");
            Assert.AreEqual(1, vm.Exception.Count, "Wrong number of exceptions displayed by exception view model");
            Assert.AreEqual(StringResources.ErrorPrefix + "Test inner Exception", vm.Exception[0].Message, "Exception view model is displaying the wrong default inner exception message");
        }
Ejemplo n.º 4
0
        private void ExceptionHelper <T>(COMException xtfException, string consoleIpAddress, ulong?gamepadId)
        {
            Exception createdException = null;

            if (string.IsNullOrEmpty(consoleIpAddress))
            {
                createdException = ExceptionFactory.Create(ExceptionMessage, xtfException);
            }
            else if (!gamepadId.HasValue)
            {
                createdException = ExceptionFactory.Create(ExceptionMessage, xtfException, consoleIpAddress);
            }
            else
            {
                createdException = ExceptionFactory.Create(ExceptionMessage, xtfException, consoleIpAddress, gamepadId.Value);
            }

            Assert.IsNotNull(createdException);
            Assert.IsInstanceOfType(createdException, typeof(XboxConsoleException));
            Assert.IsTrue(createdException.Message.StartsWith(ExceptionMessage, StringComparison.Ordinal));
            Assert.AreEqual(xtfException, createdException.InnerException);

            var consoleException = createdException as XboxConsoleException;

            if (consoleIpAddress != null)
            {
                Assert.AreEqual(consoleIpAddress, consoleException.XboxName, "XboxName are not equal for XboxConsoleException");
            }

            var gamepadException = createdException as XboxInputException;

            if (gamepadException != null && gamepadId.HasValue)
            {
                Assert.AreEqual(gamepadId.Value, gamepadException.XboxGamepadId, "GamepadId are not equal for XboxInputException");
            }
        }
Ejemplo n.º 5
0
        public void Load(string url)
        {
            CurrentMediaKind = MediaKind.None;

            FreeHandles();

            if (FormatHelpers.IsMidi(url) && File.Exists(_configuration.SoundFontPath))
            {
                BassMidi.DefaultFont = _configuration.SoundFontPath;
            }

            const BassFlags sourceflags = BassFlags.Decode | BassFlags.Loop | BassFlags.Float | BassFlags.Prescan;
            const BassFlags mixerflags  = BassFlags.MixerDownMix | BassFlags.MixerPositionEx | BassFlags.AutoFree;

            if (FormatHelpers.IsNetwork(url))
            {
                _sourceHandle    = Bass.CreateStream(url, 0, sourceflags, _callback, IntPtr.Zero);
                CurrentMediaKind = MediaKind.Network;
            }
            else if (FormatHelpers.IsCd(url))
            {
                (int drive, int track)cdInfo = FormatHelpers.ProcessCdUrl(url);
                _sourceHandle    = BassCd.CreateStream(cdInfo.drive, cdInfo.track, sourceflags);
                CurrentMediaKind = MediaKind.CDStream;
            }
            else if (FormatHelpers.IsTracker(url))
            {
                _sourceHandle    = Bass.MusicLoad(url, 0, 0, sourceflags);
                CurrentMediaKind = MediaKind.Tracker;
                MetaInfo         = TrackMetaInfoFactory.CreateTrackerInfo(url, _sourceHandle);
            }
            else
            {
                _sourceHandle    = Bass.CreateStream(url, 0, 0, sourceflags);
                CurrentMediaKind = MediaKind.File;
                MetaInfo         = TrackMetaInfoFactory.CreateFileInfo(url);
            }

            if (_sourceHandle == 0)
            {
                ExceptionFactory.Create(Bass.LastError, "File Load failed");
            }

            _sourceInfo  = Bass.ChannelGetInfo(_sourceHandle);
            _mixerHandle = BassMix.CreateMixerStream(_sourceInfo.Frequency, _sourceInfo.Channels, mixerflags);

            if (_mixerHandle == 0)
            {
                ExceptionFactory.Create(Bass.LastError, "Mixer failed");
            }

            if (!BassMix.MixerAddChannel(_mixerHandle, _sourceHandle, BassFlags.MixerDownMix))
            {
                ExceptionFactory.Create(Bass.LastError, "Channel mixing failed");
            }

            Bass.ChannelSetAttribute(_mixerHandle, ChannelAttribute.Volume, _lastvol);
            InitEq(ref _mixerHandle);
            Bass.ChannelPlay(_mixerHandle, false);
            IsPlaying = true;
            NotifyPropertyChanged(nameof(MetaInfo));
        }