OSDN Git Service

* Enable building speech for the distro (nigtlies and releases)
authorLatif Khalifa <latifer@streamgrid.net>
Wed, 11 Nov 2009 13:43:19 +0000 (13:43 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Wed, 11 Nov 2009 13:43:19 +0000 (13:43 +0000)
* Make speech startup/shutdown only when needed
* Move ALICE button to plugins menu

git-svn-id: https://radegast.googlecode.com/svn/trunk@444 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast.sln
Radegast/GUI/Dialogs/MainForm.Designer.cs
plugins/Radegast.Plugin.Alice/Alice.cs
plugins/Radegast.Plugin.Speech/RadSpeech/PluginControl.cs
plugins/Radegast.Plugin.Speech/RadSpeech/Talk/Synthesizer.cs
plugins/Radegast.Plugin.Speech/RadSpeechWin/WinSpeech.cs

index c0d0a86..03f7c40 100644 (file)
@@ -97,27 +97,35 @@ Global
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|x86.ActiveCfg = Debug|x86\r
+               {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Debug|x86.Build.0 = Debug|x86\r
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|Any CPU.Build.0 = Release|Any CPU\r
                {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|x86.ActiveCfg = Release|x86\r
+               {BA078535-BB58-45F0-9225-D2F6DF1197E4}.Release|x86.Build.0 = Release|x86\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|x86.ActiveCfg = Debug|x86\r
+               {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Debug|x86.Build.0 = Debug|x86\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|Any CPU.Build.0 = Release|Any CPU\r
                {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|x86.ActiveCfg = Release|x86\r
+               {D19A654B-FE91-4010-A654-FC88AE62F7CC}.Release|x86.Build.0 = Release|x86\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|x86.ActiveCfg = Debug|x86\r
+               {33B46397-BA1C-490A-A0A6-81C409884CE2}.Debug|x86.Build.0 = Debug|x86\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|Any CPU.Build.0 = Release|Any CPU\r
                {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|x86.ActiveCfg = Release|x86\r
+               {33B46397-BA1C-490A-A0A6-81C409884CE2}.Release|x86.Build.0 = Release|x86\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|x86.ActiveCfg = Debug|x86\r
+               {DDFA3357-938D-41A3-881E-152105641A3D}.Debug|x86.Build.0 = Debug|x86\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Release|Any CPU.Build.0 = Release|Any CPU\r
                {DDFA3357-938D-41A3-881E-152105641A3D}.Release|x86.ActiveCfg = Release|x86\r
+               {DDFA3357-938D-41A3-881E-152105641A3D}.Release|x86.Build.0 = Release|x86\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
index 69bfd5b..6297141 100644 (file)
@@ -103,7 +103,6 @@ namespace Radegast
             this.cleanCacheToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
             this.setAppearanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
             this.rebakeTexturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
-            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();\r
             this.tbnPlugins = new System.Windows.Forms.ToolStripDropDownButton();\r
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();\r
             this.tbtnFriends = new System.Windows.Forms.ToolStripButton();\r
@@ -371,8 +370,7 @@ namespace Radegast
             this.autopilotToolStripMenuItem,\r
             this.cleanCacheToolStripMenuItem,\r
             this.setAppearanceToolStripMenuItem,\r
-            this.rebakeTexturesToolStripMenuItem,\r
-            this.toolStripMenuItem1});\r
+            this.rebakeTexturesToolStripMenuItem});\r
             this.tbnTools.Enabled = false;\r
             this.tbnTools.Image = ((System.Drawing.Image)(resources.GetObject("tbnTools.Image")));\r
             this.tbnTools.ImageTransparentColor = System.Drawing.Color.Magenta;\r
@@ -423,11 +421,6 @@ namespace Radegast
             this.rebakeTexturesToolStripMenuItem.Text = "Rebake textures";\r
             this.rebakeTexturesToolStripMenuItem.Click += new System.EventHandler(this.rebakeTexturesToolStripMenuItem_Click);\r
             // \r
-            // toolStripMenuItem1\r
-            // \r
-            this.toolStripMenuItem1.Name = "toolStripMenuItem1";\r
-            this.toolStripMenuItem1.Size = new System.Drawing.Size(153, 6);\r
-            // \r
             // tbnPlugins\r
             // \r
             this.tbnPlugins.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
@@ -828,7 +821,6 @@ namespace Radegast
         public System.Windows.Forms.ToolStripButton tbtnGroups;\r
         public System.Windows.Forms.ToolStripMenuItem scriptEditorToolStripMenuItem;\r
         public System.Windows.Forms.ToolStripDropDownButton tbnPlugins;\r
-        public System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;\r
         public System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;\r
         public System.Windows.Forms.ToolStripMenuItem tmnuCreateLandmark;\r
         public System.Windows.Forms.ToolStripMenuItem tmnuSetHome;\r
index 6401763..fd876cb 100644 (file)
@@ -70,8 +70,9 @@ namespace Radegast.Plugin.Alice
                 Enabled = Instance.GlobalSettings["plugin.alice.enabled"].AsBoolean();\r
             }\r
 \r
-            MenuButton = new ToolStripMenuItem("A.L.I.C.E. chatbot", null, OnALICEMenuButtonClicked);\r
-            Instance.MainForm.ToolsMenu.DropDownItems.Add(MenuButton);\r
+            MenuButton = new ToolStripMenuItem("ALICE chatbot", null, OnALICEMenuButtonClicked);\r
+            Instance.MainForm.PluginsMenu.DropDownItems.Add(MenuButton);\r
+            Instance.MainForm.PluginsMenu.Visible = true;\r
             MenuButton.Checked = Enabled;\r
 \r
             try\r
index 5fbc097..b738353 100644 (file)
@@ -54,6 +54,7 @@ namespace RadegastSpeech
         private ToolStripMenuItem SpeechButton;\r
         internal IRadSpeech osLayer;\r
         public OSDMap config;\r
+        private bool started;\r
 \r
         /// <summary>\r
         /// Plugin start-up entry.\r
@@ -66,6 +67,7 @@ namespace RadegastSpeech
 \r
             // Get configuration settings, and initialize if not found.\r
             config = instance.GlobalSettings["plugin.speech"] as OSDMap;\r
+            \r
             if (config == null)\r
             {\r
                 config = new OSDMap();\r
@@ -77,6 +79,30 @@ namespace RadegastSpeech
                 instance.GlobalSettings.Save();\r
             }\r
 \r
+            // Add our enable/disable item to the Plugin Menu.\r
+            ToolsMenu = instance.MainForm.PluginsMenu;\r
+\r
+            SpeechButton = new ToolStripMenuItem("Speech", null, OnSpeechMenuButtonClicked);\r
+            ToolsMenu.DropDownItems.Add(SpeechButton);\r
+\r
+            SpeechButton.Checked = config["enabled"].AsBoolean();\r
+\r
+            ToolsMenu.Visible = true;\r
+\r
+            if (SpeechButton.Checked)\r
+            {\r
+                Initialize();\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// Startup code (executed only when needed)\r
+        /// </summary>\r
+        private void Initialize()\r
+        {\r
+            // Never initialize twice\r
+            if (started) return;\r
+\r
             // Do the one-time only initializations.\r
             try\r
             {\r
@@ -86,34 +112,42 @@ namespace RadegastSpeech
                 listener = new Listen.Control(this);\r
                 converse = new Conversation.Control(this);\r
                 sound = new Sound.FmodSound(this);\r
+                StartControls();\r
+                talker.SayMore("Press enter to connect.");\r
+                started = true;\r
             }\r
             catch (Exception e)\r
             {\r
+                SpeechButton.Checked = false;\r
+                config["enabled"] = OSD.FromBoolean(false);\r
+                SaveSpeechSettings();\r
                 System.Windows.Forms.MessageBox.Show("Speech failed initialization: " + e.Message);\r
                 return;\r
-\r
             }\r
+        }\r
 \r
-            // Add our enable/disable item to the Plugin Menu.\r
-            ToolsMenu = instance.MainForm.PluginsMenu;\r
-\r
-            SpeechButton = new ToolStripMenuItem("Speech", null, OnSpeechMenuButtonClicked);\r
-            ToolsMenu.DropDownItems.Add(SpeechButton);\r
-\r
-            SpeechButton.Checked = config["enabled"].AsBoolean();\r
-\r
-            ToolsMenu.Visible = true;\r
-\r
-            if (SpeechButton.Checked)\r
+        /// <summary>\r
+        /// Shutdown speech module\r
+        /// </summary>\r
+        private void Shutdown()\r
+        {\r
+            if (!started) return;\r
+            try\r
             {\r
-                StartControls();\r
-                talker.SayMore("Press enter to connect.");\r
+                converse.Shutdown();\r
+                listener.Shutdown();\r
+                talker.Shutdown();\r
+                env.Shutdown();\r
+                sound.Shutdown();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Logger.Log("Failed to shutdown speech modules: ", Helpers.LogLevel.Warning, e);\r
+            }\r
+            finally\r
+            {\r
+                started = false;\r
             }\r
-\r
-            // Announce our version in the main chat window.\r
-            // TODO remove this once debugging is complete.\r
-            instance.MainForm.TabConsole.DisplayNotificationInChat(\r
-                "Speech Plugin version " + VERSION + " loaded");\r
         }\r
 \r
         /// <summary>\r
@@ -141,8 +175,6 @@ namespace RadegastSpeech
                 return;\r
             }\r
 \r
-            instance.Client.Settings.MULTIPLE_SIMS = false;\r
-\r
             // Register the speech-related actions for context menus.\r
             // Editing voice assignments to avatars.\r
             instance.ContextActionManager.RegisterContextAction(\r
@@ -168,11 +200,7 @@ namespace RadegastSpeech
         /// We use this to release system resources.</remarks>\r
         public void StopPlugin(RadegastInstance inst)\r
         {\r
-            converse.Shutdown();\r
-            listener.Shutdown();\r
-            talker.Shutdown();\r
-            env.Shutdown();\r
-            sound.Shutdown();\r
+            Shutdown();\r
         }\r
 \r
         /// <summary>\r
@@ -184,13 +212,13 @@ namespace RadegastSpeech
         {\r
             SpeechButton.Checked = !SpeechButton.Checked;\r
 \r
-            if (SpeechButton.Enabled)\r
+            if (SpeechButton.Checked)\r
             {\r
-                StartControls();\r
+                Initialize();\r
             }\r
             else\r
             {\r
-                StopPlugin(instance);\r
+                Shutdown();\r
             }\r
 \r
             // Save this into the INI file.\r
index 171c639..8597bd0 100644 (file)
@@ -54,6 +54,7 @@ namespace RadegastSpeech.Talk
             if (control.osLayer == null) return;\r
             control.osLayer.Speak(q, outputfile);\r
         }\r
+\r
         internal void Shutdown()\r
         {\r
             if (control.osLayer == null) return;\r
index 319b2bd..cda71ba 100644 (file)
@@ -31,13 +31,24 @@ namespace RadegastSpeech
 \r
         public void SpeechStop()\r
         {\r
-            synth.SpeechStop();\r
-            recog.Stop();\r
+            if (synth != null)\r
+            {\r
+                synth.SpeechStop();\r
+                synth = null;\r
+            }\r
+\r
+            if (recog != null)\r
+            {\r
+                recog.Stop();\r
+                recog = null;\r
+            }\r
         }\r
+\r
         public void SpeechHalt()\r
         {\r
             synth.Halt();\r
         }\r
+\r
         public Dictionary<string, AvailableVoice> GetVoices()\r
         {\r
             return synth.GetVoices();\r