static HRESULT WINAPI InstanceObjectFactory_IClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppvObj) { InstanceObjectFactory *This = ADJUST_THIS(InstanceObjectFactory, IClassFactory, iface); IPersistPropertyBag *pPersistPropertyBag; HRESULT hr; TRACE("(pUnkOuter=%p, riid=%s, ppvObj=%p)\n", pUnkOuter, debugstr_guid(riid), ppvObj); hr = CoCreateInstance(&This->m_clsidInstance, NULL, CLSCTX_INPROC_SERVER, &IID_IPersistPropertyBag, (LPVOID*)&pPersistPropertyBag); if (FAILED(hr)) { TRACE("Failed to create instance of %s. hr = %08lx\n", debugstr_guid(&This->m_clsidInstance), hr); return hr; } hr = IPersistPropertyBag_Load(pPersistPropertyBag, This->m_pPropertyBag, NULL); if (FAILED(hr)) { TRACE("Failed to initialize object from ProperyBag: hr = %08lx\n", hr); IPersistPropertyBag_Release(pPersistPropertyBag); return hr; } hr = IPersistPropertyBag_QueryInterface(pPersistPropertyBag, riid, ppvObj); IPersistPropertyBag_Release(pPersistPropertyBag); return hr; }
static void load_prop_bag(PluginHost *host, IPersistPropertyBag *persist_prop_bag) { IPropertyBag *prop_bag; HRESULT hres; hres = create_param_prop_bag(host->element->element.nselem, &prop_bag); if(FAILED(hres)) return; if(prop_bag && !check_load_safety(host)) { IPropertyBag_Release(prop_bag); prop_bag = NULL; } if(prop_bag) { hres = IPersistPropertyBag_Load(persist_prop_bag, prop_bag, NULL); IPropertyBag_Release(prop_bag); if(FAILED(hres)) WARN("Load failed: %08x\n", hres); }else { hres = IPersistPropertyBag_InitNew(persist_prop_bag); if(FAILED(hres)) WARN("InitNew failed: %08x\n", hres); } }
static void test_AviCo(void) { IPersistPropertyBag *persist_bag; IPin *pin, *in_pin, *out_pin; IEnumPins *enum_pins; IBaseFilter *avico; PIN_INFO pin_info; HRESULT hres; static const WCHAR inputW[] = {'I','n','p','u','t',0}; static const WCHAR outputW[] = {'O','u','t','p','u','t',0}; hres = CoCreateInstance(&CLSID_AVICo, NULL, CLSCTX_INPROC_SERVER, &IID_IBaseFilter, (void**)&avico); if(hres == REGDB_E_CLASSNOTREG) { win_skip("CLSID_AVICo not restered\n"); return; } ok(hres == S_OK, "Could not create CLSID_AVICo class: %08x\n", hres); hres = IBaseFilter_QueryInterface(avico, &IID_IPin, (void**)&pin); ok(hres == E_NOINTERFACE, "QueryInterface(IID_IPin) returned: %08x\n", hres); hres = IBaseFilter_QueryInterface(avico, &IID_IPersistPropertyBag, (void**)&persist_bag); ok(hres == S_OK, "QueryInterface(IID_IPersistPropertyBag) returned: %08x\n", hres); SET_EXPECT(Read_FccHandler); hres = IPersistPropertyBag_Load(persist_bag, &PropertyBag, NULL); ok(hres == S_OK, "Load failed: %08x\n", hres); CHECK_CALLED(Read_FccHandler); IPersistPropertyBag_Release(persist_bag); hres = IBaseFilter_EnumPins(avico, &enum_pins); ok(hres == S_OK, "EnumPins failed: %08x\n", hres); hres = IEnumPins_Next(enum_pins, 1, &in_pin, NULL); ok(hres == S_OK, "Next failed: %08x\n", hres); hres = IPin_QueryPinInfo(in_pin, &pin_info); ok(hres == S_OK, "QueryPinInfo failed: %08x\n", hres); ok(pin_info.pFilter == avico, "pin_info.pFilter != avico\n"); ok(pin_info.dir == PINDIR_INPUT, "pin_info.dir = %d\n", pin_info.dir); ok(!lstrcmpW(pin_info.achName, inputW), "pin_info.achName = %s\n", wine_dbgstr_w(pin_info.achName)); hres = IEnumPins_Next(enum_pins, 1, &out_pin, NULL); ok(hres == S_OK, "Next failed: %08x\n", hres); hres = IPin_QueryPinInfo(out_pin, &pin_info); ok(hres == S_OK, "QueryPinInfo failed: %08x\n", hres); ok(pin_info.pFilter == avico, "pin_info.pFilter != avico\n"); ok(pin_info.dir == PINDIR_OUTPUT, "pin_info.dir = %d\n", pin_info.dir); ok(!lstrcmpW(pin_info.achName, outputW), "pin_info.achName = %s\n", wine_dbgstr_w(pin_info.achName)); IEnumPins_Release(enum_pins); IPin_Release(in_pin); IPin_Release(out_pin); IBaseFilter_Release(avico); }
static void test_query_interface(void) { HRESULT hr; IBaseFilter *pBaseFilter = NULL; IBasicAudio *pBasicAudio = NULL; IMediaPosition *pMediaPosition = NULL; IMediaSeeking *pMediaSeeking = NULL; IQualityControl *pQualityControl = NULL; IPersistPropertyBag *ppb = NULL; IDirectSound3DBuffer *ds3dbuf = NULL; IReferenceClock *clock = NULL; IAMDirectSound *pAMDirectSound = NULL; QI_SUCCEED(pDSRender, IID_IBaseFilter, pBaseFilter); RELEASE_EXPECT(pBaseFilter, 1); QI_SUCCEED(pDSRender, IID_IBasicAudio, pBasicAudio); RELEASE_EXPECT(pBasicAudio, 1); QI_SUCCEED(pDSRender, IID_IMediaSeeking, pMediaSeeking); RELEASE_EXPECT(pMediaSeeking, 1); QI_SUCCEED(pDSRender, IID_IReferenceClock, clock); RELEASE_EXPECT(clock, 1); QI_SUCCEED(pDSRender, IID_IAMDirectSound, pAMDirectSound); RELEASE_EXPECT( pAMDirectSound, 1); todo_wine { QI_SUCCEED(pDSRender, IID_IDirectSound3DBuffer, ds3dbuf); RELEASE_EXPECT(ds3dbuf, 1); QI_SUCCEED(pDSRender, IID_IPersistPropertyBag, ppb); if (ppb) { IPropertyBag bag = { &PB_Vtbl }; hr = IPersistPropertyBag_Load(ppb, &bag, NULL); ok(hr == S_OK, "Couldn't load default device: %08x\n", hr); } RELEASE_EXPECT(ppb, 1); } QI_SUCCEED(pDSRender, IID_IMediaPosition, pMediaPosition); RELEASE_EXPECT(pMediaPosition, 1); QI_SUCCEED(pDSRender, IID_IQualityControl, pQualityControl); RELEASE_EXPECT(pQualityControl, 1); }
static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD clsctx, PROPVARIANT *params, void **ppv) { HRESULT hr = E_NOINTERFACE; MMDevice *This = impl_from_IMMDevice(iface); TRACE("(%p)->(%s, %x, %p, %p)\n", iface, debugstr_guid(riid), clsctx, params, ppv); if (!ppv) return E_POINTER; if (IsEqualIID(riid, &IID_IAudioClient)){ hr = drvs.pGetAudioEndpoint(&This->devguid, iface, (IAudioClient**)ppv); }else if (IsEqualIID(riid, &IID_IAudioEndpointVolume) || IsEqualIID(riid, &IID_IAudioEndpointVolumeEx)) hr = AudioEndpointVolume_Create(This, (IAudioEndpointVolumeEx**)ppv); else if (IsEqualIID(riid, &IID_IAudioSessionManager) || IsEqualIID(riid, &IID_IAudioSessionManager2)) { hr = drvs.pGetAudioSessionManager(iface, (IAudioSessionManager2**)ppv); } else if (IsEqualIID(riid, &IID_IBaseFilter)) { if (This->flow == eRender) hr = CoCreateInstance(&CLSID_DSoundRender, NULL, clsctx, riid, ppv); else ERR("Not supported for recording?\n"); if (SUCCEEDED(hr)) { IPersistPropertyBag *ppb; hr = IUnknown_QueryInterface((IUnknown*)*ppv, &IID_IPersistPropertyBag, (void*)&ppb); if (SUCCEEDED(hr)) { /* ::Load cannot assume the interface stays alive after the function returns, * so just create the interface on the stack, saves a lot of complicated code */ IPropertyBagImpl bag = { { &PB_Vtbl } }; bag.devguid = This->devguid; hr = IPersistPropertyBag_Load(ppb, &bag.IPropertyBag_iface, NULL); IPersistPropertyBag_Release(ppb); if (FAILED(hr)) IBaseFilter_Release((IBaseFilter*)*ppv); } else { FIXME("Wine doesn't support IPersistPropertyBag on DSoundRender yet, ignoring..\n"); hr = S_OK; } } } else if (IsEqualIID(riid, &IID_IDeviceTopology)) { FIXME("IID_IDeviceTopology unsupported\n"); } else if (IsEqualIID(riid, &IID_IDirectSound) || IsEqualIID(riid, &IID_IDirectSound8)) { if (This->flow == eRender) hr = CoCreateInstance(&CLSID_DirectSound8, NULL, clsctx, riid, ppv); if (SUCCEEDED(hr)) { hr = IDirectSound_Initialize((IDirectSound*)*ppv, &This->devguid); if (FAILED(hr)) IDirectSound_Release((IDirectSound*)*ppv); } } else if (IsEqualIID(riid, &IID_IDirectSoundCapture)) { if (This->flow == eCapture) hr = CoCreateInstance(&CLSID_DirectSoundCapture8, NULL, clsctx, riid, ppv); if (SUCCEEDED(hr)) { hr = IDirectSoundCapture_Initialize((IDirectSoundCapture*)*ppv, &This->devguid); if (FAILED(hr)) IDirectSoundCapture_Release((IDirectSoundCapture*)*ppv); } } else ERR("Invalid/unknown iid %s\n", debugstr_guid(riid)); if (FAILED(hr)) *ppv = NULL; TRACE("Returning %08x\n", hr); return hr; }
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_BindToObject(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult) { MediaCatMoniker *This = impl_from_IMoniker(iface); IUnknown * pObj = NULL; IPropertyBag * pProp = NULL; CLSID clsID; VARIANT var; HRESULT res = E_FAIL; TRACE("(%p)->(%p, %p, %s, %p)\n", This, pbc, pmkToLeft, debugstr_guid(riidResult), ppvResult); VariantInit(&var); *ppvResult = NULL; if(pmkToLeft==NULL) { /* first activation of this class */ LPVOID pvptr; res=IMoniker_BindToStorage(iface, NULL, NULL, &IID_IPropertyBag, &pvptr); pProp = pvptr; if (SUCCEEDED(res)) { V_VT(&var) = VT_LPWSTR; res = IPropertyBag_Read(pProp, clsid_keyname, &var, NULL); } if (SUCCEEDED(res)) { res = CLSIDFromString(V_UNION(&var,bstrVal), &clsID); CoTaskMemFree(V_UNION(&var, bstrVal)); } if (SUCCEEDED(res)) { res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IUnknown,&pvptr); pObj = pvptr; } } if (pObj!=NULL) { /* get the requested interface from the loaded class */ res = S_OK; if (pProp) { HRESULT res2; LPVOID ppv = NULL; res2 = IUnknown_QueryInterface(pObj, &IID_IPersistPropertyBag, &ppv); if (SUCCEEDED(res2)) { res = IPersistPropertyBag_Load((IPersistPropertyBag *) ppv, pProp, NULL); IPersistPropertyBag_Release((IPersistPropertyBag *) ppv); } } if (SUCCEEDED(res)) res= IUnknown_QueryInterface(pObj,riidResult,ppvResult); IUnknown_Release(pObj); } if (pProp) { IPropertyBag_Release(pProp); } TRACE("<- 0x%x\n", res); return res; }