Initialize the pwave array whenever we don't have a hardware buffer.
Always create the wineoss thread. Change the mmap ERR into a TRACE: there are normal circumstances where mmap will fail and we can deal with them.
This commit is contained in:
parent
95209b3937
commit
6bbce6cd22
|
@ -468,10 +468,6 @@ static ULONG WINAPI IDirectSoundImpl_Release(LPDIRECTSOUND8 iface) {
|
|||
DeleteCriticalSection(&This->mixlock);
|
||||
if (This->driver) {
|
||||
IDsDriver_Close(This->driver);
|
||||
} else {
|
||||
unsigned c;
|
||||
for (c=0; c<DS_HEL_FRAGS; c++)
|
||||
HeapFree(GetProcessHeap(),0,This->pwave[c]);
|
||||
}
|
||||
if (This->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) {
|
||||
waveOutClose(This->hwo);
|
||||
|
@ -683,28 +679,11 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
|
|||
if (drv) {
|
||||
IDsDriver_GetCaps(drv,&((*ippDS)->drvcaps));
|
||||
} else {
|
||||
unsigned c;
|
||||
|
||||
/* FIXME: We should check the device capabilities */
|
||||
(*ippDS)->drvcaps.dwFlags =
|
||||
DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO;
|
||||
if (ds_emuldriver)
|
||||
(*ippDS)->drvcaps.dwFlags |= DSCAPS_EMULDRIVER;
|
||||
|
||||
/* Allocate memory for HEL buffer headers */
|
||||
for (c=0; c<DS_HEL_FRAGS; c++) {
|
||||
(*ippDS)->pwave[c] = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEHDR));
|
||||
if (!(*ippDS)->pwave[c]) {
|
||||
/* Argh, out of memory */
|
||||
while (c--) {
|
||||
HeapFree(GetProcessHeap(),0,(*ippDS)->pwave[c]);
|
||||
waveOutClose((*ippDS)->hwo);
|
||||
HeapFree(GetProcessHeap(),0,*ippDS);
|
||||
*ippDS = NULL;
|
||||
return DSERR_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DSOUND_RecalcVolPan(&((*ippDS)->volpan));
|
||||
|
|
|
@ -176,6 +176,21 @@ HRESULT DSOUND_PrimaryCreate(IDirectSoundImpl *This)
|
|||
&(This->buflen),&(This->buffer),
|
||||
(LPVOID*)&(This->hwbuf));
|
||||
}
|
||||
if (!This->hwbuf) {
|
||||
/* Allocate memory for HEL buffer headers */
|
||||
unsigned c;
|
||||
for (c=0; c<DS_HEL_FRAGS; c++) {
|
||||
This->pwave[c] = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEHDR));
|
||||
if (!This->pwave[c]) {
|
||||
/* Argh, out of memory */
|
||||
while (c--) {
|
||||
HeapFree(GetProcessHeap(),0,This->pwave[c]);
|
||||
}
|
||||
err=DSERR_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (err == DS_OK)
|
||||
err = DSOUND_PrimaryOpen(This);
|
||||
if (err != DS_OK)
|
||||
|
@ -191,6 +206,11 @@ HRESULT DSOUND_PrimaryDestroy(IDirectSoundImpl *This)
|
|||
DSOUND_PrimaryClose(This);
|
||||
if (This->hwbuf) {
|
||||
IDsDriverBuffer_Release(This->hwbuf);
|
||||
} else {
|
||||
unsigned c;
|
||||
for (c=0; c<DS_HEL_FRAGS; c++) {
|
||||
HeapFree(GetProcessHeap(),0,This->pwave[c]);
|
||||
}
|
||||
}
|
||||
return DS_OK;
|
||||
}
|
||||
|
|
|
@ -1374,15 +1374,10 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
|||
|
||||
OSS_InitRingMessage(&wwo->msgRing);
|
||||
|
||||
if (!(dwFlags & WAVE_DIRECTSOUND)) {
|
||||
wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
|
||||
WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
|
||||
CloseHandle(wwo->hStartUpEvent);
|
||||
} else {
|
||||
wwo->hThread = INVALID_HANDLE_VALUE;
|
||||
wwo->dwThreadID = 0;
|
||||
}
|
||||
wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
|
||||
WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
|
||||
CloseHandle(wwo->hStartUpEvent);
|
||||
wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
|
||||
|
||||
TRACE("fd=%d fragmentSize=%ld\n",
|
||||
|
@ -1785,7 +1780,7 @@ static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb)
|
|||
wwo->mapping = mmap(NULL, wwo->maplen, PROT_WRITE, MAP_SHARED,
|
||||
wwo->ossdev->fd, 0);
|
||||
if (wwo->mapping == (LPBYTE)-1) {
|
||||
ERR("(%p): Could not map sound device for direct access (%s)\n", dsdb, strerror(errno));
|
||||
TRACE("(%p): Could not map sound device for direct access (%s)\n", dsdb, strerror(errno));
|
||||
return DSERR_GENERIC;
|
||||
}
|
||||
TRACE("(%p): sound device has been mapped for direct access at %p, size=%ld\n", dsdb, wwo->mapping, wwo->maplen);
|
||||
|
|
Loading…
Reference in New Issue