Exemple #1
0
        public void ChangeAudioDevice(string deviceName = null)
        {
            if (CurrentDeviceName == deviceName && ApplicationDevice != null)
            {
                return;
            }
            var playbackDevices = DirectSound.GetDevices();
            // Use default device.
            Guid driverGuid = Guid.Empty;

            foreach (var device in playbackDevices)
            {
                // Pick specific device for the plaback.
                if (string.Compare(device.Description, deviceName, true) == 0)
                {
                    driverGuid = device.DriverGuid;
                }
            }
            if (ApplicationDevice != null)
            {
                ApplicationDevice.Dispose();
                ApplicationDevice = null;
            }
            // Create and set the sound device.
            ApplicationDevice = new DirectSound(driverGuid);
            SpeakerConfiguration speakerSet;
            SpeakerGeometry      geometry;

            ApplicationDevice.GetSpeakerConfiguration(out speakerSet, out geometry);
            ApplicationDevice.SetCooperativeLevel(_Handle, CooperativeLevel.Normal);
            CurrentDeviceName = deviceName;
        }
Exemple #2
0
        public void Open(string scriptPath)
        {
            lock (locker)
            {
                try
                {
                    script = scriptPath;
                    LoadAviSynth();

                    if (IsError || IsAborted)
                    {
                        return;
                    }

                    if (HasVideo)
                    {
                        try
                        {
                            //Framework 3.0 с SP1+
                            CreateInteropBitmap();
                        }
                        catch (TypeLoadException)
                        {
                            //Framework 3.0 без SP1
                            CreateWriteableBitmap();
                        }
                    }

                    if (HasAudio)
                    {
                        SetUpAudioDevice();
                    }

                    #region ShowPictureViewInfo
                    if (HasVideo && reader.GetVarBoolean("ShowPictureViewInfo", false))
                    {
                        SpeakerConfiguration conf = 0; SpeakerGeometry geom = 0;
                        if (HasAudio)
                        {
                            AudioDevice.GetSpeakerConfiguration(out conf, out geom);
                        }

                        Stopwatch sw = Stopwatch.StartNew();
                        for (int i = 0; i < 100; i++)
                        {
                            Thread.Sleep(1);
                        }
                        sw.Stop();

                        Message mes = new Message(Owner);
                        mes.ShowMessage("Video\r\n  Resolution: " + reader.Width + "x" + reader.Height + ", FrameRate: " + reader.Framerate + ", Format: " +
                                        reader.Clip.OriginalColorspace + ((reader.Clip.OriginalColorspace != AviSynthColorspace.RGB32) ? "->RGB32" : "") + " \r\n  Output: " +
                                        ((IsInterop) ? "InteropBitmap" : "WriteableBitmap (Install SP1 for .NET Framework 3.0!)") + "\r\n\r\nAudio\r\n" +
                                        ((HasAudio) ? "  Bits: " + BufferDesc.Format.BitsPerSample + ((reader.Clip.SampleType == AudioSampleType.FLOAT) ? " FLOAT" : "") +
                                         ", SampleRate: " + BufferDesc.Format.SampleRate + ", Channels: " + BufferDesc.Format.Channels + ((BufferDesc.Format.Encoding == WaveFormatEncoding.Extensible) ?
                                                                                                                                          ", Mask: " + ((WaveFormatExtensible)BufferDesc.Format).ChannelMask + " (" + (int)((WaveFormatExtensible)BufferDesc.Format).ChannelMask + ")" : "") +
                                         "\r\n  PrimaryBuffers: " + AudioDevice.Capabilities.PrimaryBuffers + ", MixingBuffers: " + AudioDevice.Capabilities.MaxHardwareMixingAllBuffers +
                                         " (" + AudioDevice.Capabilities.FreeHardwareMixingAllBuffers + "), 3DBuffers: " + AudioDevice.Capabilities.MaxHardware3DAllBuffers + " (" +
                                         AudioDevice.Capabilities.FreeHardware3DAllBuffers + "), MemBytes: " + AudioDevice.Capabilities.TotalHardwareMemBytes + " (" +
                                         AudioDevice.Capabilities.FreeHardwareMemBytes + "), SampleRate: " + AudioDevice.Capabilities.MinSecondarySampleRate + " - " +
                                         AudioDevice.Capabilities.MaxSecondarySampleRate + (((AudioDevice.Capabilities.Flags & CapabilitiesFlags.ContinousRate) > 0) ? " (continuous)" : "") +
                                         "\r\n  SpeakerConfiguration: " + conf + ", SpeakerGeometry: " + geom + "\r\n" : "  None" + ((!EnableAudio) ? " (disabled)" : "") + "\r\n") +
                                        "\r\nTimers\r\n  Sleep(100): " + sw.ElapsedMilliseconds + ", HighResolutionStopwatch: " + Stopwatch.IsHighResolution, Languages.Translate("Info"));
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    SetError(ex);
                }
            }
        }