private void Initialize(Profile profile) { if (Mode == EngineMode.Synchronous) { throw new Exception("Only an asynchronous engine instance can be initialized with a profile."); } profile.Freeze(); InitializeForAsynchronous(profile); }
protected static Profile BaseOpenProfile(string fileName, IFileIOHandler ioHandler) { var p = new Profile {FileIOHandler = ioHandler}; var document = new XmlDocument(); document.Load(fileName); XmlNode documentElement = document.DocumentElement; p.FileName = fileName; p.ClearChannels(); if (documentElement != null) { var channelObjectsNode = documentElement.SelectNodes("ChannelObjects/*"); if (channelObjectsNode != null) { foreach (XmlNode channelObject in channelObjectsNode) { p.AddChannelObject(new Channel(channelObject), false); } } var outputNodes = documentElement.SelectSingleNode("Outputs"); if (outputNodes != null) { foreach (var outputChannel in outputNodes.InnerText.Split(',').Where(outputChannel => outputChannel.Length > 0)) { p.AddChannelOutput(Convert.ToInt32(outputChannel)); } } } p.PlugInData.LoadFromXml(documentElement); p.Groups = Group.LoadFromXml(documentElement) ?? new Dictionary<string, GroupData>(); p.IsDirty = Group.LoadFromFile(documentElement, p.Groups); if (documentElement != null) { var disabledChannelsNode = documentElement.SelectSingleNode("DisabledChannels"); if (disabledChannelsNode != null) { foreach ( var disabledChannel in disabledChannelsNode.InnerText.Split(',').Where(disabledChannel => disabledChannel != string.Empty)) { p.Channels[Convert.ToInt32(disabledChannel)].Enabled = false; } } } p.Freeze(); return p; }
protected static void BaseSaveProfile(XmlDocument doc, Profile profileObject, FormatChannelDelegate fc) { profileObject.Freeze(); // fix VIX-53 XmlNode profileDoc = doc.DocumentElement; var channelObjectsNode = Xml.GetEmptyNodeAlways(profileDoc, "ChannelObjects"); foreach (var channel in profileObject.Channels) { channelObjectsNode.AppendChild(fc(doc, channel)); } var outputs = string.Join(",", (from c in profileObject.Channels select c.OutputChannel.ToString()).ToArray()); Xml.GetEmptyNodeAlways(profileDoc, "Outputs").InnerText = outputs; if (profileDoc != null) { profileDoc.AppendChild(doc.ImportNode(profileObject.PlugInData.RootNode, true)); } var disabledChannels = string.Join(",", (from c in profileObject.Channels where !c.Enabled select profileObject.Channels.FindIndex(i => i == c).ToString()).ToArray()); Xml.SetValue(profileDoc, "DisabledChannels", disabledChannels); }
public int RequestContext(bool suppressAsynchronousContext, bool suppressSynchronousContext, Form keyInterceptor) { try { var num = ((int)DateTime.Now.ToBinary()) + _registeredContexts.Count; var context = new ExecutionContext { SuppressAsynchronousContext = suppressAsynchronousContext, SuppressSynchronousContext = suppressSynchronousContext }; var integer = _preferences.GetInteger("SoundDevice"); context.SynchronousEngineInstance = context.SuppressSynchronousContext ? null : new Engine8(_host, integer); context.AsynchronousEngineInstance = context.SuppressAsynchronousContext ? null : new Engine8(Engine8.EngineMode.Asynchronous, _host, integer); context.LocalRequestor = RequestorIsLocal(new StackTrace().GetFrame(1)); context.Object = null; context.KeyInterceptor = keyInterceptor; if (!context.SuppressAsynchronousContext) { byte[][] mask; SetupData plugInData; var str = _preferences.GetString("AsynchronousData"); var str2 = ((str != "Default") && (str != "Sync")) ? str : _preferences.GetString("DefaultProfile"); Profile profile = null; if (str2.Length > 0) { try { var nativeIO = FileIOHelper.GetNativeHelper(); profile = nativeIO.OpenProfile(Path.Combine(Paths.ProfilePath, str2 + ".pro")); profile.Freeze(); } catch { LogError("RequestContext", "Error loading profile " + str2); } } if (profile == null) { if (str == "Default") { LogError("RequestContext", "Preference set to use default profile for asynchronous execution, but no default profile exists."); } mask = null; plugInData = null; } else { mask = profile.Mask; plugInData = profile.PlugInData; context.Object = profile; } if (context.Object != null) { context.Object.Mask = mask; if (plugInData != null) { context.Object.PlugInData.ReplaceRoot(plugInData.RootNode); } AsyncInit(context); } } _registeredContexts[num] = context; return(num); } catch (Exception exception) { LogError("RequestContext", exception); return(0); } }
public void AttachToProfile(Profile profile) { _profile = profile; _profile.Freeze(); LoadFromProfile(); }