aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/dsound.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-09-16 22:58:54 -0700
committerChris Robinson <[email protected]>2009-09-16 22:58:54 -0700
commitcbcaa54173bf6b14435adf3daf9feb2fa2e37d04 (patch)
treea56832a1ee9f96e72ac03a0424893714794cae4a /Alc/dsound.c
parent94e3fca7022c5c7f8147200ffdb3cda5ded62488 (diff)
Store the number of periods in the device instead of the buffer size
Also keep all the fields in sync
Diffstat (limited to 'Alc/dsound.c')
-rw-r--r--Alc/dsound.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/Alc/dsound.c b/Alc/dsound.c
index e4436258..959f55d2 100644
--- a/Alc/dsound.c
+++ b/Alc/dsound.c
@@ -51,8 +51,6 @@ static void *ds_handle;
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext);
-// Since DSound doesn't report the fragment size, emulate it
-static int num_frags;
typedef struct {
// DirectSound Playback Device
@@ -98,10 +96,10 @@ static ALuint DSoundProc(ALvoid *ptr)
aluHandleDisconnect(pDevice);
return 1;
}
- FragSize = DSBCaps.dwBufferBytes / num_frags;
FrameSize = aluChannelsFromFormat(pDevice->Format) *
aluBytesFromFormat(pDevice->Format);
+ FragSize = pDevice->UpdateSize * FrameSize;
IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &LastCursor, NULL);
while(!pData->killNow)
@@ -344,10 +342,13 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device)
if(SUCCEEDED(hr))
{
+ DWORD num_frags = GetConfigValueInt("dsound", "periods", device->NumUpdates);
+ if(num_frags < 2) num_frags = 2;
+
memset(&DSBDescription,0,sizeof(DSBUFFERDESC));
DSBDescription.dwSize=sizeof(DSBUFFERDESC);
DSBDescription.dwFlags=DSBCAPS_GLOBALFOCUS|DSBCAPS_GETCURRENTPOSITION2;
- DSBDescription.dwBufferBytes=(device->BufferSize/num_frags) * num_frags * frameSize;
+ DSBDescription.dwBufferBytes=device->UpdateSize * device->NumUpdates * frameSize;
DSBDescription.lpwfxFormat=&OutputType.Format;
hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL);
}
@@ -375,7 +376,6 @@ static ALCboolean DSoundResetPlayback(ALCdevice *device)
}
device->Format = format;
- device->UpdateSize = device->BufferSize/num_frags;
return ALC_TRUE;
}
@@ -505,9 +505,6 @@ void alcDSoundInit(BackendFuncs *FuncList)
LOAD_FUNC(DirectSoundCreate);
LOAD_FUNC(DirectSoundEnumerateA);
#undef LOAD_FUNC
-
- num_frags = GetConfigValueInt("dsound", "periods", 4);
- if(num_frags < 2) num_frags = 2;
}
void alcDSoundDeinit(void)