dmusic: Partially implement the synth IDirectMusicPort::SetDirectSound().

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2017-05-10 14:44:02 +02:00 committed by Alexandre Julliard
parent e8873b75af
commit f968edb988
2 changed files with 43 additions and 16 deletions

View File

@ -31,11 +31,12 @@ typedef struct SynthPortImpl {
IKsControl IKsControl_iface; IKsControl IKsControl_iface;
LONG ref; LONG ref;
IDirectMusic8Impl *parent; IDirectMusic8Impl *parent;
IDirectSound *pDirectSound; IDirectSound *dsound;
IDirectSoundBuffer *dsbuffer;
IReferenceClock *pLatencyClock; IReferenceClock *pLatencyClock;
IDirectMusicSynth *synth; IDirectMusicSynth *synth;
IDirectMusicSynthSink *synth_sink; IDirectMusicSynthSink *synth_sink;
BOOL fActive; BOOL active;
DMUS_PORTCAPS caps; DMUS_PORTCAPS caps;
DMUS_PORTPARAMS params; DMUS_PORTPARAMS params;
int nrofgroups; int nrofgroups;
@ -198,6 +199,10 @@ static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT ifa
IDirectMusicSynth_Release(This->synth); IDirectMusicSynth_Release(This->synth);
IDirectMusicSynthSink_Release(This->synth_sink); IDirectMusicSynthSink_Release(This->synth_sink);
IReferenceClock_Release(This->pLatencyClock); IReferenceClock_Release(This->pLatencyClock);
if (This->dsbuffer)
IDirectSoundBuffer_Release(This->dsbuffer);
if (This->dsound)
IDirectSound_Release(This->dsound);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
@ -437,7 +442,7 @@ static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_Activate(LPDIRECTMUSICPORT
TRACE("(%p/%p)->(%d)\n", iface, This, active); TRACE("(%p/%p)->(%d)\n", iface, This, active);
This->fActive = active; This->active = active;
return S_OK; return S_OK;
} }
@ -468,11 +473,33 @@ static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_GetChannelPriority(LPDIRECT
return S_OK; return S_OK;
} }
static HRESULT WINAPI SynthPortImpl_IDirectMusicPort_SetDirectSound(LPDIRECTMUSICPORT iface, LPDIRECTSOUND direct_sound, LPDIRECTSOUNDBUFFER direct_sound_buffer) static HRESULT WINAPI synth_dmport_SetDirectSound(IDirectMusicPort *iface, IDirectSound *dsound,
IDirectSoundBuffer *dsbuffer)
{ {
SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface); SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface);
FIXME("(%p/%p)->(%p, %p): stub\n", iface, This, direct_sound, direct_sound_buffer); FIXME("(%p/%p)->(%p, %p): semi-stub\n", iface, This, dsound, dsbuffer);
if (This->active)
return DMUS_E_DSOUND_ALREADY_SET;
if (This->dsound) {
if (This->dsound != This->parent->dsound)
ERR("Not the same dsound in the port (%p) and parent dmusic (%p), expect trouble!\n",
This->dsound, This->parent->dsound);
if (!IDirectSound_Release(This->parent->dsound))
This->parent->dsound = NULL;
}
if (This->dsbuffer)
IDirectSound_Release(This->dsbuffer);
This->dsound = dsound;
This->dsbuffer = dsbuffer;
if (This->dsound)
IDirectSound_AddRef(This->dsound);
if (This->dsbuffer)
IDirectSound_AddRef(This->dsbuffer);
return S_OK; return S_OK;
} }
@ -543,7 +570,7 @@ static const IDirectMusicPortVtbl SynthPortImpl_DirectMusicPort_Vtbl = {
SynthPortImpl_IDirectMusicPort_Activate, SynthPortImpl_IDirectMusicPort_Activate,
SynthPortImpl_IDirectMusicPort_SetChannelPriority, SynthPortImpl_IDirectMusicPort_SetChannelPriority,
SynthPortImpl_IDirectMusicPort_GetChannelPriority, SynthPortImpl_IDirectMusicPort_GetChannelPriority,
SynthPortImpl_IDirectMusicPort_SetDirectSound, synth_dmport_SetDirectSound,
SynthPortImpl_IDirectMusicPort_GetFormat SynthPortImpl_IDirectMusicPort_GetFormat
}; };
@ -785,7 +812,7 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param
obj->IKsControl_iface.lpVtbl = &ikscontrol_vtbl; obj->IKsControl_iface.lpVtbl = &ikscontrol_vtbl;
obj->ref = 1; obj->ref = 1;
obj->parent = parent; obj->parent = parent;
obj->fActive = FALSE; obj->active = FALSE;
obj->params = *port_params; obj->params = *port_params;
obj->caps = *port_caps; obj->caps = *port_caps;

