static void test_COM_audiopathconfig(void) { IDirectMusicAudioPath *dmap = (IDirectMusicAudioPath*)0xdeadbeef; IDirectMusicObject *dmo; IPersistStream *ps; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, (IUnknown*)&dmap, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dmap); if (hr == REGDB_E_CLASSNOTREG) { win_skip("DirectMusicAudioPathConfig not registered\n"); return; } ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicAudioPathConfig create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dmap, "dmap = %p\n", dmap); /* IDirectMusicAudioPath not supported */ hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicAudioPath, (void**)&dmap); todo_wine ok(FAILED(hr) && !dmap, "Unexpected IDirectMusicAudioPath interface: hr=%08x, iface=%p\n", hr, dmap); /* IDirectMusicObject and IPersistStream supported */ hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "DirectMusicObject create failed: %08x, expected S_OK\n", hr); IPersistStream_Release(ps); hr = CoCreateInstance(&CLSID_DirectMusicAudioPathConfig, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (void**)&dmo); ok(hr == S_OK, "DirectMusicObject create failed: %08x, expected S_OK\n", hr); /* Same refcount for all DirectMusicObject interfaces */ refcount = IDirectMusicObject_AddRef(dmo); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); IPersistStream_Release(ps); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IUnknown_Release(unk); /* IDirectMusicAudioPath still not supported */ hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicAudioPath, (void**)&dmap); todo_wine ok(FAILED(hr) && !dmap, "Unexpected IDirectMusicAudioPath interface: hr=%08x, iface=%p\n", hr, dmap); while (IDirectMusicObject_Release(dmo)); }
static HRESULT IDirectMusicStyle8Impl_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand) { HRESULT hr = E_FAIL; IPersistStream* pPersistStream = NULL; hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand); if (FAILED(hr)) { ERR(": could not create object\n"); return hr; } /* acquire PersistStream interface */ hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream); if (FAILED(hr)) { ERR(": could not acquire IPersistStream\n"); return hr; } /* load */ hr = IPersistStream_Load (pPersistStream, pClonedStream); if (FAILED(hr)) { ERR(": failed to load object\n"); return hr; } /* release all loading-related stuff */ IPersistStream_Release (pPersistStream); return S_OK; }
static HRESULT ITrayBandSiteImpl_LoadFromStream(IN OUT ITrayBandSiteImpl *This, IN OUT IStream *pStm) { IPersistStream *pPStm; HRESULT hRet; ASSERT(This->BandSite != NULL); /* We implement the undocumented COM interface IBandSiteStreamCallback that the shell will query so that we can intercept and custom-load the task band when it finds the task band's CLSID (which is internal). This way we can prevent the shell from attempting to CoCreateInstance the (internal) task band, resulting in a failure... */ hRet = IBandSite_QueryInterface(This->BandSite, &IID_IPersistStream, (PVOID*)&pPStm); if (SUCCEEDED(hRet)) { hRet = IPersistStream_Load(pPStm, pStm); DbgPrint("IPersistStream_Load() returned 0x%x\n", hRet); IPersistStream_Release(pPStm); } return hRet; }
static void test_COM(void) { IDirectMusicObject *dmo = (IDirectMusicObject*)0xdeadbeef; IPersistStream *ps; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectSoundWave, (IUnknown*)&dmo, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dmo); ok(hr == CLASS_E_NOAGGREGATION, "DirectSoundWave create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dmo, "dmo = %p\n", dmo); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSegment8, (void**)&dmo); ok(hr == E_NOINTERFACE, "DirectSoundWave create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount for all DirectSoundWave interfaces */ hr = CoCreateInstance(&CLSID_DirectSoundWave, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (void**)&dmo); ok(hr == S_OK, "DirectSoundWave create failed: %08x, expected S_OK\n", hr); refcount = IDirectMusicObject_AddRef(dmo); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); IPersistStream_Release(ps); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IUnknown_Release(unk); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicWavePRIVATE, (void**)&unk); todo_wine ok(hr == S_OK, "QueryInterface for IID_IDirectMusicWavePRIVATE failed: %08x\n", hr); if (hr == S_OK) { refcount = IUnknown_AddRef(unk); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); refcount = IUnknown_Release(unk); } /* Interfaces that native does not support */ hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment, (void**)&unk); ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment failed: %08x\n", hr); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IDirectMusicSegment8, (void**)&unk); ok(hr == E_NOINTERFACE, "QueryInterface for IID_IDirectMusicSegment8 failed: %08x\n", hr); while (IDirectMusicObject_Release(dmo)); }
static void test_load_save_bmp(void) { IPicture *pic; PICTDESC desc; short type; OLE_HANDLE handle; HGLOBAL hmem; DWORD *mem; IPersistStream *src_stream; IStream *dst_stream; HRESULT hr; desc.cbSizeofstruct = sizeof(desc); desc.picType = PICTYPE_BITMAP; desc.u.bmp.hpal = 0; desc.u.bmp.hbitmap = CreateBitmap(1, 1, 1, 1, NULL); hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic); ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr); type = -1; hr = IPicture_get_Type(pic, &type); ok(hr == S_OK,"get_Type error %#8x\n", hr); ok(type == PICTYPE_BITMAP,"expected picture type PICTYPE_BITMAP, got %d\n", type); hr = IPicture_get_Handle(pic, &handle); ok(hr == S_OK,"get_Handle error %#8x\n", hr); ok(IntToPtr(handle) == desc.u.bmp.hbitmap, "get_Handle returned wrong handle %#x\n", handle); hmem = GlobalAlloc(GMEM_ZEROINIT, 4096); hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream); ok(hr == S_OK, "createstreamonhglobal error %#x\n", hr); hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream); ok(hr == S_OK, "QueryInterface error %#x\n", hr); hr = IPersistStream_Save(src_stream, dst_stream, TRUE); ok(hr == S_OK, "Save error %#x\n", hr); IPersistStream_Release(src_stream); IStream_Release(dst_stream); mem = GlobalLock(hmem); ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]); ok(mem[1] == 66, "expected stream size 66, got %u\n", mem[1]); ok(!memcmp(&mem[2], "BM", 2), "got wrong bmp header %04x\n", mem[2]); GlobalUnlock(hmem); GlobalFree(hmem); DeleteObject(desc.u.bmp.hbitmap); IPicture_Release(pic); }
static void test_COM(void) { IDirectMusicStyle8 *dms8 = (IDirectMusicStyle8*)0xdeadbeef; IDirectMusicObject *dmo; IPersistStream *ps; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicStyle, (IUnknown*)&dms8, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dms8); ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicStyle8 create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dms8, "dms8 = %p\n", dms8); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectMusicStyle, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory, (void**)&dms8); ok(hr == E_NOINTERFACE, "DirectMusicStyle8 create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount for all DirectMusicStyle8 interfaces */ hr = CoCreateInstance(&CLSID_DirectMusicStyle, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicStyle8, (void**)&dms8); if (hr == E_NOINTERFACE) { win_skip("Old version without IDirectMusicStyle8\n"); return; } ok(hr == S_OK, "DirectMusicStyle8 create failed: %08x, expected S_OK\n", hr); refcount = IDirectMusicStyle8_AddRef(dms8); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicStyle8_QueryInterface(dms8, &IID_IDirectMusicObject, (void**)&dmo); ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr); refcount = IDirectMusicObject_AddRef(dmo); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); refcount = IDirectMusicObject_Release(dmo); hr = IDirectMusicStyle8_QueryInterface(dms8, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IPersistStream_Release(ps); hr = IDirectMusicStyle8_QueryInterface(dms8, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); refcount = IUnknown_Release(unk); while (IDirectMusicStyle8_Release(dms8)); }
static void test_COM_segment(void) { IDirectMusicSegment8 *dms = (IDirectMusicSegment8*)0xdeadbeef; IDirectMusicObject *dmo; IPersistStream *stream; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicSegment, (IUnknown*)&dms, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dms); ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicSegment create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dms, "dms = %p\n", dms); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void**)&dms); ok(hr == E_NOINTERFACE, "DirectMusicSegment create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount */ hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSegment8, (void**)&dms); if (hr == E_NOINTERFACE) { win_skip("DirectMusicSegment without IDirectMusicSegment8\n"); return; } ok(hr == S_OK, "DirectMusicSegment create failed: %08x, expected S_OK\n", hr); refcount = IDirectMusicSegment8_AddRef(dms); ok (refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IDirectMusicObject, (void**)&dmo); ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr); IDirectMusicSegment8_AddRef(dms); refcount = IDirectMusicSegment8_Release(dms); ok (refcount == 3, "refcount == %u, expected 3\n", refcount); hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IPersistStream, (void**)&stream); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IDirectMusicSegment8_Release(dms); ok (refcount == 3, "refcount == %u, expected 3\n", refcount); hr = IDirectMusicSegment8_QueryInterface(dms, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_Release(unk); ok (refcount == 3, "refcount == %u, expected 3\n", refcount); refcount = IDirectMusicObject_Release(dmo); ok (refcount == 2, "refcount == %u, expected 2\n", refcount); refcount = IPersistStream_Release(stream); ok (refcount == 1, "refcount == %u, expected 1\n", refcount); refcount = IDirectMusicSegment8_Release(dms); ok (refcount == 0, "refcount == %u, expected 0\n", refcount); }
static void test_load_save_icon(void) { IPicture *pic; PICTDESC desc; short type; OLE_HANDLE handle; HGLOBAL hmem; DWORD *mem; IPersistStream *src_stream; IStream *dst_stream; HRESULT hr; desc.cbSizeofstruct = sizeof(desc); desc.picType = PICTYPE_ICON; desc.u.icon.hicon = LoadIcon(0, IDI_APPLICATION); hr = OleCreatePictureIndirect(&desc, &IID_IPicture, FALSE, (void**)&pic); ok(hr == S_OK, "OleCreatePictureIndirect error %#x\n", hr); type = -1; hr = IPicture_get_Type(pic, &type); ok(hr == S_OK,"get_Type error %#8x\n", hr); ok(type == PICTYPE_ICON,"expected picture type PICTYPE_ICON, got %d\n", type); hr = IPicture_get_Handle(pic, &handle); ok(hr == S_OK,"get_Handle error %#8x\n", hr); ok(IntToPtr(handle) == desc.u.icon.hicon, "get_Handle returned wrong handle %#x\n", handle); hmem = GlobalAlloc(GMEM_ZEROINIT, 8192); hr = CreateStreamOnHGlobal(hmem, FALSE, &dst_stream); ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); hr = IPicture_QueryInterface(pic, &IID_IPersistStream, (void **)&src_stream); ok(hr == S_OK, "QueryInterface error %#x\n", hr); hr = IPersistStream_Save(src_stream, dst_stream, TRUE); ok(hr == S_OK, "Saveerror %#x\n", hr); IPersistStream_Release(src_stream); IStream_Release(dst_stream); mem = GlobalLock(hmem); ok(!memcmp(mem, "lt\0\0", 4), "got wrong stream header %04x\n", mem[0]); todo_wine ok(mem[1] == 766, "expected stream size 766, got %u\n", mem[1]); ok(mem[2] == 0x00010000, "got wrong icon header %04x\n", mem[2]); GlobalUnlock(hmem); GlobalFree(hmem); DestroyIcon(desc.u.icon.hicon); IPicture_Release(pic); }
static void test_COM_chordmap(void) { IDirectMusicChordMap *dmcm = (IDirectMusicChordMap*)0xdeadbeef; IDirectMusicObject *dmo; IPersistStream *ps; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicChordMap, (IUnknown*)&dmcm, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dmcm); ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicChordMap create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dmcm, "dmcm = %p\n", dmcm); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectMusicChordMap, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory, (void**)&dmcm); ok(hr == E_NOINTERFACE, "DirectMusicChordMap create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount for all DirectMusicChordMap interfaces */ hr = CoCreateInstance(&CLSID_DirectMusicChordMap, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicChordMap, (void**)&dmcm); ok(hr == S_OK, "DirectMusicChordMap create failed: %08x, expected S_OK\n", hr); refcount = IDirectMusicChordMap_AddRef(dmcm); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicChordMap_QueryInterface(dmcm, &IID_IDirectMusicObject, (void**)&dmo); ok(hr == S_OK, "QueryInterface for IID_IDirectMusicObject failed: %08x\n", hr); refcount = IDirectMusicObject_AddRef(dmo); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); refcount = IDirectMusicObject_Release(dmo); hr = IDirectMusicChordMap_QueryInterface(dmcm, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IPersistStream_Release(ps); hr = IDirectMusicChordMap_QueryInterface(dmcm, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); refcount = IUnknown_Release(unk); while (IDirectMusicChordMap_Release(dmcm)); }
static void test_COM_bandtrack(void) { IDirectMusicTrack *dmbt = (IDirectMusicTrack*)0xdeadbeef; IPersistStream *ps; IUnknown *private; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicBandTrack, (IUnknown*)&dmbt, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dmbt); ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicBandTrack create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dmbt, "dmbt = %p\n", dmbt); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectMusicBandTrack, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (void**)&dmbt); ok(hr == E_NOINTERFACE, "DirectMusicBandTrack create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount for all DirectMusicBandTrack interfaces */ hr = CoCreateInstance(&CLSID_DirectMusicBandTrack, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicTrack, (void**)&dmbt); ok(hr == S_OK, "DirectMusicBandTrack create failed: %08x, expected S_OK\n", hr); refcount = IDirectMusicTrack_AddRef(dmbt); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicTrack_QueryInterface(dmbt, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); refcount = IPersistStream_Release(ps); hr = IDirectMusicTrack_QueryInterface(dmbt, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IUnknown_Release(unk); hr = IDirectMusicTrack_QueryInterface(dmbt, &IID_IDirectMusicBandTrackPrivate, (void**)&private); todo_wine ok(hr == S_OK, "QueryInterface for IID_IDirectMusicBandTrackPrivate failed: %08x\n", hr); if (hr == S_OK) { refcount = IUnknown_AddRef(private); ok(refcount == 6, "refcount == %u, expected 6\n", refcount); refcount = IUnknown_Release(private); }
static void test_COM_section(void) { IDirectMusicObject *dmo = (IDirectMusicObject*)0xdeadbeef; IPersistStream *ps; IUnknown *unk; ULONG refcount; HRESULT hr; /* COM aggregation */ hr = CoCreateInstance(&CLSID_DirectMusicSection, (IUnknown*)&dmo, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&dmo); ok(hr == CLASS_E_NOAGGREGATION, "DirectMusicSection create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr); ok(!dmo, "dmo = %p\n", dmo); /* Invalid RIID */ hr = CoCreateInstance(&CLSID_DirectMusicSection, NULL, CLSCTX_INPROC_SERVER, &IID_IClassFactory, (void**)&dmo); todo_wine ok(hr == E_NOINTERFACE, "DirectMusicSection create failed: %08x, expected E_NOINTERFACE\n", hr); /* Same refcount for all DirectMusicObject interfaces */ hr = CoCreateInstance(&CLSID_DirectMusicSection, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicObject, (void**)&dmo); todo_wine ok(hr == S_OK, "DirectMusicSection create failed: %08x, expected S_OK\n", hr); if (hr != S_OK) { skip("DirectMusicSection not implemented\n"); return; } refcount = IDirectMusicObject_AddRef(dmo); ok(refcount == 2, "refcount == %u, expected 2\n", refcount); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IPersistStream, (void**)&ps); ok(hr == S_OK, "QueryInterface for IID_IPersistStream failed: %08x\n", hr); refcount = IPersistStream_AddRef(ps); ok(refcount == 4, "refcount == %u, expected 4\n", refcount); IPersistStream_Release(ps); hr = IDirectMusicObject_QueryInterface(dmo, &IID_IUnknown, (void**)&unk); ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr); refcount = IUnknown_AddRef(unk); ok(refcount == 5, "refcount == %u, expected 5\n", refcount); refcount = IUnknown_Release(unk); while (IDirectMusicObject_Release(dmo)); }
static HRESULT IDirectMusicBandTrack_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand, DMUS_PRIVATE_BAND_ITEM_HEADER* pHeader) { ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface); HRESULT hr = E_FAIL; IPersistStream* pPersistStream = NULL; hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand); if (FAILED(hr)) { ERR(": could not create object\n"); return hr; } /* acquire PersistStream interface */ hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream); if (FAILED(hr)) { ERR(": could not acquire IPersistStream\n"); return hr; } /* load */ hr = IPersistStream_Load (pPersistStream, pClonedStream); if (FAILED(hr)) { ERR(": failed to load object\n"); return hr; } /* release all loading-related stuff */ IPersistStream_Release (pPersistStream); /* * @TODO insert pBand into This */ if (SUCCEEDED(hr)) { LPDMUS_PRIVATE_BAND pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_BAND)); if (NULL == pNewBand) { ERR(": no more memory\n"); return E_OUTOFMEMORY; } pNewBand->BandHeader = *pHeader; pNewBand->pBand = (IDirectMusicBandImpl*)((char*)(*ppBand) - offsetof(IDirectMusicBandImpl,BandVtbl)); IDirectMusicBand_AddRef(*ppBand); list_add_tail (&This->Bands, &pNewBand->entry); } return S_OK; }
static void helper_free_storage(zend_object *obj) { php_com_persist_helper *object = (php_com_persist_helper*)obj; if (object->ipf) { IPersistFile_Release(object->ipf); } if (object->ips) { IPersistStream_Release(object->ips); } if (object->ipsi) { IPersistStreamInit_Release(object->ipsi); } if (object->unk) { IUnknown_Release(object->unk); } zend_object_std_dtor(&object->std); }
static HRESULT WINAPI IPersistStream_fnGetSizeMax(IPersistStream* iface, ULARGE_INTEGER* pcbSize) { HRESULT r; HlinkImpl *This = impl_from_IPersistStream(iface); IMoniker *moniker; TRACE("(%p) Moniker(%p)\n", This, This->Moniker); pcbSize->QuadPart = sizeof(DWORD)*2; if (This->TargetFrameName) pcbSize->QuadPart += size_hlink_string(This->TargetFrameName); if (This->FriendlyName) pcbSize->QuadPart += size_hlink_string(This->FriendlyName); r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT); if (FAILED(r)) return r; r = E_FAIL; if (moniker) { IPersistStream* monstream = NULL; IMoniker_QueryInterface(moniker, &IID_IPersistStream, (LPVOID*)&monstream); if (monstream) { ULARGE_INTEGER mon_size; r = IPersistStream_GetSizeMax(monstream, &mon_size); pcbSize->QuadPart += mon_size.QuadPart; IPersistStream_Release(monstream); } IMoniker_Release(moniker); } if (This->Location) pcbSize->QuadPart += size_hlink_string(This->Location); return r; }
static void test_dmband(void) { IDirectMusicBand *band; IUnknown *unknown = NULL; IDirectMusicTrack *track = NULL; IPersistStream *stream = NULL; IPersistStream *private = NULL; HRESULT hr; hr = CoCreateInstance(&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*)&band); if (hr != S_OK) { skip("Cannot create DirectMusicBand object (%x)\n", hr); return; } hr = CoCreateInstance(&CLSID_DirectMusicBandTrack, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (LPVOID*)&unknown); ok(hr == S_OK, "CoCreateInstance returned: %x\n", hr); hr = IUnknown_QueryInterface(unknown, &IID_IDirectMusicTrack, (LPVOID*)&track); ok(hr == S_OK, "QueryInterface returned: %x\n", hr); todo_wine ok((LPVOID)track == (LPVOID)unknown, "Interface are not the same %p != %p\n", stream, private); hr = IUnknown_QueryInterface(unknown, &IID_IPersistStream, (LPVOID*)&stream); ok(hr == S_OK, "QueryInterface returned: %x\n", hr); /* Query private interface */ hr = IUnknown_QueryInterface(unknown, &IID_IDirectMusicBandTrackPrivate, (LPVOID*)&private); todo_wine ok(hr == S_OK, "QueryInterface returned: %x\n", hr); trace("Interfaces: unknown = %p, track = %p, stream = %p, private = %p\n", unknown, track, stream, private); if (private) IPersistStream_Release(private); if (stream) IPersistStream_Release(stream); if (track) IDirectMusicTrack_Release(track); if (unknown) IUnknown_Release(unknown); IDirectMusicBand_Release(band); }
static HRESULT WINAPI IPersistStream_fnSave(IPersistStream* iface, IStream* pStm, BOOL fClearDirty) { HRESULT r; HlinkImpl *This = impl_from_IPersistStream(iface); DWORD hdr[2]; IMoniker *moniker; TRACE("(%p) Moniker(%p)\n", This, This->Moniker); r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT); if (FAILED(r)) return r; r = E_FAIL; hdr[0] = HLINK_SAVE_MAGIC; hdr[1] = 0; if (moniker) hdr[1] |= HLINK_SAVE_MONIKER_PRESENT; if (This->absolute) hdr[1] |= HLINK_SAVE_MONIKER_IS_ABSOLUTE; if (This->Location) hdr[1] |= HLINK_SAVE_LOCATION_PRESENT; if (This->FriendlyName) hdr[1] |= HLINK_SAVE_FRIENDLY_PRESENT | 4 /* FIXME */; if (This->TargetFrameName) hdr[1] |= HLINK_SAVE_TARGET_FRAME_PRESENT; IStream_Write(pStm, hdr, sizeof(hdr), NULL); if (This->TargetFrameName) { r = write_hlink_string(pStm, This->TargetFrameName); if (FAILED(r)) goto end; } if (This->FriendlyName) { r = write_hlink_string(pStm, This->FriendlyName); if (FAILED(r)) goto end; } if (moniker) { IPersistStream* monstream; monstream = NULL; IMoniker_QueryInterface(moniker, &IID_IPersistStream, (LPVOID*)&monstream); if (monstream) { r = OleSaveToStream(monstream, pStm); IPersistStream_Release(monstream); } if (FAILED(r)) goto end; } if (This->Location) { r = write_hlink_string(pStm, This->Location); if (FAILED(r)) goto end; } end: if (moniker) IMoniker_Release(moniker); TRACE("Save Result 0x%x\n", r); return r; }
static int dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype, enum dshowSourceFilterType sourcetype) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; IGraphBuilder *graph = ctx->graph; IPin *device_pin = NULL; libAVPin *capture_pin = NULL; libAVFilter *capture_filter = NULL; ICaptureGraphBuilder2 *graph_builder2 = NULL; int ret = AVERROR(EIO); int r; IStream *ifile_stream = NULL; IStream *ofile_stream = NULL; IPersistStream *pers_stream = NULL; const wchar_t *filter_name[2] = { L"Audio capture filter", L"Video capture filter" }; if ( ((ctx->audio_filter_load_file) && (strlen(ctx->audio_filter_load_file)>0) && (sourcetype == AudioSourceDevice)) || ((ctx->video_filter_load_file) && (strlen(ctx->video_filter_load_file)>0) && (sourcetype == VideoSourceDevice)) ) { HRESULT hr; char *filename = NULL; if (sourcetype == AudioSourceDevice) filename = ctx->audio_filter_load_file; else filename = ctx->video_filter_load_file; hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_READ, &ifile_stream); if (S_OK != hr) { av_log(avctx, AV_LOG_ERROR, "Could not open capture filter description file.\n"); goto error; } hr = OleLoadFromStream(ifile_stream, &IID_IBaseFilter, (void **) &device_filter); if (hr != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not load capture filter from file.\n"); goto error; } if (sourcetype == AudioSourceDevice) av_log(avctx, AV_LOG_INFO, "Audio-"); else av_log(avctx, AV_LOG_INFO, "Video-"); av_log(avctx, AV_LOG_INFO, "Capture filter loaded successfully from file \"%s\".\n", filename); } else { if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter)) < 0) { ret = r; goto error; } } ctx->device_filter [devtype] = device_filter; r = IGraphBuilder_AddFilter(graph, device_filter, NULL); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not add device filter to graph.\n"); goto error; } if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, &device_pin)) < 0) { ret = r; goto error; } ctx->device_pin[devtype] = device_pin; capture_filter = libAVFilter_Create(avctx, callback, devtype); if (!capture_filter) { av_log(avctx, AV_LOG_ERROR, "Could not create grabber filter.\n"); goto error; } ctx->capture_filter[devtype] = capture_filter; if ( ((ctx->audio_filter_save_file) && (strlen(ctx->audio_filter_save_file)>0) && (sourcetype == AudioSourceDevice)) || ((ctx->video_filter_save_file) && (strlen(ctx->video_filter_save_file)>0) && (sourcetype == VideoSourceDevice)) ) { HRESULT hr; char *filename = NULL; if (sourcetype == AudioSourceDevice) filename = ctx->audio_filter_save_file; else filename = ctx->video_filter_save_file; hr = SHCreateStreamOnFile ((LPCSTR) filename, STGM_CREATE | STGM_READWRITE, &ofile_stream); if (S_OK != hr) { av_log(avctx, AV_LOG_ERROR, "Could not create capture filter description file.\n"); goto error; } hr = IBaseFilter_QueryInterface(device_filter, &IID_IPersistStream, (void **) &pers_stream); if (hr != S_OK) { av_log(avctx, AV_LOG_ERROR, "Query for IPersistStream failed.\n"); goto error; } hr = OleSaveToStream(pers_stream, ofile_stream); if (hr != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not save capture filter \n"); goto error; } hr = IStream_Commit(ofile_stream, STGC_DEFAULT); if (S_OK != hr) { av_log(avctx, AV_LOG_ERROR, "Could not commit capture filter data to file.\n"); goto error; } if (sourcetype == AudioSourceDevice) av_log(avctx, AV_LOG_INFO, "Audio-"); else av_log(avctx, AV_LOG_INFO, "Video-"); av_log(avctx, AV_LOG_INFO, "Capture filter saved successfully to file \"%s\".\n", filename); } r = IGraphBuilder_AddFilter(graph, (IBaseFilter *) capture_filter, filter_name[devtype]); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not add capture filter to graph\n"); goto error; } libAVPin_AddRef(capture_filter->pin); capture_pin = capture_filter->pin; ctx->capture_pin[devtype] = capture_pin; r = CoCreateInstance(&CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, &IID_ICaptureGraphBuilder2, (void **) &graph_builder2); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not create CaptureGraphBuilder2\n"); goto error; } ICaptureGraphBuilder2_SetFiltergraph(graph_builder2, graph); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not set graph for CaptureGraphBuilder2\n"); goto error; } r = ICaptureGraphBuilder2_RenderStream(graph_builder2, NULL, NULL, (IUnknown *) device_pin, NULL /* no intermediate filter */, (IBaseFilter *) capture_filter); /* connect pins, optionally insert intermediate filters like crossbar if necessary */ if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not RenderStream to connect pins\n"); goto error; } r = dshow_try_setup_crossbar_options(graph_builder2, device_filter, devtype, avctx); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not setup CrossBar\n"); goto error; } ret = 0; error: if (graph_builder2 != NULL) ICaptureGraphBuilder2_Release(graph_builder2); if (pers_stream) IPersistStream_Release(pers_stream); if (ifile_stream) IStream_Release(ifile_stream); if (ofile_stream) IStream_Release(ofile_stream); return ret; }
static void test_persist_save_data(const char *testname, IHlink *lnk, const unsigned char *expected_data, unsigned int expected_data_size, const unsigned char *expected_data_alt, unsigned int expected_data_alt_size) { HRESULT hr; IStream *stream; IPersistStream *ps; HGLOBAL hglobal; DWORD data_size; const unsigned char *data; DWORD i; BOOL same; unsigned int expected_data_win9x_size = 0; hr = IHlink_QueryInterface(lnk, &IID_IPersistStream, (void **)&ps); ok(hr == S_OK, "IHlink_QueryInterface failed with error 0x%08x\n", hr); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "CreateStreamOnHGlobal failed with error 0x%08x\n", hr); hr = IPersistStream_Save(ps, stream, TRUE); ok(hr == S_OK, "IPersistStream_Save failed with error 0x%08x\n", hr); hr = GetHGlobalFromStream(stream, &hglobal); ok(hr == S_OK, "GetHGlobalFromStream failed with error 0x%08x\n", hr); data_size = GlobalSize(hglobal); data = GlobalLock(hglobal); if (expected_data_size % 4) expected_data_win9x_size = 4 * ((expected_data_size / 4) + 1); /* first check we have the right amount of data */ ok((data_size == expected_data_size) || (data_size == expected_data_alt_size) || broken(data_size == expected_data_win9x_size), /* Win9x and WinMe */ "%s: Size of saved data differs (expected %d or %d, actual %d)\n", testname, expected_data_size, expected_data_alt_size, data_size); same = TRUE; /* then do a byte-by-byte comparison */ for (i = 0; i < min(data_size, expected_data_size); i++) { if ((expected_data[i] != data[i]) && (((expected_data != expected_hlink_data2) && (expected_data != expected_hlink_data3)) || ((i < 52 || i >= 56) && (i < 80 || i >= 84)))) { same = FALSE; break; } } if (!same && (expected_data_alt != expected_data)) { /* then try the alternate data */ same = TRUE; for (i = 0; i < min(data_size, expected_data_alt_size); i++) { if ((expected_data_alt[i] != data[i]) && (((expected_data_alt != expected_hlink_data2) && (expected_data_alt != expected_hlink_data3)) || ((i < 52 || i >= 56) && (i < 80 || i >= 84)))) { same = FALSE; break; } } } ok(same, "%s: Saved data differs\n", testname); if (!same) { for (i = 0; i < data_size; i++) { if (i % 8 == 0) printf(" "); printf("0x%02x,", data[i]); if (i % 8 == 7) printf("\n"); } printf("\n"); } GlobalUnlock(hglobal); IStream_Release(stream); IPersistStream_Release(ps); }