[Amis-vcs] SF.net SVN: amis: [2416] branches/amis3/AmisGuiMFC2
Brought to you by:
julienq,
marisademeglio
From: <dan...@us...> - 2008-03-17 17:33:06
|
Revision: 2416 http://amis.svn.sourceforge.net/amis/?rev=2416&view=rev Author: daniel_weck Date: 2008-03-17 10:33:11 -0700 (Mon, 17 Mar 2008) Log Message: ----------- - trying to pin-down a weird crash *after* the application exits. I have added code to manually close the DX audio player thread instead of letting the Windows runtime do it. I'm not sure that's going to fix anything, I will keep testing. Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/AudioSequencePlayer.h 2008-03-17 17:33:11 UTC (rev 2416) @@ -56,6 +56,7 @@ HANDLE m_hThread; HANDLE m_hEventWakeup; + HANDLE m_hEventEnd; CRITICAL_SECTION m_csSequence; bool m_bAbort; Modified: branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/include/gui/self-voicing/directshow/dx_audio_player.h 2008-03-17 17:33:11 UTC (rev 2416) @@ -153,8 +153,9 @@ static audio_playerX* Instance(); static void DestroyInstance(); + #ifdef SINGLE_THREAD_HACK -HANDLE m_hEventWakeup; + HANDLE m_hEventWakeup; #endif ~audio_playerX(); Modified: branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/src/gui/MainFrm.cpp 2008-03-17 17:33:11 UTC (rev 2416) @@ -268,7 +268,7 @@ void CMainFrame::OnMenuSelect( UINT nItemID, UINT nFlags, HMENU hSysMenu ) { - TRACE("\n\nHERE 1"); + TRACE("\nCMainFrame::OnMenuSelect()\n"); CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu); if (amis::Preferences::Instance()->getIsSelfVoicing() == true) @@ -279,7 +279,7 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) { - TRACE("\n\nHERE 2"); + TRACE("\nCMainFrame::OnInitMenuPopup()\n"); m_lastOpenPopupMenu = pPopupMenu; CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); @@ -318,7 +318,7 @@ void CMainFrame::OnInitMenu(CMenu* pMenu) { - TRACE("\n\n\n\HERE xxxxxxxxxxxxxxxx"); + TRACE("\nCMainFrame::OnInitMenu()\n"); CMDIFrameWnd::OnInitMenu(pMenu); } @@ -375,8 +375,8 @@ if (m_lastOpenPopupMenu != NULL) { m_lastOpenPopupMenu = NULL; } - TRACE("\n---------------DANOUL1\n\n"); - TRACE(L"%d", cwnd); + //TRACE("\n---------------DANOUL1\n\n"); + //TRACE(L"%d", cwnd); } } if (amis::Preferences::Instance()->getIsSelfVoicing() == true && @@ -386,16 +386,16 @@ if (cwnd) mCommonPreTranslateMessageHandler->handle(pMsg, (cwnd == NULL ? -1 : cwnd->GetDlgCtrlID())); } if (pMsg->message == WM_CANCELMODE) { - TRACE("\n---------------DANOUL2\n\n"); - TRACE(L"%d", pMsg->message); + //TRACE("\n---------------DANOUL2\n\n"); + //TRACE(L"%d", pMsg->message); } if (pMsg->wParam == WM_CANCELMODE) { - TRACE("\n---------------DANOUL3\n\n"); - TRACE(L"%d", pMsg->wParam); + //TRACE("\n---------------DANOUL3\n\n"); + //TRACE(L"%d", pMsg->wParam); } if (pMsg->lParam == WM_CANCELMODE) { - TRACE("\n---------------DANOUL4\n\n"); - TRACE(L"%d", pMsg->lParam); + //TRACE("\n---------------DANOUL4\n\n"); + //TRACE(L"%d", pMsg->lParam); } return CFrameWnd::PreTranslateMessage(pMsg); } Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/AudioSequencePlayer.cpp 2008-03-17 17:33:11 UTC (rev 2416) @@ -534,6 +534,8 @@ //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); HANDLE xeventHandler = CreateThread(NULL, 0, &eventHandlerY, 0, 0, &lpdwThreadID); //AfxBeginThread(eventHandlerX,0); + //GetCurrentThreadId + TRACE("\nTHREAD ID (AUDIO_SEQ_PLAYER): %x\n", lpdwThreadID); } void AudioSequencePlayer::Stop(bool fromPlay) @@ -690,7 +692,7 @@ #endif //HWND hWnd = MainWndParts::Instance()->mpMainFrame->GetSafeHwnd(); - MainWndParts::Instance()->mpMainFrame->PostMessage(WM_COMMAND, (WPARAM)SELF_VOICING_PLAY_NEXT, (LPARAM)0); + MainWndParts::Instance()->mpMainFrame->SendMessage(WM_COMMAND, (WPARAM)SELF_VOICING_PLAY_NEXT, (LPARAM)0); //playNext(false); /* Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/dialogs/MenuVoicing.cpp 2008-03-17 17:33:11 UTC (rev 2416) @@ -215,11 +215,9 @@ UINT nID = mFrm->m_lastOpenPopupMenu->GetMenuItemID(0); std::string prompt = computeRootMenuFromFirstChildID(nID, false); - s.Format(_T("\n\n\n\n{{{ %d\n\n\n\n"), nItemID); //DAN_MENU_DEBUG + s.Format(_T("\nMenuVoicing::OnMenuSelect(%d) '%s'\n"), nItemID, prompt.c_str()); //DAN_MENU_DEBUG TRACE(s); - TRACE(prompt.c_str()); - AudioSequence* seq = createSeqPrepend(nFlags); if (prompt.compare("file") == 0 || prompt.compare("recentBooksList") == 0) { @@ -266,10 +264,9 @@ } } else if ((nItemID >=0 && nItemID <=6) && (mFrm->m_lastOpenPopupMenu == NULL)) { //TODO: Yuuk ! UGLY ! This is only a temporary workaround ! //(nFlags & MF_GRAYED) - s.Format(_T("\n\n\n\n{{{ %d\n\n\n\n"), nItemID); //DAN_MENU_DEBUG + s.Format(_T("\nMenuVoicing::OnMenuSelect(%d)\n"), nItemID); //DAN_MENU_DEBUG TRACE(s); - AudioSequence* seq = createSeqPrepend(nFlags); switch (nItemID) { @@ -318,7 +315,9 @@ } else { - s.Format(_T("Item %d is selected"), nItemID); //DAN_MENU_DEBUG + + s.Format(_T("\nMenuVoicing::OnMenuSelect(%d is selected)\n"), nItemID); //DAN_MENU_DEBUG + TRACE(s); Modified: branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-17 04:28:03 UTC (rev 2415) +++ branches/amis3/AmisGuiMFC2/src/gui/self-voicing/directshow/dx_audio_player.cpp 2008-03-17 17:33:11 UTC (rev 2416) @@ -57,6 +57,11 @@ #define errorX #define traceX + +#ifdef SINGLE_THREAD_HACK + static bool bDestroyBreak = false; +#endif + static int nTimes = 0; //unsigned __stdcall eventHandler(void* lpParam) { @@ -71,7 +76,11 @@ int nn = ++nTimes; TRACE(L"\n== THREAD BEGIN %d\n", nn); - while(!bSelfBreak) { + while(!bSelfBreak +#ifdef SINGLE_THREAD_HACK + && !bDestroyBreak +#endif + ) { hResult = E_FAIL; #ifdef SINGLE_THREAD_HACK if (pPlayer->m_media_event == NULL) { @@ -166,15 +175,29 @@ hEventHandler(0) { set_rate(1.0); + +#ifdef SINGLE_THREAD_HACK + bDestroyBreak = false; m_hEventWakeup = CreateEvent(NULL, TRUE, FALSE, NULL); _ASSERT(m_hEventWakeup); ResetEvent(m_hEventWakeup); +#endif + InitializeCriticalSection(&m_csSequence); } gui::dx::audio_playerX::~audio_playerX() { - stop(true); + stop(true); + +#ifdef SINGLE_THREAD_HACK + TRACE(L"\n####### ~audio_playerX || SetEvent(m_hEventWakeup)\n"); + //end_thread(); + bDestroyBreak = true; + SetEvent(m_hEventWakeup); + CloseHandle(m_hEventWakeup); +#endif + DeleteCriticalSection(&m_csSequence); } @@ -785,6 +808,8 @@ unsigned long lpdwThreadID; //hEventHandler = (HANDLE) _beginthreadex(NULL, 0, eventHandler, (void*) this, 0, &lpdwThreadID); hEventHandler = CreateThread(NULL, 0, &eventHandler, this, 0, &lpdwThreadID); + //GetCurrentThreadId + TRACE("\nTHREAD ID (DX_AUDIO_PLAYER): %x\n", lpdwThreadID); } #ifdef SINGLE_THREAD_HACK SetEvent(m_hEventWakeup); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |