示例#1
0
 // Async context means it is not synced with any music (e.g. channel testing)
 private static void AsyncInit(ExecutionContext context)
 {
     context.AsynchronousEngineInstance.Initialize(context.Object);
 }
示例#2
0
 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;
     }
 }