Make the DSound emulated fragment count configurable

This commit is contained in:
Chris Robinson
2008-11-21 07:48:03 -08:00
parent eefc18170d
commit 3dad17c263
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -39,8 +39,8 @@
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
// Since DSound doesn't report the fragment size, just assume 4 fragments
#define DS_FRAGS 4
// Since DSound doesn't report the fragment size, emulate it
static int num_frags;
typedef struct {
// DirectSound Playback Device
@@ -72,7 +72,7 @@ static ALuint DSoundProc(ALvoid *ptr)
DWORD avail;
HRESULT err;
BufferSize = pDevice->UpdateSize * DS_FRAGS *
BufferSize = pDevice->UpdateSize * num_frags *
aluBytesFromFormat(pDevice->Format) *
aluChannelsFromFormat(pDevice->Format);
@@ -258,7 +258,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign;
OutputType.Format.cbSize = 0;
device->UpdateSize /= DS_FRAGS;
device->UpdateSize /= num_frags;
}
if(OutputType.Format.nChannels > 2)
@@ -286,7 +286,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
DSBDescription.dwBufferBytes=device->UpdateSize * DS_FRAGS * frameSize;
DSBDescription.dwBufferBytes=device->UpdateSize * num_frags * frameSize;
DSBDescription.lpwfxFormat=&OutputType.Format;
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
}
@@ -411,6 +411,9 @@ void alcDSoundInit(BackendFuncs *FuncList)
*FuncList = DSoundFuncs;
num_frags = GetConfigValueInt("dsound", "periods", 4);
if(num_frags < 2) num_frags = 2;
hr = DirectSoundEnumerate(DSoundEnumDevices, &iter);
if(FAILED(hr))
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
+1 -1
View File
@@ -95,7 +95,7 @@ device = /dev/audio # Sets the device name for Solaris output. Default is
# /dev/audio
[dsound] # DirectSound backend stuff
# Nothing yet...
periods = 4 # Sets the number of updates for the output buffer. Default is 4
[winmm] # Windows Multimedia backend stuff
# Nothing yet...