Allocate necessary dsound buffers for standard audio paths and enable

retrieval of their interfaces via GetObjectInPath.
Fix and clean dsound and dmusics objects allocation when initializing
the performance object.
Some stubs improvements.
This commit is contained in:
Christian Costa 2003-06-16 20:26:50 +00:00 committed by Alexandre Julliard
parent e10a0fd375
commit 677b37cbd8
4 changed files with 137 additions and 42 deletions

View File

@ -303,6 +303,9 @@ HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOAD
return S_OK;
}
extern ICOM_VTABLE(IDirectMusicSegment) DirectMusicSegment_Vtbl;
extern ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl;
HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface,
REFGUID rguidClassID,
REFIID iidInterfaceID,
@ -320,6 +323,24 @@ HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8
} else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicContainer)) {
FIXME("wanted 'con'\n");
}
if (IsEqualGUID(iidInterfaceID,&IID_IDirectMusicSegment)) {
IDirectMusicSegmentImpl* segment;
segment = (IDirectMusicSegmentImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectMusicImpl));
segment->lpVtbl = &DirectMusicSegment_Vtbl;
segment->ref = 1;
*ppObject = segment;
return S_OK;
} else if (IsEqualGUID(iidInterfaceID,&IID_IDirectMusicSegment8)) {
IDirectMusicSegmentImpl* segment;
segment = (IDirectMusicSegmentImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectMusicImpl));
segment->lpVtbl = &DirectMusicSegment8_Vtbl;
segment->ref = 1;
*ppObject = segment;
return S_OK;
} else {
FIXME("bad iid\n");
}
/** for now alway return not supported for avoiding futur crash */
return DMUS_E_LOADER_FORMATNOTSUPPORTED;

View File

@ -216,6 +216,32 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH
FIXME("(%p, %ld, %ld, %ld, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_guid(guidObject), dwIndex, debugstr_guid(iidInterface), ppObject);
switch (dwStage) {
case DMUS_PATH_BUFFER:
{
if (IsEqualGUID(iidInterface,&IID_IDirectSoundBuffer8)) {
IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSoundBuffer8, ppObject);
TRACE("returning %p\n",*ppObject);
return S_OK;
} else if (IsEqualGUID(iidInterface,&IID_IDirectSound3DBuffer)) {
IDirectSoundBuffer8_QueryInterface(This->buffer, &IID_IDirectSound3DBuffer, ppObject);
TRACE("returning %p\n",*ppObject);
return S_OK;
} else {
FIXME("Bad iid\n");
}
}
break;
case DMUS_PATH_PRIMARY_BUFFER: {
if (IsEqualGUID(iidInterface,&IID_IDirectSound3DListener)) {
IDirectSoundBuffer8_QueryInterface(This->primary, &IID_IDirectSound3DListener, ppObject);
return S_OK;
}else {
FIXME("bad iid...\n");
}
}
break;
case DMUS_PATH_AUDIOPATH_GRAPH:
{
if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) {
@ -257,7 +283,7 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH
pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));
pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
pGraph->ref = 1;
IDirectMusicPerformanceImpl_SetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, pGraph);
IDirectMusicPerformanceImpl_SetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, (IDirectMusicGraph*) pGraph);
/* we need release as SetGraph do an AddRef */
IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph);
pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;

View File

