mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-05-13 06:31:39 -04:00
Implement/match MxSoundManager::Create (#249)
* Implement/match MxSoundManager::Create * Fix offset
This commit is contained in:
parent
4c387d6d49
commit
89b3c5f8ae
2 changed files with 74 additions and 6 deletions
|
@ -20,7 +20,7 @@ MxSoundManager::~MxSoundManager()
|
||||||
// OFFSET: LEGO1 0x100ae830
|
// OFFSET: LEGO1 0x100ae830
|
||||||
void MxSoundManager::Init()
|
void MxSoundManager::Init()
|
||||||
{
|
{
|
||||||
m_unk30 = 0;
|
m_directSound = NULL;
|
||||||
m_dsBuffer = NULL;
|
m_dsBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,79 @@ void MxSoundManager::Destroy(MxBool p_fromDestructor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100ae8b0 STUB
|
// OFFSET: LEGO1 0x100ae8b0
|
||||||
MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
|
MxResult MxSoundManager::Create(MxU32 p_frequencyMS, MxBool p_createThread)
|
||||||
{
|
{
|
||||||
// TODO
|
MxResult status = FAILURE;
|
||||||
return FAILURE;
|
MxBool locked = FALSE;
|
||||||
|
|
||||||
|
if (MxAudioManager::InitPresenters() != SUCCESS)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
m_criticalSection.Enter();
|
||||||
|
locked = TRUE;
|
||||||
|
|
||||||
|
if (DirectSoundCreate(NULL, &m_directSound, NULL) != DS_OK)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (m_directSound->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DSSCL_PRIORITY) != DS_OK)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
DSBUFFERDESC desc;
|
||||||
|
memset(&desc, 0, sizeof(desc));
|
||||||
|
desc.dwSize = sizeof(desc);
|
||||||
|
|
||||||
|
if (MxOmni::IsSound3D())
|
||||||
|
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
|
||||||
|
else
|
||||||
|
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
|
||||||
|
|
||||||
|
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK) {
|
||||||
|
if (!MxOmni::IsSound3D())
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
MxOmni::SetSound3D(FALSE);
|
||||||
|
desc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
|
||||||
|
|
||||||
|
if (m_directSound->CreateSoundBuffer(&desc, &m_dsBuffer, NULL) != DS_OK)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
WAVEFORMATEX format;
|
||||||
|
|
||||||
|
format.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
|
|
||||||
|
if (MxOmni::IsSound3D())
|
||||||
|
format.nChannels = 2;
|
||||||
|
else
|
||||||
|
format.nChannels = 1;
|
||||||
|
|
||||||
|
format.nSamplesPerSec = 11025; // KHz
|
||||||
|
format.wBitsPerSample = 16;
|
||||||
|
format.nBlockAlign = format.nChannels * 2;
|
||||||
|
format.nAvgBytesPerSec = format.nBlockAlign * 11025;
|
||||||
|
format.cbSize = 0;
|
||||||
|
|
||||||
|
status = m_dsBuffer->SetFormat(&format);
|
||||||
|
|
||||||
|
if (p_createThread) {
|
||||||
|
m_thread = new MxTickleThread(this, p_frequencyMS);
|
||||||
|
|
||||||
|
if (!m_thread || m_thread->Start(0, 0) != SUCCESS)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
TickleManager()->RegisterClient(this, p_frequencyMS);
|
||||||
|
|
||||||
|
status = SUCCESS;
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (status != SUCCESS)
|
||||||
|
Destroy();
|
||||||
|
|
||||||
|
if (locked)
|
||||||
|
m_criticalSection.Leave();
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100aed10 STUB
|
// OFFSET: LEGO1 0x100aed10 STUB
|
||||||
|
|
|
@ -23,9 +23,9 @@ private:
|
||||||
void Init();
|
void Init();
|
||||||
void Destroy(MxBool p_fromDestructor);
|
void Destroy(MxBool p_fromDestructor);
|
||||||
|
|
||||||
undefined4 m_unk30;
|
LPDIRECTSOUND m_directSound; // 0x30
|
||||||
LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x34
|
LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x34
|
||||||
undefined m_unk35[4];
|
undefined m_unk38[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MXSOUNDMANAGER_H
|
#endif // MXSOUNDMANAGER_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue