mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 19:20:38 +00:00
Tweak DirectSound error
git-svn-id: https://svn.eduke32.com/eduke32@7910 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
24aba0220d
commit
2307160c4a
2 changed files with 19 additions and 22 deletions
|
@ -100,17 +100,18 @@ static void FillBuffer(int32_t bufnum)
|
||||||
{
|
{
|
||||||
HRESULT err = IDirectSoundBuffer_Lock(lpdsbsec, notifyPositions[bufnum].dwOffset, notifyPositions[1].dwOffset,
|
HRESULT err = IDirectSoundBuffer_Lock(lpdsbsec, notifyPositions[bufnum].dwOffset, notifyPositions[1].dwOffset,
|
||||||
&ptr, &remaining, &ptr2, &remaining2, 0);
|
&ptr, &remaining, &ptr2, &remaining2, 0);
|
||||||
if (FAILED(err))
|
|
||||||
|
if (EDUKE32_PREDICT_FALSE(FAILED(err)))
|
||||||
{
|
{
|
||||||
if (err == DSERR_BUFFERLOST)
|
if (err == DSERR_BUFFERLOST)
|
||||||
{
|
{
|
||||||
if (FAILED(err = IDirectSoundBuffer_Restore(lpdsbsec)))
|
if (FAILED(err = IDirectSoundBuffer_Restore(lpdsbsec)))
|
||||||
return;
|
goto fail;
|
||||||
|
|
||||||
if (retries-- > 0)
|
if (retries-- > 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
fail:
|
||||||
if (MV_Printf)
|
if (MV_Printf)
|
||||||
MV_Printf("DirectSound FillBuffer: err %x\n", (uint32_t)err);
|
MV_Printf("DirectSound FillBuffer: err %x\n", (uint32_t)err);
|
||||||
|
|
||||||
|
@ -201,13 +202,12 @@ static void TeardownDSound(HRESULT err)
|
||||||
IDirectSound_Release(lpds), lpds = NULL;
|
IDirectSound_Release(lpds), lpds = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DIRECTSOUND_ERROR(err, code) \
|
static int DirectSound_Error(HRESULT err, int code)
|
||||||
do \
|
{
|
||||||
{ \
|
TeardownDSound(err);
|
||||||
TeardownDSound(err); \
|
ErrorCode = code;
|
||||||
ErrorCode = code; \
|
return DSErr_Error;
|
||||||
return DSErr_Error; \
|
}
|
||||||
} while (0)
|
|
||||||
|
|
||||||
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
|
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
|
||||||
{
|
{
|
||||||
|
@ -219,16 +219,16 @@ int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * i
|
||||||
DirectSoundDrv_PCM_Shutdown();
|
DirectSoundDrv_PCM_Shutdown();
|
||||||
|
|
||||||
if (FAILED(err = DirectSoundCreate(0, &lpds, 0)))
|
if (FAILED(err = DirectSoundCreate(0, &lpds, 0)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_DirectSoundCreate);
|
return DirectSound_Error(err, DSErr_DirectSoundCreate);
|
||||||
|
|
||||||
if (FAILED(err = IDirectSound_SetCooperativeLevel(lpds, (HWND) initdata, DSSCL_PRIORITY)))
|
if (FAILED(err = IDirectSound_SetCooperativeLevel(lpds, (HWND) initdata, DSSCL_PRIORITY)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_SetCooperativeLevel);
|
return DirectSound_Error(err, DSErr_SetCooperativeLevel);
|
||||||
|
|
||||||
bufdesc.dwSize = sizeof(DSBUFFERDESC);
|
bufdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
bufdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_PRIMARYBUFFER | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS;
|
bufdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_PRIMARYBUFFER | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS;
|
||||||
|
|
||||||
if (FAILED(err = IDirectSound_CreateSoundBuffer(lpds, &bufdesc, &lpdsbprimary, 0)))
|
if (FAILED(err = IDirectSound_CreateSoundBuffer(lpds, &bufdesc, &lpdsbprimary, 0)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_CreateSoundBuffer);
|
return DirectSound_Error(err, DSErr_CreateSoundBuffer);
|
||||||
|
|
||||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
wfex.nChannels = *numchannels;
|
wfex.nChannels = *numchannels;
|
||||||
|
@ -238,7 +238,7 @@ int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * i
|
||||||
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
|
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
|
||||||
|
|
||||||
if (FAILED(err = IDirectSoundBuffer_SetFormat(lpdsbprimary, &wfex)))
|
if (FAILED(err = IDirectSoundBuffer_SetFormat(lpdsbprimary, &wfex)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_SetFormat);
|
return DirectSound_Error(err, DSErr_SetFormat);
|
||||||
|
|
||||||
bufdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS;
|
bufdesc.dwFlags = DSBCAPS_LOCSOFTWARE | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STICKYFOCUS;
|
||||||
|
|
||||||
|
@ -246,27 +246,27 @@ int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * i
|
||||||
bufdesc.lpwfxFormat = &wfex;
|
bufdesc.lpwfxFormat = &wfex;
|
||||||
|
|
||||||
if (FAILED(err = IDirectSound_CreateSoundBuffer(lpds, &bufdesc, &lpdsbsec, 0)))
|
if (FAILED(err = IDirectSound_CreateSoundBuffer(lpds, &bufdesc, &lpdsbsec, 0)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_CreateSoundBufferSecondary);
|
return DirectSound_Error(err, DSErr_CreateSoundBufferSecondary);
|
||||||
|
|
||||||
if (FAILED(err = IDirectSoundBuffer_QueryInterface(lpdsbsec, &IID_IDirectSoundNotify, (LPVOID *)&lpdsnotify)))
|
if (FAILED(err = IDirectSoundBuffer_QueryInterface(lpdsbsec, &IID_IDirectSoundNotify, (LPVOID *)&lpdsnotify)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_Notify);
|
return DirectSound_Error(err, DSErr_Notify);
|
||||||
|
|
||||||
for (int i = 0; i < MIXBUFFERPOSITIONS; i++)
|
for (int i = 0; i < MIXBUFFERPOSITIONS; i++)
|
||||||
{
|
{
|
||||||
notifyPositions[i].dwOffset = (bufdesc.dwBufferBytes/MIXBUFFERPOSITIONS)*i;
|
notifyPositions[i].dwOffset = (bufdesc.dwBufferBytes/MIXBUFFERPOSITIONS)*i;
|
||||||
notifyPositions[i].hEventNotify = CreateEvent(NULL, FALSE, FALSE, NULL);
|
notifyPositions[i].hEventNotify = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
if (!notifyPositions[i].hEventNotify)
|
if (!notifyPositions[i].hEventNotify)
|
||||||
DIRECTSOUND_ERROR(DS_OK, DSErr_NotifyEvents);
|
return DirectSound_Error(DS_OK, DSErr_NotifyEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyPositions[MIXBUFFERPOSITIONS].dwOffset = DSBPN_OFFSETSTOP;
|
notifyPositions[MIXBUFFERPOSITIONS].dwOffset = DSBPN_OFFSETSTOP;
|
||||||
notifyPositions[MIXBUFFERPOSITIONS].hEventNotify = CreateEvent(NULL, FALSE, FALSE, NULL);
|
notifyPositions[MIXBUFFERPOSITIONS].hEventNotify = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||||
|
|
||||||
if (FAILED(err = IDirectSoundNotify_SetNotificationPositions(lpdsnotify, MIXBUFFERPOSITIONS+1, notifyPositions)))
|
if (FAILED(err = IDirectSoundNotify_SetNotificationPositions(lpdsnotify, MIXBUFFERPOSITIONS+1, notifyPositions)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_SetNotificationPositions);
|
return DirectSound_Error(err, DSErr_SetNotificationPositions);
|
||||||
|
|
||||||
if (FAILED(err = IDirectSoundBuffer_Play(lpdsbprimary, 0, 0, DSBPLAY_LOOPING)))
|
if (FAILED(err = IDirectSoundBuffer_Play(lpdsbprimary, 0, 0, DSBPLAY_LOOPING)))
|
||||||
DIRECTSOUND_ERROR(err, DSErr_Play);
|
return DirectSound_Error(err, DSErr_Play);
|
||||||
|
|
||||||
mutex_init(&mutex);
|
mutex_init(&mutex);
|
||||||
|
|
||||||
|
@ -275,8 +275,6 @@ int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * i
|
||||||
return DSErr_Ok;
|
return DSErr_Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DIRECTSOUND_ERROR
|
|
||||||
|
|
||||||
void DirectSoundDrv_PCM_Shutdown(void)
|
void DirectSoundDrv_PCM_Shutdown(void)
|
||||||
{
|
{
|
||||||
if (!Initialised)
|
if (!Initialised)
|
||||||
|
|
|
@ -38,7 +38,6 @@ enum
|
||||||
DSErr_Play,
|
DSErr_Play,
|
||||||
DSErr_PlaySecondary,
|
DSErr_PlaySecondary,
|
||||||
DSErr_CreateThread,
|
DSErr_CreateThread,
|
||||||
DSErr_CreateMutex
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t DirectSoundDrv_GetError(void);
|
int32_t DirectSoundDrv_GetError(void);
|
||||||
|
|
Loading…
Reference in a new issue