Пример #1
0
 protected void TestAudioSetup(Form wnd)
 {
     try
     {
         Voice.Test test = new Voice.Test();
         try
         {
             test.CheckAudioSetup(DSoundHelper.DefaultPlaybackDevice, DSoundHelper.DefaultCaptureDevice, wnd, Voice.TestFlags.QueryOnly);
         }
         catch (DirectXException)
         {
             try
             {
                 test.CheckAudioSetup(DSoundHelper.DefaultPlaybackDevice, DSoundHelper.DefaultCaptureDevice, wnd, Voice.TestFlags.AllowBack);
             }
             catch (DirectXException dxeUser)
             {
                 throw dxeUser;
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #2
0
        /// <summary>
        /// Tests the current DirectPlay voice configuration and displays built-in
        /// configuration UI if needed.
        /// </summary>
        /// <returns>true if DirectPlay Voice configuration passed tests</returns>
        private bool TestDirectVoice()
        {
            // Create a new Test object for DirectPlay Voice
            Voice.Test VoiceTest = new Voice.Test();

            try
            {
                // Check the current audio configuration
                VoiceTest.CheckAudioSetup(DSoundHelper.DefaultVoicePlaybackDevice, // Guid of the default playback hardware
                                          DSoundHelper.DefaultCaptureDevice,       // Guid of the default capture hardware
                                          Voice.TestFlags.QueryOnly);              // Read-only flag
            }
            catch (DirectXException dex)
            {
                if (dex.ErrorCode == (int)Voice.ResultCode.RunSetup)
                {
                    try
                    {
                        // Test setup again, this time allowing user configuration
                        VoiceTest.CheckAudioSetup(DSoundHelper.DefaultVoicePlaybackDevice, // Guid of the default playback hardware
                                                  DSoundHelper.DefaultCaptureDevice,       // Guid of the default capture hardware
                                                  m_Form,                                  // Current window handle for UI display
                                                  Voice.TestFlags.AllowBack);              // Enable back button flag
                    }
                    catch (Exception ex)
                    {
                        m_Form.ShowException(ex, "CheckAudioSetup", true);
                        m_Form.Dispose();
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                m_Form.ShowException(ex, "CheckAudioSetup", true);
                m_Form.Dispose();
                return(false);
            }

            return(true);
        }