View File

@ -183,11 +183,11 @@ static void test_setdsound(void)
/* Releasing dsound from dmusic */ /* Releasing dsound from dmusic */
hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL); hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
todo_wine ok(hr == DMUS_E_DSOUND_ALREADY_SET, "SetDirectSound failed: %08x\n", hr); ok(hr == DMUS_E_DSOUND_ALREADY_SET, "SetDirectSound failed: %08x\n", hr);
hr = IDirectMusicPort_Activate(port, FALSE); hr = IDirectMusicPort_Activate(port, FALSE);
ok(hr == S_OK, "Port Activate returned: %x\n", hr); ok(hr == S_OK, "Port Activate returned: %x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref); ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL); hr = IDirectMusic_SetDirectSound(dmusic, NULL, NULL);
ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr); ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
@ -217,41 +217,41 @@ static void test_setdsound(void)
hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL); hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL);
ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr); ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 2, "dsound ref count got %d expected 2\n", ref); ok(ref == 2, "dsound ref count got %d expected 2\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref); ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
/* Setting the dsound again on the port will mess with the parent dmusic */ /* Setting the dsound again on the port will mess with the parent dmusic */
hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL); hr = IDirectMusicPort_SetDirectSound(port, dsound, NULL);
ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr); ok(hr == S_OK, "SetDirectSound failed: %08x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref); ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref); ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);
IDirectSound_AddRef(dsound2); /* Crash prevention */ IDirectSound_AddRef(dsound2); /* Crash prevention */
hr = IDirectMusicPort_Activate(port, TRUE); hr = IDirectMusicPort_Activate(port, TRUE);
ok(hr == S_OK, "Activate returned: %x\n", hr); ok(hr == S_OK, "Activate returned: %x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref); todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
todo_wine ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref); ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
hr = IDirectMusicPort_Activate(port, TRUE); hr = IDirectMusicPort_Activate(port, TRUE);
todo_wine ok(hr == S_FALSE, "Activate returned: %x\n", hr); todo_wine ok(hr == S_FALSE, "Activate returned: %x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref); todo_wine ok(ref == 4, "dsound ref count got %d expected 4\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
todo_wine ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref); ok(ref == 2, "dsound2 ref count got %d expected 2\n", ref);
/* Deactivating the port messes with the dsound refcount in the parent dmusic */ /* Deactivating the port messes with the dsound refcount in the parent dmusic */
hr = IDirectMusicPort_Activate(port, FALSE); hr = IDirectMusicPort_Activate(port, FALSE);
ok(hr == S_OK, "Port Activate returned: %x\n", hr); ok(hr == S_OK, "Port Activate returned: %x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref); ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref); todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);
hr = IDirectMusicPort_Activate(port, FALSE); hr = IDirectMusicPort_Activate(port, FALSE);
todo_wine ok(hr == S_FALSE, "Port Activate returned: %x\n", hr); todo_wine ok(hr == S_FALSE, "Port Activate returned: %x\n", hr);
ref = get_refcount(dsound); ref = get_refcount(dsound);
todo_wine ok(ref == 3, "dsound ref count got %d expected 3\n", ref); ok(ref == 3, "dsound ref count got %d expected 3\n", ref);
ref = get_refcount(dsound2); ref = get_refcount(dsound2);
todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref); todo_wine ok(ref == 1, "dsound2 ref count got %d expected 1\n", ref);