Commit 6bbce6cd authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

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.
parent 95209b39
...@@ -468,10 +468,6 @@ static ULONG WINAPI IDirectSoundImpl_Release(LPDIRECTSOUND8 iface) { ...@@ -468,10 +468,6 @@ static ULONG WINAPI IDirectSoundImpl_Release(LPDIRECTSOUND8 iface) {
DeleteCriticalSection(&This->mixlock); DeleteCriticalSection(&This->mixlock);
if (This->driver) { if (This->driver) {
IDsDriver_Close(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) { if (This->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) {
waveOutClose(This->hwo); waveOutClose(This->hwo);
...@@ -683,28 +679,11 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown * ...@@ -683,28 +679,11 @@ HRESULT WINAPI DirectSoundCreate8(REFGUID lpGUID,LPDIRECTSOUND8 *ppDS,IUnknown *
if (drv) { if (drv) {
IDsDriver_GetCaps(drv,&((*ippDS)->drvcaps)); IDsDriver_GetCaps(drv,&((*ippDS)->drvcaps));
} else { } else {
unsigned c;
/* FIXME: We should check the device capabilities */ /* FIXME: We should check the device capabilities */
(*ippDS)->drvcaps.dwFlags = (*ippDS)->drvcaps.dwFlags =
DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO; DSCAPS_PRIMARY16BIT | DSCAPS_PRIMARYSTEREO;
if (ds_emuldriver) if (ds_emuldriver)
(*ippDS)->drvcaps.dwFlags |= DSCAPS_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)); DSOUND_RecalcVolPan(&((*ippDS)->volpan));
......
...@@ -176,6 +176,21 @@ HRESULT DSOUND_PrimaryCreate(IDirectSoundImpl *This) ...@@ -176,6 +176,21 @@ HRESULT DSOUND_PrimaryCreate(IDirectSoundImpl *This)
&(This->buflen),&(This->buffer), &(This->buflen),&(This->buffer),
(LPVOID*)&(This->hwbuf)); (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) if (err == DS_OK)
err = DSOUND_PrimaryOpen(This); err = DSOUND_PrimaryOpen(This);
if (err != DS_OK) if (err != DS_OK)
...@@ -191,6 +206,11 @@ HRESULT DSOUND_PrimaryDestroy(IDirectSoundImpl *This) ...@@ -191,6 +206,11 @@ HRESULT DSOUND_PrimaryDestroy(IDirectSoundImpl *This)
DSOUND_PrimaryClose(This); DSOUND_PrimaryClose(This);
if (This->hwbuf) { if (This->hwbuf) {
IDsDriverBuffer_Release(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; return DS_OK;
} }
......
...@@ -1374,15 +1374,10 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags) ...@@ -1374,15 +1374,10 @@ static DWORD wodOpen(WORD wDevID, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
OSS_InitRingMessage(&wwo->msgRing); OSS_InitRingMessage(&wwo->msgRing);
if (!(dwFlags & WAVE_DIRECTSOUND)) { wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
wwo->hStartUpEvent = CreateEventA(NULL, FALSE, FALSE, NULL); wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID));
wwo->hThread = CreateThread(NULL, 0, wodPlayer, (LPVOID)(DWORD)wDevID, 0, &(wwo->dwThreadID)); WaitForSingleObject(wwo->hStartUpEvent, INFINITE);
WaitForSingleObject(wwo->hStartUpEvent, INFINITE); CloseHandle(wwo->hStartUpEvent);
CloseHandle(wwo->hStartUpEvent);
} else {
wwo->hThread = INVALID_HANDLE_VALUE;
wwo->dwThreadID = 0;
}
wwo->hStartUpEvent = INVALID_HANDLE_VALUE; wwo->hStartUpEvent = INVALID_HANDLE_VALUE;
TRACE("fd=%d fragmentSize=%ld\n", TRACE("fd=%d fragmentSize=%ld\n",
...@@ -1785,7 +1780,7 @@ static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb) ...@@ -1785,7 +1780,7 @@ static HRESULT DSDB_MapPrimary(IDsDriverBufferImpl *dsdb)
wwo->mapping = mmap(NULL, wwo->maplen, PROT_WRITE, MAP_SHARED, wwo->mapping = mmap(NULL, wwo->maplen, PROT_WRITE, MAP_SHARED,
wwo->ossdev->fd, 0); wwo->ossdev->fd, 0);
if (wwo->mapping == (LPBYTE)-1) { 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; return DSERR_GENERIC;
} }
TRACE("(%p): sound device has been mapped for direct access at %p, size=%ld\n", dsdb, wwo->mapping, wwo->maplen); TRACE("(%p): sound device has been mapped for direct access at %p, size=%ld\n", dsdb, wwo->mapping, wwo->maplen);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment