forward headroom setter to voice
This commit is contained in:
parent
d7d1d781d8
commit
ab142abd69
|
@ -104,8 +104,7 @@ struct EmuDirectSoundBuffer
|
|||
REFERENCE_TIME Xb_rtPauseEx;
|
||||
REFERENCE_TIME Xb_rtStopEx;
|
||||
LONG Xb_Volume;
|
||||
LONG Xb_VolumeMixbin;
|
||||
DWORD Xb_dwHeadroom;
|
||||
LONG Xb_VolumeMixbin;
|
||||
X_DSENVOLOPEDESC Xb_EnvolopeDesc;
|
||||
X_DSVOICEPROPS Xb_VoiceProperties;
|
||||
DWORD Xb_Flags;
|
||||
|
@ -273,8 +272,7 @@ class X_CDirectSoundStream
|
|||
REFERENCE_TIME Xb_rtFlushEx;
|
||||
REFERENCE_TIME Xb_rtPauseEx;
|
||||
LONG Xb_Volume;
|
||||
LONG Xb_VolumeMixbin;
|
||||
DWORD Xb_dwHeadroom;
|
||||
LONG Xb_VolumeMixbin;
|
||||
X_DSENVOLOPEDESC Xb_EnvolopeDesc;
|
||||
X_DSVOICEPROPS Xb_VoiceProperties;
|
||||
DWORD Host_dwLastWritePos;
|
||||
|
|
|
@ -240,14 +240,13 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateBuffer)
|
|||
else {
|
||||
if (pdsbd->dwFlags & DSBCAPS_CTRL3D) {
|
||||
DSound3DBufferCreate(pEmuBuffer->EmuDirectSoundBuffer8, pEmuBuffer->EmuDirectSound3DBuffer8);
|
||||
pEmuBuffer->Xb_dwHeadroom = 0; // Default for 3D
|
||||
}
|
||||
|
||||
DSoundDebugMuteFlag(pEmuBuffer->X_BufferCacheSize, pEmuBuffer->EmuFlags);
|
||||
|
||||
// Pre-set volume to enforce silence if one of audio codec is disabled.
|
||||
HybridDirectSoundBuffer_SetVolume(pEmuBuffer->EmuDirectSoundBuffer8, 0L, pEmuBuffer->EmuFlags, nullptr,
|
||||
pEmuBuffer->Xb_VolumeMixbin, pEmuBuffer->Xb_dwHeadroom, pHybridBuffer->p_CDSVoice);
|
||||
HybridDirectSoundBuffer_SetVolume(pEmuBuffer->EmuDirectSoundBuffer8, 0L, pEmuBuffer->EmuFlags,
|
||||
pEmuBuffer->Xb_VolumeMixbin, pHybridBuffer->p_CDSVoice);
|
||||
|
||||
g_pDSoundBufferCache.push_back(pHybridBuffer);
|
||||
}
|
||||
|
@ -1001,7 +1000,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetHeadroom)
|
|||
LOG_FUNC_END;
|
||||
|
||||
EmuDirectSoundBuffer* pThis = pHybridThis->emuDSBuffer;
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetHeadroom(pThis->EmuDirectSoundBuffer8, dwHeadroom, pThis->Xb_dwHeadroom,
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetHeadroom(pThis->EmuDirectSoundBuffer8, dwHeadroom,
|
||||
pThis->Xb_Volume, pThis->Xb_VolumeMixbin, pThis->EmuFlags,
|
||||
pHybridThis->p_CDSVoice);
|
||||
|
||||
|
@ -1221,7 +1220,7 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetMixBinVolumes_8)
|
|||
|
||||
EmuDirectSoundBuffer* pThis = pHybridThis->emuDSBuffer;
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetMixBinVolumes_8(pThis->EmuDirectSoundBuffer8, pMixBins, pThis->Xb_VoiceProperties,
|
||||
pThis->EmuFlags, pThis->Xb_Volume, pThis->Xb_VolumeMixbin, pThis->Xb_dwHeadroom,
|
||||
pThis->EmuFlags, pThis->Xb_Volume, pThis->Xb_VolumeMixbin,
|
||||
pHybridThis->p_CDSVoice);
|
||||
|
||||
return hRet;
|
||||
|
@ -1507,8 +1506,8 @@ HRESULT WINAPI XTL::EMUPATCH(IDirectSoundBuffer_SetVolume)
|
|||
LOG_FUNC_END;
|
||||
|
||||
EmuDirectSoundBuffer* pThis = pHybridThis->emuDSBuffer;
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetVolume(pThis->EmuDirectSoundBuffer8, lVolume, pThis->EmuFlags, &pThis->Xb_Volume,
|
||||
pThis->Xb_VolumeMixbin, pThis->Xb_dwHeadroom, pHybridThis->p_CDSVoice);
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetVolume(pThis->EmuDirectSoundBuffer8, lVolume, pThis->EmuFlags,
|
||||
pThis->Xb_VolumeMixbin, pHybridThis->p_CDSVoice);
|
||||
|
||||
return hRet;
|
||||
}
|
||||
|
|
|
@ -394,7 +394,6 @@ static inline void DSound3DBufferCreate(LPDIRECTSOUNDBUFFER8 pDSBuffer, LPDIRECT
|
|||
pThis->Xb_rtPauseEx = 0LL; \
|
||||
pThis->Xb_Volume = 0L; \
|
||||
pThis->Xb_VolumeMixbin = 0L; \
|
||||
pThis->Xb_dwHeadroom = 600; /* default for 2D voice */ \
|
||||
pThis->Xb_EnvolopeDesc = { 0 }; \
|
||||
InitVoiceProperties(pThis->Xb_VoiceProperties); /* The rest will initialize in GeneratePCMFormat to GenerateMixBinDefault. */ \
|
||||
pThis->Xb_Flags = Xb_dwFlags;
|
||||
|
@ -1133,7 +1132,7 @@ static inline HRESULT HybridDirectSoundBuffer_SetFrequency(
|
|||
RETURN_RESULT_CHECK(hRet);
|
||||
}
|
||||
|
||||
static HRESULT HybridDirectSoundBuffer_SetVolume(LPDIRECTSOUNDBUFFER8, LONG, DWORD, LPLONG, LONG, DWORD, XTL::CDirectSoundVoice*);
|
||||
static HRESULT HybridDirectSoundBuffer_SetVolume(LPDIRECTSOUNDBUFFER8, LONG, DWORD, LONG, XTL::CDirectSoundVoice*);
|
||||
|
||||
//IDirectSoundStream
|
||||
//IDirectSoundBuffer
|
||||
|
@ -1141,7 +1140,6 @@ static HRESULT HybridDirectSoundBuffer_SetVolume(LPDIRECTSOUNDBUFFER8, LONG, DWO
|
|||
static inline HRESULT HybridDirectSoundBuffer_SetHeadroom(
|
||||
LPDIRECTSOUNDBUFFER8 pDSBuffer,
|
||||
DWORD dwHeadroom,
|
||||
DWORD &Xb_dwHeadroom,
|
||||
LONG Xb_volume,
|
||||
LONG Xb_volumeMixbin,
|
||||
DWORD dwEmuFlags,
|
||||
|
@ -1151,9 +1149,10 @@ static inline HRESULT HybridDirectSoundBuffer_SetHeadroom(
|
|||
if (dwHeadroom > 10000) {
|
||||
hRet = DSERR_INVALIDPARAM;
|
||||
} else {
|
||||
Xb_dwHeadroom = dwHeadroom;
|
||||
hRet = DS_OK;
|
||||
HybridDirectSoundBuffer_SetVolume(pDSBuffer, Xb_volume, dwEmuFlags, xbnullptr, Xb_volumeMixbin, dwHeadroom, Xb_Voice);
|
||||
Xb_Voice->SetHeadroom(Xb_Voice, dwHeadroom);
|
||||
uint32_t volume = Xb_Voice->GetVolume(Xb_Voice);
|
||||
pDSBuffer->SetVolume(volume);
|
||||
}
|
||||
|
||||
return DS_OK;
|
||||
|
@ -1245,7 +1244,6 @@ static inline HRESULT HybridDirectSoundBuffer_SetMixBinVolumes_8(
|
|||
DWORD EmuFlags,
|
||||
LONG Xb_volume,
|
||||
LONG &Xb_volumeMixBin,
|
||||
DWORD Xb_dwHeadroom,
|
||||
XTL::CDirectSoundVoice* Xb_Voice)
|
||||
{
|
||||
HRESULT hRet = DSERR_INVALIDPARAM;
|
||||
|
@ -1286,8 +1284,8 @@ static inline HRESULT HybridDirectSoundBuffer_SetMixBinVolumes_8(
|
|||
}
|
||||
if (counter > 0) {
|
||||
Xb_volumeMixBin = volume / (LONG)counter;
|
||||
hRet = HybridDirectSoundBuffer_SetVolume(pDSBuffer, Xb_volume, EmuFlags, nullptr,
|
||||
Xb_volumeMixBin, Xb_dwHeadroom, Xb_Voice);
|
||||
hRet = HybridDirectSoundBuffer_SetVolume(pDSBuffer, Xb_volume, EmuFlags,
|
||||
Xb_volumeMixBin, Xb_Voice);
|
||||
} else {
|
||||
hRet = DS_OK;
|
||||
}
|
||||
|
@ -1429,22 +1427,18 @@ static inline HRESULT HybridDirectSoundBuffer_SetVolume(
|
|||
LPDIRECTSOUNDBUFFER8 pDSBuffer,
|
||||
LONG lVolume,
|
||||
DWORD dwEmuFlags,
|
||||
LPLONG Xb_lpVolume,
|
||||
LONG Xb_volumeMixbin,
|
||||
DWORD Xb_dwHeadroom,
|
||||
XTL::CDirectSoundVoice* Xb_Voice)
|
||||
{
|
||||
// Preserve original volume
|
||||
if (Xb_lpVolume != xbnullptr) {
|
||||
*Xb_lpVolume = lVolume;
|
||||
}
|
||||
|
||||
#if 0 // TODO: Restore it once DSound work update comes up
|
||||
// For time being, this log is kept in case of something changed somewhere making a wrong input into the API.
|
||||
printf("DEBUG: SetVolume | lVolume = %ld | volumeMixbin = %ld | dwHeadroom = %8u\n", lVolume, Xb_volumeMixbin, Xb_dwHeadroom);
|
||||
#endif
|
||||
|
||||
lVolume += Xb_volumeMixbin - Xb_dwHeadroom;
|
||||
Xb_Voice->SetVolume(Xb_Voice, lVolume);
|
||||
lVolume = Xb_Voice->GetVolume(Xb_Voice);
|
||||
lVolume += Xb_volumeMixbin;
|
||||
|
||||
if ((dwEmuFlags & DSE_FLAG_PCM) > 0) {
|
||||
if (!g_XBAudio.codec_pcm) {
|
||||
|
|
|
@ -271,14 +271,13 @@ HRESULT WINAPI XTL::EMUPATCH(DirectSoundCreateStream)
|
|||
else {
|
||||
if (DSBufferDesc.dwFlags & DSBCAPS_CTRL3D) {
|
||||
DSound3DBufferCreate((*ppStream)->EmuDirectSoundBuffer8, (*ppStream)->EmuDirectSound3DBuffer8);
|
||||
(*ppStream)->Xb_dwHeadroom = 0; // Default for 3D
|
||||
}
|
||||
|
||||
DSoundDebugMuteFlag((*ppStream)->EmuBufferDesc.dwBufferBytes, (*ppStream)->EmuFlags);
|
||||
|
||||
// Pre-set volume to enforce silence if one of audio codec is disabled.
|
||||
HybridDirectSoundBuffer_SetVolume((*ppStream)->EmuDirectSoundBuffer8, 0L, (*ppStream)->EmuFlags, nullptr,
|
||||
(*ppStream)->Xb_VolumeMixbin, (*ppStream)->Xb_dwHeadroom, &(*ppStream)->Xb_Voice);
|
||||
HybridDirectSoundBuffer_SetVolume((*ppStream)->EmuDirectSoundBuffer8, 0L, (*ppStream)->EmuFlags,
|
||||
(*ppStream)->Xb_VolumeMixbin, &(*ppStream)->Xb_Voice);
|
||||
|
||||
g_pDSoundStreamCache.push_back(*ppStream);
|
||||
}
|
||||
|
@ -969,7 +968,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_SetHeadroom)
|
|||
LOG_FUNC_ARG(dwHeadroom)
|
||||
LOG_FUNC_END;
|
||||
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetHeadroom(pThis->EmuDirectSoundBuffer8, dwHeadroom, pThis->Xb_dwHeadroom,
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetHeadroom(pThis->EmuDirectSoundBuffer8, dwHeadroom,
|
||||
pThis->Xb_Volume, pThis->Xb_VolumeMixbin, pThis->EmuFlags, &pThis->Xb_Voice);
|
||||
|
||||
return hRet;
|
||||
|
@ -1210,7 +1209,7 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_SetMixBinVolumes_8)
|
|||
LOG_FUNC_END;
|
||||
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetMixBinVolumes_8(pThis->EmuDirectSoundBuffer8, pMixBins, pThis->Xb_VoiceProperties,
|
||||
pThis->EmuFlags, pThis->Xb_Volume, pThis->Xb_VolumeMixbin, pThis->Xb_dwHeadroom,
|
||||
pThis->EmuFlags, pThis->Xb_Volume, pThis->Xb_VolumeMixbin,
|
||||
&pThis->Xb_Voice);
|
||||
|
||||
return hRet;
|
||||
|
@ -1390,8 +1389,8 @@ HRESULT WINAPI XTL::EMUPATCH(CDirectSoundStream_SetVolume)
|
|||
LOG_FUNC_ARG(lVolume)
|
||||
LOG_FUNC_END;
|
||||
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetVolume(pThis->EmuDirectSoundBuffer8, lVolume, pThis->EmuFlags, &pThis->Xb_Volume,
|
||||
pThis->Xb_VolumeMixbin, pThis->Xb_dwHeadroom, &pThis->Xb_Voice);
|
||||
HRESULT hRet = HybridDirectSoundBuffer_SetVolume(pThis->EmuDirectSoundBuffer8, lVolume, pThis->EmuFlags,
|
||||
pThis->Xb_VolumeMixbin, &pThis->Xb_Voice);
|
||||
|
||||
return hRet;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue