Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CAT/CATSpeechCmds.cpp Source File

CATSpeechCmds.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /// \class   CATSpeechCmds.cpp
00003 /// \brief   Speech command input support
00004 /// \ingroup CATGUI
00005 /// 
00006 /// Copyright (c) 2008 by Michael Ellison.
00007 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00008 ///
00009 // $Author: mikeellison $
00010 // $Date: 2008-01-27 01:25:54 -0600 (Sun, 27 Jan 2008) $
00011 // $Revision:   $
00012 // $NoKeywords: $
00013 //
00014 //---------------------------------------------------------------------------
00015 
00016 #include "CATSpeechCmds.h"
00017 
00018 CATSpeechCmds::CATSpeechCmds()
00019 {
00020     fRecognizer  = 0;
00021     fRecoContext = 0;
00022     fRecoGrammar = 0;
00023 }
00024 
00025 CATSpeechCmds::~CATSpeechCmds()
00026 {
00027 }
00028 
00029 void CATSpeechCmds::ThreadFunction()
00030 {
00031     CATResult result = InitializeSAPI();
00032     if (CATSUCCEEDED(result))
00033     {
00034 
00035         CATMsgThread::ThreadFunction();
00036 
00037         UninitializeSAPI();
00038     }    
00039 }
00040 
00041 CATResult CATSpeechCmds::InitializeSAPI()
00042 {
00043     CATResult result = CAT_SUCCESS;
00044     ::CoInitialize(0);
00045     /*
00046     if (CATFAILED( result = ::CoCreateInstance(CLSID_SpSharedRecognizer, 
00047                                                0,
00048                                                CLSCTX_INPROC,
00049                                                IID_SpSharedRecognizer,
00050                                                &fRecognizer)))
00051     {
00052         CoUninitialize();        
00053         return CATRESULT(CAT_ERR_SPEECH_INIT);
00054     }
00055 
00056     if (FAILED(fRecognizer->CreateRecoContext(&fRecoContext)))
00057     {
00058         Uninitialize();
00059         return CATRESULT(CAT_ERR_SPEECH_INIT);
00060     }
00061     */
00062     return result;
00063 }
00064 
00065 void CATSpeechCmds::UninitializeSAPI()
00066 {
00067     if (fRecoGrammar)
00068         fRecoGrammar->Release();
00069     fRecoGrammar = 0;
00070 
00071     if (fRecoContext)
00072         fRecoContext->Release();
00073     fRecoContext = 0;
00074 
00075     if (fRecognizer)
00076         fRecognizer->Release();
00077     fRecognizer = 0;
00078 
00079     CoUninitialize();
00080 }
00081 

Generated on Mon Feb 11 04:09:47 2008 for Game Accessibility Suite by doxygen 1.5.4