REFACTOR : soundcore to use logging macros

This commit is contained in:
Aaron Culliney 2015-02-17 16:14:25 -08:00
parent 0470cb8907
commit 815b6f5a7c
3 changed files with 24 additions and 40 deletions

View File

@ -653,7 +653,7 @@ static void SSI263_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
{
case SSI_DURPHON:
#if LOG_SSI263
if(g_fh) fprintf(g_fh, "DUR = 0x%02X, PHON = 0x%02X\n\n", nValue>>6, nValue&PHONEME_MASK);
LOG("DUR = 0x%02X, PHON = 0x%02X\n\n", nValue>>6, nValue&PHONEME_MASK);
#endif
// Datasheet is not clear, but a write to DURPHON must clear the IRQ
@ -689,19 +689,19 @@ static void SSI263_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
break;
case SSI_INFLECT:
#if LOG_SSI263
if(g_fh) fprintf(g_fh, "INF = 0x%02X\n", nValue);
LOG("INF = 0x%02X\n", nValue);
#endif
pMB->SpeechChip.Inflection = nValue;
break;
case SSI_RATEINF:
#if LOG_SSI263
if(g_fh) fprintf(g_fh, "RATE = 0x%02X, INF = 0x%02X\n", nValue>>4, nValue&0x0F);
LOG("RATE = 0x%02X, INF = 0x%02X\n", nValue>>4, nValue&0x0F);
#endif
pMB->SpeechChip.RateInflection = nValue;
break;
case SSI_CTTRAMP:
#if LOG_SSI263
if(g_fh) fprintf(g_fh, "CTRL = %d, ART = 0x%02X, AMP=0x%02X\n", nValue>>7, (nValue&ARTICULATION_MASK)>>4, nValue&AMPLITUDE_MASK);
LOG("CTRL = %d, ART = 0x%02X, AMP=0x%02X\n", nValue>>7, (nValue&ARTICULATION_MASK)>>4, nValue&AMPLITUDE_MASK);
#endif
if((pMB->SpeechChip.CtrlArtAmp & CONTROL_MASK) && !(nValue & CONTROL_MASK)) // H->L
pMB->SpeechChip.CurrentMode = pMB->SpeechChip.DurationPhonome & DURATION_MODE_MASK;
@ -709,7 +709,7 @@ static void SSI263_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
break;
case SSI_FILFREQ:
#if LOG_SSI263
if(g_fh) fprintf(g_fh, "FFREQ = 0x%02X\n", nValue);
LOG("FFREQ = 0x%02X\n", nValue);
#endif
pMB->SpeechChip.FilterFreq = nValue;
break;
@ -1297,7 +1297,7 @@ static bool MB_DSInit()
LogFileOutput("MB_DSInit: DSGetSoundBuffer(), hr=0x%08X\n", (unsigned int)hr);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "MB: DSGetSoundBuffer failed (%08X)\n",(unsigned int)hr);
LOG("MB: DSGetSoundBuffer failed (%08X)\n",(unsigned int)hr);
return false;
}
@ -1363,7 +1363,7 @@ static bool MB_DSInit()
if((g_hSSI263Event[0] == NULL) || (g_hSSI263Event[1] == NULL))
{
if(g_fh) fprintf(g_fh, "SSI263: CreateEvent failed\n");
LOG("SSI263: CreateEvent failed\n");
return false;
}
#endif
@ -1394,7 +1394,7 @@ static bool MB_DSInit()
LogFileOutput("MB_DSInit: (%02d) DSGetSoundBuffer(), hr=0x%08X\n", i, (unsigned int)hr);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "SSI263: DSGetSoundBuffer failed (%08X)\n",(unsigned int)hr);
LOG("SSI263: DSGetSoundBuffer failed (%08X)\n",(unsigned int)hr);
return false;
}
@ -1406,7 +1406,7 @@ static bool MB_DSInit()
//LogFileOutput("MB_DSInit: (%02d) DSGetLock(), res=%d\n", i, hr ? 1 : 0); // WARNING: Lock acquired && doing heavy-weight logging
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "SSI263: DSGetLock failed (%08X)\n",(unsigned int)hr);
LOG("SSI263: DSGetLock failed (%08X)\n",(unsigned int)hr);
return false;
}
@ -1435,7 +1435,7 @@ static bool MB_DSInit()
//LogFileOutput("MB_DSInit: (%02d) QueryInterface(), hr=0x%08X\n", i, hr); // WARNING: Lock acquired && doing heavy-weight logging
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "SSI263: QueryInterface failed (%08X)\n",hr);
LOG("SSI263: QueryInterface failed (%08X)\n",hr);
return false;
}
@ -1449,7 +1449,7 @@ static bool MB_DSInit()
//LogFileOutput("MB_DSInit: (%02d) SetNotificationPositions(), hr=0x%08X\n", i, hr); // WARNING: Lock acquired && doing heavy-weight logging
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "SSI263: SetNotifyPos failed (%08X)\n",hr);
LOG("SSI263: SetNotifyPos failed (%08X)\n",hr);
return false;
}
#endif
@ -1462,7 +1462,7 @@ static bool MB_DSInit()
LogFileOutput("MB_DSInit: (%02d) Unlock(),hr=0x%08X\n", i, (unsigned int)hr);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "SSI263: DSUnlock failed (%08X)\n",(unsigned int)hr);
LOG("SSI263: DSUnlock failed (%08X)\n",(unsigned int)hr);
return false;
}

