just some minor cleanup (texdecoder, dsoundstream)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2394 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-02-23 19:47:58 +00:00
parent a09a3e08f1
commit 3b7875bf3f
3 changed files with 23 additions and 40 deletions

View File

@ -22,13 +22,12 @@
#include "TextureDecoder.h" #include "TextureDecoder.h"
#include "LookUpTables.h" #include "LookUpTables.h"
//Uncomment this to enable Texture Format ID overlays
#define OVERLAY_TEXFMT
#ifdef OVERLAY_TEXFMT
bool TexFmt_Overlay_Enable=false; bool TexFmt_Overlay_Enable=false;
bool TexFmt_Overlay_Center=false; bool TexFmt_Overlay_Center=false;
#endif
extern const char* texfmt[];
extern const unsigned char sfont_map[];
extern const unsigned char sfont_raw[][9*10];
// TRAM // TRAM
// STATE_TO_SAVE // STATE_TO_SAVE
@ -344,11 +343,7 @@ void decodeDXTBlock(u32 *dst, const DXTBlock *src, int pitch)
//TODO: to save memory, don't blindly convert everything to argb8888 //TODO: to save memory, don't blindly convert everything to argb8888
//also ARGB order needs to be swapped later, to accommodate modern hardware better //also ARGB order needs to be swapped later, to accommodate modern hardware better
//need to add DXT support too //need to add DXT support too
#ifdef OVERLAY_TEXFMT
PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt) PC_TexFormat TexDecoder_Decode_real(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt)
#else
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt)
#endif
{ {
switch (texformat) switch (texformat)
{ {
@ -491,15 +486,9 @@ void TexDecoder_SetTexFmtOverlayOptions(bool enable, bool center)
#endif #endif
} }
#ifdef OVERLAY_TEXFMT
extern const char* texfmt[];
extern const unsigned char sfont_map[];
extern const unsigned char sfont_raw[][9*10];
PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt) PC_TexFormat TexDecoder_Decode(u8 *dst, const u8 *src, int width, int height, int texformat, int tlutaddr, int tlutfmt)
{ {
PC_TexFormat retval = TexDecoder_Decode_real(dst,src,width,height,texformat,tlutaddr,tlutfmt); PC_TexFormat retval = TexDecoder_Decode_real(dst,src,width,height,texformat,tlutaddr,tlutfmt);
if ((!TexFmt_Overlay_Enable)||(retval==PC_TEX_FMT_NONE)) if ((!TexFmt_Overlay_Enable)||(retval==PC_TEX_FMT_NONE))
return retval; return retval;
@ -1309,5 +1298,3 @@ const unsigned char sfont_raw[][9*10] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x78, 0x78, 0x78,
}, },
}; };
#endif

View File

@ -106,7 +106,7 @@ void DSound::SoundLoop()
while (!threadData) while (!threadData)
{ {
// No blocking inside the csection // No blocking inside the csection
soundCriticalSection->Enter(); soundCriticalSection.Enter();
dsBuffer->GetCurrentPosition((DWORD*)&currentPos, 0); dsBuffer->GetCurrentPosition((DWORD*)&currentPos, 0);
int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos)); int numBytesToRender = FIX128(ModBufferSize(currentPos - lastPos));
if (numBytesToRender >= 256) if (numBytesToRender >= 256)
@ -120,8 +120,10 @@ void DSound::SoundLoop()
lastPos = currentPos; lastPos = currentPos;
} }
soundCriticalSection->Leave(); soundCriticalSection.Leave();
soundSyncEvent->Wait(); if (threadData)
break;
soundSyncEvent.Wait();
} }
dsBuffer->Stop(); dsBuffer->Stop();
@ -129,10 +131,7 @@ void DSound::SoundLoop()
bool DSound::Start() bool DSound::Start()
{ {
soundSyncEvent = new Common::Event(); soundSyncEvent.Init();
soundSyncEvent->Init();
soundCriticalSection = new Common::CriticalSection();
if (FAILED(DirectSoundCreate8(0, &ds, 0))) if (FAILED(DirectSoundCreate8(0, &ds, 0)))
return false; return false;
if (hWnd) if (hWnd)
@ -152,24 +151,21 @@ bool DSound::Start()
void DSound::Update() void DSound::Update()
{ {
soundSyncEvent->Set(); soundSyncEvent.Set();
} }
void DSound::Stop() void DSound::Stop()
{ {
soundCriticalSection->Enter(); soundCriticalSection.Enter();
threadData = 1; threadData = 1;
// kick the thread if it's waiting // kick the thread if it's waiting
soundSyncEvent->Set(); soundSyncEvent.Set();
soundCriticalSection->Leave(); soundCriticalSection.Leave();
delete soundCriticalSection;
delete thread; delete thread;
dsBuffer->Release(); dsBuffer->Release();
ds->Release(); ds->Release();
soundSyncEvent->Shutdown(); soundSyncEvent.Shutdown();
delete soundSyncEvent;
soundSyncEvent = NULL;
thread = NULL; thread = NULL;
} }

View File

@ -36,8 +36,8 @@ class DSound : public SoundStream
{ {
#ifdef _WIN32 #ifdef _WIN32
Common::Thread *thread; Common::Thread *thread;
Common::CriticalSection *soundCriticalSection; Common::CriticalSection soundCriticalSection;
Common::Event *soundSyncEvent; Common::Event soundSyncEvent;
void *hWnd; void *hWnd;
IDirectSound8* ds; IDirectSound8* ds;