Commit 677b37cb authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

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.
parent e10a0fd3
...@@ -303,6 +303,9 @@ HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOAD ...@@ -303,6 +303,9 @@ HRESULT WINAPI IDirectMusicLoader8Impl_ReleaseObjectByUnknown (LPDIRECTMUSICLOAD
return S_OK; return S_OK;
} }
extern ICOM_VTABLE(IDirectMusicSegment) DirectMusicSegment_Vtbl;
extern ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl;
HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface, HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 iface,
REFGUID rguidClassID, REFGUID rguidClassID,
REFIID iidInterfaceID, REFIID iidInterfaceID,
...@@ -320,6 +323,24 @@ HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8 ...@@ -320,6 +323,24 @@ HRESULT WINAPI IDirectMusicLoader8Impl_LoadObjectFromFile (LPDIRECTMUSICLOADER8
} else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicContainer)) { } else if (IsEqualGUID(iidInterfaceID, &CLSID_DirectMusicContainer)) {
FIXME("wanted 'con'\n"); 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 */ /** for now alway return not supported for avoiding futur crash */
return DMUS_E_LOADER_FORMATNOTSUPPORTED; return DMUS_E_LOADER_FORMATNOTSUPPORTED;
......
...@@ -216,6 +216,32 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH ...@@ -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); 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) { 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: case DMUS_PATH_AUDIOPATH_GRAPH:
{ {
if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) { if (IsEqualGUID(iidInterface, &IID_IDirectMusicGraph)) {
...@@ -257,7 +283,7 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH ...@@ -257,7 +283,7 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (LPDIRECTMUSICAUDIOPATH
pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl)); pGraph = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));
pGraph->lpVtbl = &DirectMusicGraph_Vtbl; pGraph->lpVtbl = &DirectMusicGraph_Vtbl;
pGraph->ref = 1; pGraph->ref = 1;
IDirectMusicPerformanceImpl_SetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, pGraph); IDirectMusicPerformanceImpl_SetGraph((LPDIRECTMUSICPERFORMANCE) This->perfo, (IDirectMusicGraph*) pGraph);
/* we need release as SetGraph do an AddRef */ /* we need release as SetGraph do an AddRef */
IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph); IDirectMusicGraphImpl_Release((LPDIRECTMUSICGRAPH) pGraph);
pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph; pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;
......
...@@ -557,37 +557,31 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_Init (LPDIRECTMUSICPERFORMANCE8 ifac ...@@ -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); 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 */ /* app creates it's own dmusic object and gives it to performance */
if (NULL != *ppDirectMusic) { This->dmusic = (IDirectMusic*) *ppDirectMusic;
if (NULL != This->dmusic) { IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic);
} } else {
This->dmusic = (IDirectMusic*) *ppDirectMusic; /* app allows the performance to initialise itfself and needs a pointer to object*/
IDirectMusicImpl_AddRef((LPDIRECTMUSIC) This->dmusic); /* maybe IID_IDirectMusic8 must be used here */
} else { /* app allows the performance to initialise itfself and needs a pointer to object*/ DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
/* maybe IID_IDirectMusic8 must be used here */ if (ppDirectMusic) {
DMUSIC_CreateDirectMusic(&IID_IDirectMusic, (LPDIRECTMUSIC*) &This->dmusic, NULL);
*ppDirectMusic = (LPDIRECTMUSIC) This->dmusic; *ppDirectMusic = (LPDIRECTMUSIC) This->dmusic;
if (NULL != *ppDirectMusic) { IDirectMusic_AddRef(*ppDirectMusic);
IDirectMusic_AddRef(*ppDirectMusic);
}
} }
} else {
TRACE("DirectMusic to be created; not needed\n");
} }
if (NULL != pDirectSound) { if (NULL != pDirectSound) {
if (NULL != This->dsound) {
}
This->dsound = (IDirectSound*) pDirectSound; This->dsound = (IDirectSound*) pDirectSound;
IDirectSound_AddRef((LPDIRECTSOUND) This->dsound); IDirectSound_AddRef((LPDIRECTSOUND) This->dsound);
} else { } else {
DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) This->dsound, NULL); DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
} }
return S_OK; return S_OK;
} }
HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState) HRESULT WINAPI IDirectMusicPerformance8Impl_PlaySegment (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicSegment* pSegment, DWORD dwFlags, __int64 i64StartTime, IDirectMusicSegmentState** ppSegmentState)
...@@ -1021,18 +1015,23 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8 ...@@ -1021,18 +1015,23 @@ HRESULT WINAPI IDirectMusicPerformance8ImplInitAudio (LPDIRECTMUSICPERFORMANCE8
ICOM_THIS(IDirectMusicPerformance8Impl,iface); ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p, %p, %p, %p, %lx, %lu, %lx, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams); 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) { if (NULL != ppDirectSound && NULL != *ppDirectSound) {
This->dsound = *ppDirectSound; This->dsound = *ppDirectSound;
} else { } else {
This->dsound = NULL; DirectSoundCreate8(&IID_IDirectSound8, (LPDIRECTSOUND8*) &This->dsound, NULL);
if (ppDirectSound)
*ppDirectSound = This->dsound;
} }
IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd); IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, This->dsound, hWnd);
if (NULL != ppDirectSound && NULL == *ppDirectSound) {
*ppDirectSound = (IDirectSound*) This->dsound; /* Init increases the ref count of the dsound object. Decremente it if the app don't want a pointer to the object. */
if (NULL != *ppDirectSound) { if (!ppDirectSound)
IDirectSound_AddRef(*ppDirectSound); IDirectSound_Release(*ppDirectSound);
}
}
/* as seen in msdn we need params init before audio path creation */ /* as seen in msdn we need params init before audio path creation */
if (NULL != pParams) { if (NULL != pParams) {
memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS)); memcpy(&This->params, pParams, sizeof(DMUS_AUDIOPARAMS));
...@@ -1082,27 +1081,74 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORM ...@@ -1082,27 +1081,74 @@ HRESULT WINAPI IDirectMusicPerformance8ImplCreateAudioPath (LPDIRECTMUSICPERFORM
HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) HRESULT WINAPI IDirectMusicPerformance8ImplCreateStandardAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, DWORD dwType, DWORD dwPChannelCount, BOOL fActivate, IDirectMusicAudioPath** ppNewPath)
{ {
IDirectMusicAudioPathImpl* default_path; IDirectMusicAudioPathImpl *default_path;
ICOM_THIS(IDirectMusicPerformance8Impl,iface); DSBUFFERDESC desc;
WAVEFORMATEX format;
LPDIRECTSOUNDBUFFER8 buffer;
FIXME("(%p, %ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath); ICOM_THIS(IDirectMusicPerformance8Impl,iface);
FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, dwPChannelCount, fActivate, ppNewPath);
switch (dwType) { 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;
/* 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: case DMUS_APATH_DYNAMIC_3D:
desc.dwFlags |= DSBCAPS_CTRL3D;
break;
case DMUS_APATH_DYNAMIC_MONO: case DMUS_APATH_DYNAMIC_MONO:
break;
case DMUS_APATH_SHARED_STEREOPLUSREVERB:
case DMUS_APATH_DYNAMIC_STEREO: case DMUS_APATH_DYNAMIC_STEREO:
case DMUS_APATH_SHARED_STEREOPLUSREVERB: format.nChannels = 2;
break; format.nBlockAlign *= 2;
format.nAvgBytesPerSec *=2;
break;
default: default:
break; break;
} }
/* FIXME: Should we create one secondary buffer for each PChannel? */
IDirectSound8_CreateSoundBuffer((LPDIRECTSOUND8)This->dsound, &desc, &buffer, NULL);
default_path->buffer = (IDirectSoundBuffer*) buffer;
default_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl)); /* Update description for creating primary buffer */
default_path->lpVtbl = &DirectMusicAudioPath_Vtbl; desc.dwFlags |= DSBCAPS_PRIMARYBUFFER;
default_path->ref = 1; desc.dwBufferBytes = 0;
default_path->perfo = (IDirectMusicPerformance*) This; 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);
*ppNewPath = (IDirectMusicAudioPath*) default_path;
return DS_OK; return DS_OK;
} }
......
...@@ -923,6 +923,8 @@ struct IDirectMusicAudioPathImpl ...@@ -923,6 +923,8 @@ struct IDirectMusicAudioPathImpl
/* IDirectMusicAudioPathImpl fields */ /* IDirectMusicAudioPathImpl fields */
IDirectMusicPerformance* perfo; IDirectMusicPerformance* perfo;
IDirectMusicGraph* toolGraph; IDirectMusicGraph* toolGraph;
IDirectSoundBuffer* buffer;
IDirectSoundBuffer* primary;
}; };
/* IUnknown: */ /* IUnknown: */
......
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