View File

@ -54,12 +54,6 @@ static VOICE* g_pSpeakerVoice = NULL;
bool g_bDSAvailable = false;
bool g_bDisableDirectSound = false;
FILE *g_fh = NULL;
__attribute__((constructor))
static void _init_soundcore() {
g_fh = error_log;
}
//-----------------------------------------------------------------------------
@ -183,13 +177,13 @@ bool DSZeroVoiceBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSize)
HRESULT hr = Voice->lpDSBvoice->Stop(Voice->lpDSBvoice->_this);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSStop failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSStop failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
hr = !DSGetLock(Voice->lpDSBvoice, 0, 0, &pDSLockedBuffer, &dwDSLockedBufferSize, NULL, &argX);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSGetLock failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSGetLock failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
@ -199,14 +193,14 @@ bool DSZeroVoiceBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSize)
hr = Voice->lpDSBvoice->Unlock(Voice->lpDSBvoice->_this, (void*)pDSLockedBuffer, dwDSLockedBufferSize, NULL, argX);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSUnlock failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSUnlock failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
hr = Voice->lpDSBvoice->Play(Voice->lpDSBvoice->_this,0,0,0);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSPlay failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSPlay failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
@ -228,7 +222,7 @@ bool DSZeroVoiceWritableBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSiz
hr = !hr;
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSGetLock failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSGetLock failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
@ -240,7 +234,7 @@ bool DSZeroVoiceWritableBuffer(PVOICE Voice, char* pszDevName, DWORD dwBufferSiz
(void*)pDSLockedBuffer1, dwDSLockedBufferSize1);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "%s: DSUnlock failed (%08X)\n",pszDevName,(unsigned int)hr);
LOG("%s: DSUnlock failed (%08X)\n",pszDevName,(unsigned int)hr);
return false;
}
@ -253,10 +247,6 @@ static UINT g_uDSInitRefCount = 0;
bool DSInit()
{
if (!g_fh)
{
g_fh = stderr;
}
if(g_bDSAvailable)
{
g_uDSInitRefCount++;
@ -279,14 +269,11 @@ bool DSInit()
HRESULT hr = (num_sound_devices <= 0);
if(FAILED(hr))
{
if(g_fh) fprintf(g_fh, "DSEnumerate failed (%08X)\n",(unsigned int)hr);
LOG("DSEnumerate failed (%08X)\n",(unsigned int)hr);
return false;
}
if(g_fh)
{
fprintf(g_fh, "Number of sound devices = %ld\n",num_sound_devices);
}
LOG("Number of sound devices = %ld\n",num_sound_devices);
bool bCreatedOK = false;
for(int x=0; x<num_sound_devices; x++)
@ -302,11 +289,11 @@ bool DSInit()
break;
}
if(g_fh) fprintf(g_fh, "DSCreate failed for sound device #%d (%08X)\n",x,(unsigned int)hr);
LOG("DSCreate failed for sound device #%d (%08X)\n",x,(unsigned int)hr);
}
if(!bCreatedOK)
{
if(g_fh) fprintf(g_fh, "DSCreate failed for all sound devices\n");
LOG("DSCreate failed for all sound devices\n");
return false;
}
@ -364,7 +351,7 @@ int SoundCore_GetErrorInc()
void SoundCore_SetErrorInc(const int nErrorInc)
{
g_nErrorInc = nErrorInc < g_nErrorMax ? nErrorInc : g_nErrorMax;
if(g_fh) fprintf(g_fh, "Speaker/MB Error Inc = %d\n", g_nErrorInc);
LOG("Speaker/MB Error Inc = %d\n", g_nErrorInc);
}
int SoundCore_GetErrorMax()
@ -375,7 +362,6 @@ int SoundCore_GetErrorMax()
void SoundCore_SetErrorMax(const int nErrorMax)
{
g_nErrorMax = nErrorMax < MAX_SAMPLES ? nErrorMax : MAX_SAMPLES;
if(g_fh) fprintf(g_fh, "Speaker/MB Error Max = %d\n", g_nErrorMax);
LOG("Speaker/MB Error Max = %d\n", g_nErrorMax);
}

View File

@ -86,8 +86,6 @@ typedef void* HANDLE;
#define FALSE false
#endif
extern FILE *g_fh;
#define _strdup strdup
#define _ASSERT assert
#define Sleep(x) usleep(x)