sumom****@users*****
sumom****@users*****
2009年 11月 12日 (木) 11:03:49 JST
Index: julius4/msvc/SampleApp/Julius.cpp diff -u julius4/msvc/SampleApp/Julius.cpp:1.6 julius4/msvc/SampleApp/Julius.cpp:1.7 --- julius4/msvc/SampleApp/Julius.cpp:1.6 Fri Nov 6 13:47:47 2009 +++ julius4/msvc/SampleApp/Julius.cpp Thu Nov 12 11:03:49 2009 @@ -10,12 +10,13 @@ #include <julius/juliuslib.h> #include "Julius.h" +#include "process.h" // ----------------------------------------------------------------------------- // JuliusLib callback functions // -#define JCALLBACK(A, B) static void A (Recog *recog, void *data) { cJulius *j = (cJulius *) data; SendMessage(j->getWindow(), WM_JULIUS, B, 0L);} +#define JCALLBACK(A, B) static void A (Recog *recog, void *data) { cJulius *j = (cJulius *) data; PostMessage(j->getWindow(), WM_JULIUS, B, 0L);} JCALLBACK(callback_engine_active, JEVENT_ENGINE_ACTIVE) JCALLBACK(callback_engine_inactive, JEVENT_ENGINE_INACTIVE) @@ -95,7 +96,7 @@ wparam = (code << 16) + JEVENT_RESULT_FINAL; // send message - SendMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr); + PostMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr); } // callbackk for pause @@ -116,13 +117,13 @@ #endif // main function for the engine thread -DWORD WINAPI recogThreadMain(LPVOID vdParam) +unsigned __stdcall recogThreadMain( void *param ) { int ret; - Recog *recog = (Recog *)vdParam; + Recog *recog = (Recog *)param; ret = j_recognize_stream(recog); - if (ret == -1) ExitThread(FALSE); - ExitThread(TRUE); + _endthreadex(ret); + return(ret); } //----------------------------------------------------------------------------------------- @@ -355,8 +356,8 @@ return false; } // create recognition thread - m_threadHandle = CreateThread(NULL, 0, ::recogThreadMain, (LPVOID)m_recog, 0, &m_threadId); - if (m_threadHandle == NULL) { + m_threadHandle = (HANDLE)_beginthreadex(NULL, 0, ::recogThreadMain, m_recog, 0, NULL); + if (m_threadHandle == 0) { j_close_stream(m_recog); return false; } @@ -490,7 +491,7 @@ /* make sure this process will be activated */ r->active = 1; - SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); + PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); return true; } @@ -526,7 +527,7 @@ /* tell engine to update at requested timing */ schedule_grammar_update(m_recog); - SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); + PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); return true; } @@ -557,7 +558,7 @@ } /* tell engine to update at requested timing */ schedule_grammar_update(m_recog); - SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); + PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); return true; } @@ -588,7 +589,7 @@ } /* tell engine to update at requested timing */ schedule_grammar_update(m_recog); - SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); + PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L); return true; } Index: julius4/msvc/SampleApp/Julius.h diff -u julius4/msvc/SampleApp/Julius.h:1.4 julius4/msvc/SampleApp/Julius.h:1.5 --- julius4/msvc/SampleApp/Julius.h:1.4 Tue Oct 27 23:56:58 2009 +++ julius4/msvc/SampleApp/Julius.h Thu Nov 12 11:03:49 2009 @@ -47,7 +47,6 @@ bool m_opened; FILE *m_fpLogFile; HANDLE m_threadHandle; - DWORD m_threadId; HWND m_hWnd; _locale_t m_modelLocale; #ifdef APP_ADIN