@ -557,37 +557,31 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac
FIXME("(iface = %p, dmusic = %p, dsound = %p, hwnd = %p): forward to IDirectMusicPerformanceImpl::Init\n", This, ppDirectMusic, pDirectSound, hWnd);
if (NULL != ppDirectMusic) {
if (This->dmusic || This->dsound)
return DMUS_E_ALREADY_INITED;
if (NULL != ppDirectMusic && NULL != *ppDirectMusic) {
/* app creates it's own dmusic object and gives it to performance */
if (NULL != *ppDirectMusic) {
if (NULL != This->dmusic) {
}
This->dmusic = (IDirectMusic*) *ppDirectMusic;
IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic);
} else { /* app allows the performance to initialise itfself and needs a pointer to object*/
/* maybe IID_IDirectMusic8 must be used here */
DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
*ppDirectMusic = (LPDIRECTMUSIC) This->dmusic;
if (NULL != *ppDirectMusic) {
IDirectMusic_AddRef(*ppDirectMusic);
}
}
This->dmusic = (IDirectMusic*) *ppDirectMusic;
IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic);
} else {
TRACE("DirectMusic to be created; not needed\n");
/* app allows the performance to initialise itfself and needs a pointer to object*/
/* maybe IID_IDirectMusic8 must be used here */
DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
if (ppDirectMusic) {
*ppDirectMusic = (LPDIRECTMUSIC) This->dmusic;
IDirectMusic_AddRef(*ppDirectMusic);
}
}
if (NULL != pDirectSound) {
if (NULL != This->dsound) {
}
This->dsound = (IDirectSound*) pDirectSound;
IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
} else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) This->dsound, NULL);
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
}
return S_OK;
}
HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState)
@ -1021,18 +1015,23 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams);
if (This->dmusic || This->dsound)
return DMUS_E_ALREADY_INITED;
if (NULL != ppDirectSound && NULL != *ppDirectSound) {
This->dsound = *ppDirectSound;
} else {
This->dsound = NULL;
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
if (ppDirectSound)
*ppDirectSound = This->dsound;
}
IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd);
if (NULL != ppDirectSound && NULL == *ppDirectSound) {
*ppDirectSound = (IDirectSound*) This->dsound;
if (NULL != *ppDirectSound) {
IDirectSound_AddRef(*ppDirectSound);
}
}
/* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
if (!ppDirectSound)
IDirectSound_Release(*ppDirectSound);
/* as seen in msdn we need params init before audio path creation */
if (NULL != pParams) {
memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS));
@ -1082,27 +1081,74 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORM
HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
{
IDirectMusicAudioPathImpl* default_path;
ICOM_THIS(IDirectMusicPerformance8Impl,iface);
IDirectMusicAudioPathImpl *default_path;
DSBUFFERDESC desc;
WAVEFORMATEX format;
LPDIRECTSOUNDBUFFER8 buffer;
FIXME("(%p, %ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
switch (dwType) {
case DMUS_APATH_DYNAMIC_3D:
case DMUS_APATH_DYNAMIC_MONO:
case DMUS_APATH_DYNAMIC_STEREO:
case DMUS_APATH_SHARED_STEREOPLUSREVERB:
break;
default:
break;
}
ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
if (NULL == default_path)
{
*ppNewPath = (LPDIRECTMUSICAUDIOPATH)NULL;
return E_OUTOFMEMORY;
}
default_path->lpVtbl = &DirectMusicAudioPath_Vtbl;
default_path->ref = 1;
default_path->perfo = (IDirectMusicPerformance*) This;
*ppNewPath = (IDirectMusicAudioPath*) default_path;
/* Secondary buffer description */
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = 1;
format.nSamplesPerSec = 44000;
format.nAvgBytesPerSec = 44000*2;
format.nBlockAlign = 2;
format.wBitsPerSample = 16;
format.cbSize = 0;
desc.dwSize = sizeof(desc);
desc.dwFlags = 0;
desc.dwBufferBytes = DSBSIZE_MIN;
desc.dwReserved = 0;
desc.lpwfxFormat = &format;
desc.guid3DAlgorithm = GUID_NULL;
switch(dwType) {
case DMUS_APATH_DYNAMIC_3D:
desc.dwFlags |= DSBCAPS_CTRL3D;
break;
case DMUS_APATH_DYNAMIC_MONO:
break;
case DMUS_APATH_SHARED_STEREOPLUSREVERB:
case DMUS_APATH_DYNAMIC_STEREO:
format.nChannels = 2;
format.nBlockAlign *= 2;
format.nAvgBytesPerSec *=2;
break;
default:
break;
}
/* FIXME: Should we create one secondary buffer for each PChannel? */
IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8)This->dsound, &desc, &buffer, NULL);
default_path->buffer = (IDirectSoundBuffer*) buffer;
/* Update description for creating primary buffer */
desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
desc.dwBufferBytes = 0;
desc.lpwfxFormat = NULL;
IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8)This->dsound, &desc, &buffer, NULL);
default_path->primary = (IDirectSoundBuffer*) buffer;
*ppNewPath = (LPDIRECTMUSICAUDIOPATH) default_path;
TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath);
return DS_OK;
}

View File

@ -923,6 +923,8 @@ struct IDirectMusicAudioPathImpl
/* IDirectMusicAudioPathImpl fields */
IDirectMusicPerformance* perfo;
IDirectMusicGraph* toolGraph;
IDirectSoundBuffer* buffer;
IDirectSoundBuffer* primary;
};
/* IUnknown: */