You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
2.6 KiB
131 lines
2.6 KiB
|
7 years ago
|
#include "miniwin/dsound.h"
|
||
|
7 years ago
|
|
||
|
|
#include <SDL.h>
|
||
|
|
|
||
|
|
#include "devilution.h"
|
||
|
|
#include "stubs.h"
|
||
|
7 years ago
|
|
||
|
7 years ago
|
namespace dvl {
|
||
|
|
|
||
|
|
ULONG DirectSound::Release()
|
||
|
7 years ago
|
{
|
||
|
|
Mix_CloseAudio();
|
||
|
|
return 0;
|
||
|
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSound::CreateSoundBuffer(LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOute)
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
if (pcDSBufferDesc->dwFlags != DVL_DSBCAPS_PRIMARYBUFFER) { // Creating primery buffer isn't needed and breaks Music
|
||
|
7 years ago
|
*ppDSBuffer = new DirectSoundBuffer();
|
||
|
|
}
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSound::GetCaps(LPDSCAPS pDSCaps)
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief SDL handels this for us when using Mix_PlayChannel(-1);
|
||
|
|
*/
|
||
|
7 years ago
|
HRESULT DirectSound::DuplicateSoundBuffer(LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate)
|
||
|
7 years ago
|
{
|
||
|
|
UNIMPLEMENTED();
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSound::SetCooperativeLevel(HWND hwnd, DWORD dwLevel)
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
|
///// DirectSoundBuffer /////
|
||
|
|
|
||
|
7 years ago
|
ULONG DirectSoundBuffer::Release()
|
||
|
7 years ago
|
{
|
||
|
|
Mix_FreeChunk(chunk);
|
||
|
|
|
||
|
|
return 0;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Only used for handeling duplicates
|
||
|
|
*/
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::GetStatus(LPDWORD pdwStatus)
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
return DVL_DSERR_INVALIDPARAM;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::Lock(DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
|
||
|
7 years ago
|
LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags)
|
||
|
|
{
|
||
|
|
*pdwAudioBytes1 = dwBytes;
|
||
|
|
*ppvAudioPtr1 = malloc(dwBytes);
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags)
|
||
|
7 years ago
|
{
|
||
|
|
int channel = Mix_PlayChannel(-1, chunk, 0);
|
||
|
|
if (channel == -1) {
|
||
|
|
SDL_Log("To few channels, skipping sound\n");
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
}
|
||
|
|
|
||
|
|
Mix_Volume(channel, volume);
|
||
|
|
int panned = 255 - 255 * abs(pan) / 10000;
|
||
|
|
Mix_SetPanning(channel, pan <= 0 ? 255 : panned, pan >= 0 ? 255 : panned);
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::SetFormat(LPCWAVEFORMATEX pcfxFormat)
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::SetVolume(LONG lVolume)
|
||
|
7 years ago
|
{
|
||
|
|
volume = MIX_MAX_VOLUME - MIX_MAX_VOLUME * lVolume / VOLUME_MIN;
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::SetPan(LONG lPan)
|
||
|
7 years ago
|
{
|
||
|
|
pan = lPan;
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::Stop()
|
||
|
7 years ago
|
{
|
||
|
|
for (int i = 1; i < Mix_AllocateChannels(-1); i++) {
|
||
|
|
if (Mix_GetChunk(i) != chunk) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
Mix_HaltChannel(i);
|
||
|
|
}
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::Unlock(LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2)
|
||
|
7 years ago
|
{
|
||
|
|
SDL_RWops *rw = SDL_RWFromConstMem(pvAudioPtr1, dwAudioBytes1);
|
||
|
|
chunk = Mix_LoadWAV_RW(rw, 1);
|
||
|
|
free(pvAudioPtr1);
|
||
|
|
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
|
|
||
|
7 years ago
|
HRESULT DirectSoundBuffer::Restore()
|
||
|
7 years ago
|
{
|
||
|
7 years ago
|
return DVL_DS_OK;
|
||
|
7 years ago
|
};
|
||
|
7 years ago
|
|
||
|
|
} // namespace dvl
|