From: Anton Baskanov baskanov@gmail.com
--- dlls/dmusic/port.c | 51 ++++++++++++++++++++++++++++++++------ dlls/dmusic/tests/dmusic.c | 8 +++--- 2 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index 49219ae10c5..84a9e759ab2 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -42,6 +42,7 @@ struct synth_port { IDirectSound *dsound; IDirectSoundBuffer *dsbuffer; IDirectMusicSynth *synth; + IKsControl *synth_control; IDirectMusicSynthSink *synth_sink; BOOL active; DMUS_PORTPARAMS params; @@ -129,6 +130,7 @@ static ULONG WINAPI synth_port_Release(IDirectMusicPort *iface) IDirectMusicSynthSink_Release(This->synth_sink); IDirectMusicSynth_Activate(This->synth, FALSE); IDirectMusicSynth_Close(This->synth); + IKsControl_Release(This->synth_control); IDirectMusicSynth_Release(This->synth); if (This->dsbuffer) IDirectSoundBuffer_Release(This->dsbuffer); @@ -639,15 +641,52 @@ static ULONG WINAPI IKsControlImpl_Release(IKsControl *iface) static HRESULT WINAPI IKsControlImpl_KsProperty(IKsControl *iface, KSPROPERTY *prop, ULONG prop_len, void *data, ULONG data_len, ULONG *ret_len) { + struct synth_port *This = synth_from_IKsControl(iface); + TRACE("(%p, %p, %lu, %p, %lu, %p)\n", iface, prop, prop_len, data, data_len, ret_len); TRACE("prop = %s - %lu - %lu\n", debugstr_guid(&prop->Set), prop->Id, prop->Flags);
+ if (prop->Flags == KSPROPERTY_TYPE_SET) + { + if (data_len < sizeof(LONG)) + return E_NOT_SUFFICIENT_BUFFER; + + if (IsEqualGUID(&prop->Set, &GUID_DMUS_PROP_Volume)) + { + KSPROPERTY volume_prop; + DWORD volume_size; + + if (prop->Id != 0) + return DMUS_E_UNKNOWN_PROPERTY; + + volume_prop.Set = GUID_DMUS_PROP_Volume; + volume_prop.Id = 1; + volume_prop.Flags = KSPROPERTY_TYPE_SET; + + return IKsControl_KsProperty(This->synth_control, &volume_prop, sizeof(volume_prop), + data, data_len, &volume_size); + } + else + { + FIXME("Unknown property %s\n", debugstr_guid(&prop->Set)); + } + + return S_OK; + } + if (prop->Flags != KSPROPERTY_TYPE_GET) { FIXME("prop flags %lu not yet supported\n", prop->Flags); return S_FALSE; }
+ if (IsEqualGUID(&prop->Set, &GUID_DMUS_PROP_Volume)) + { + if (prop->Id != 0) + return DMUS_E_UNKNOWN_PROPERTY; + return DMUS_E_GET_UNSUPPORTED; + } + if (data_len < sizeof(DWORD)) return E_NOT_SUFFICIENT_BUFFER;
@@ -686,7 +725,6 @@ static const IKsControlVtbl ikscontrol_vtbl = { HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_params, DMUS_PORTCAPS *port_caps, IDirectMusicPort **port) { - IKsControl *synth_control = NULL; struct synth_port *obj; HRESULT hr = E_FAIL; int i; @@ -713,7 +751,7 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param (void **)&obj->synth);
if (SUCCEEDED(hr)) - hr = IDirectMusicSynth_QueryInterface(obj->synth, &IID_IKsControl, (void **)&synth_control); + hr = IDirectMusicSynth_QueryInterface(obj->synth, &IID_IKsControl, (void **)&obj->synth_control);
if (SUCCEEDED(hr)) hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (void**)&obj->synth_sink); @@ -741,7 +779,7 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param volume_prop.Id = 0; volume_prop.Flags = KSPROPERTY_TYPE_SET;
- IKsControl_KsProperty(synth_control, &volume_prop, sizeof(volume_prop), &volume, + IKsControl_KsProperty(obj->synth_control, &volume_prop, sizeof(volume_prop), &volume, sizeof(volume), &volume_size);
volume = 0; @@ -749,7 +787,7 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param volume_prop.Id = 1; volume_prop.Flags = KSPROPERTY_TYPE_SET;
- IKsControl_KsProperty(synth_control, &volume_prop, sizeof(volume_prop), &volume, + IKsControl_KsProperty(obj->synth_control, &volume_prop, sizeof(volume_prop), &volume, sizeof(volume), &volume_size); }
@@ -780,14 +818,13 @@ HRESULT synth_port_create(IDirectMusic8Impl *parent, DMUS_PORTPARAMS *port_param } }
- if (synth_control) - IKsControl_Release(synth_control); - if (SUCCEEDED(hr)) { *port = &obj->IDirectMusicPort_iface; return S_OK; }
+ if (obj->synth_control) + IKsControl_Release(obj->synth_control); if (obj->synth) IDirectMusicSynth_Release(obj->synth); if (obj->synth_sink) diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index b6fd97c896e..41041294faa 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -1054,27 +1054,27 @@ static void test_port_kscontrol(void) property.Id = 0; property.Flags = KSPROPERTY_TYPE_GET; hr = IKsControl_KsProperty(control, &property, sizeof(property), &volume, sizeof(volume), &volume_size); - todo_wine ok(hr == DMUS_E_GET_UNSUPPORTED, "got hr %#lx.\n", hr); + ok(hr == DMUS_E_GET_UNSUPPORTED, "got hr %#lx.\n", hr);
property.Set = GUID_DMUS_PROP_Volume; property.Id = 1; property.Flags = KSPROPERTY_TYPE_GET; hr = IKsControl_KsProperty(control, &property, sizeof(property), &volume, sizeof(volume), &volume_size); - todo_wine ok(hr == DMUS_E_UNKNOWN_PROPERTY, "got hr %#lx.\n", hr); + ok(hr == DMUS_E_UNKNOWN_PROPERTY, "got hr %#lx.\n", hr);
volume = 0; property.Set = GUID_DMUS_PROP_Volume; property.Id = 0; property.Flags = KSPROPERTY_TYPE_SET; hr = IKsControl_KsProperty(control, &property, sizeof(property), &volume, sizeof(volume), &volume_size); - todo_wine ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(hr == S_OK, "got hr %#lx.\n", hr);
volume = 0; property.Set = GUID_DMUS_PROP_Volume; property.Id = 1; property.Flags = KSPROPERTY_TYPE_SET; hr = IKsControl_KsProperty(control, &property, sizeof(property), &volume, sizeof(volume), &volume_size); - todo_wine ok(hr == DMUS_E_UNKNOWN_PROPERTY, "got hr %#lx.\n", hr); + ok(hr == DMUS_E_UNKNOWN_PROPERTY, "got hr %#lx.\n", hr);
IDirectMusicPort_Release(port); IDirectMusic_Release(dmusic);