Fix audio crash on shutdown, log thread names more.

This commit is contained in:
Unknown W. Brackets 2013-08-18 23:25:14 -07:00
parent ad40ef6a52
commit 342bad8402
3 changed files with 25 additions and 11 deletions

View File

@ -27,6 +27,7 @@
#include <stdarg.h>
#endif
#include "thread/threadutil.h"
#include "Common.h"
#include "LogManager.h" // Common
#include "ConsoleListener.h" // Common
@ -248,6 +249,7 @@ COORD ConsoleListener::GetCoordinates(int BytesRead, int BufferWidth)
unsigned int WINAPI ConsoleListener::RunThread(void *lpParam)
{
setCurrentThreadName("ConsoleThread");
ConsoleListener *consoleLog = (ConsoleListener *)lpParam;
consoleLog->LogWriterThread();
return 0;

View File

@ -1,3 +1,4 @@
#include "native/thread/threadutil.h"
#include "Common/CommonWindows.h"
#include <dsound.h>
@ -112,6 +113,7 @@ namespace DSound
unsigned int WINAPI soundThread(void *)
{
setCurrentThreadName("DSoundThread");
currentPos = 0;
lastPos = 0;
//writeDataToBuffer(0,realtimeBuffer,bufferSize);
@ -190,18 +192,27 @@ namespace DSound
void DSound_StopSound()
{
threadData=1;
WaitForSingleObject(hThread,1000);
CloseHandle(hThread);
/*
while (threadData!=2)
;*/
if (dsBuffer != NULL)
dsBuffer->Release();
if (ds != NULL)
ds->Release();
if (threadData == 0)
threadData = 1;
CloseHandle(soundSyncEvent);
if (hThread != NULL)
{
WaitForSingleObject(hThread, 1000);
CloseHandle(hThread);
}
if (threadData == 2)
{
if (dsBuffer != NULL)
dsBuffer->Release();
dsBuffer = NULL;
if (ds != NULL)
ds->Release();
ds = NULL;
}
if (soundSyncEvent != NULL)
CloseHandle(soundSyncEvent);
soundSyncEvent = NULL;
}

View File

@ -139,6 +139,7 @@ shutdown:
_InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);
NativeShutdownGraphics();
host->ShutdownSound();
host = nativeHost;
NativeShutdown();
host = oldHost;