static ULONG WINAPI NullRendererInner_Release(IUnknown * iface) { ICOM_THIS_MULTI(NullRendererImpl, IInner_vtbl, iface); ULONG refCount = InterlockedDecrement(&This->refCount); TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1); if (!refCount) { IPin *pConnectedTo; if (This->pClock) IReferenceClock_Release(This->pClock); if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo))) { IPin_Disconnect(pConnectedTo); IPin_Release(pConnectedTo); } IPin_Disconnect((IPin *)This->pInputPin); IPin_Release((IPin *)This->pInputPin); This->lpVtbl = NULL; This->csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->csFilter); TRACE("Destroying Null Renderer\n"); CoTaskMemFree(This); return 0; } else return refCount; }
static void test_IReferenceClock_SystemClock(void) { IReferenceClock * pReferenceClock; HRESULT hr; hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pReferenceClock); ok(hr == S_OK, "Unable to create reference clock from system clock %x\n", hr); if (hr == S_OK) { test_IReferenceClock_query_interface("SystemClock", pReferenceClock); test_IReferenceClock_methods("SystemClock", pReferenceClock); IReferenceClock_Release(pReferenceClock); } }
/* IMediaFilter */ static HRESULT WINAPI SampleGrabber_IBaseFilter_SetSyncSource(IBaseFilter *iface, IReferenceClock *clock) { SG_Impl *This = impl_from_IBaseFilter(iface); TRACE("(%p)->(%p)\n", This, clock); if (clock != This->refClock) { if (clock) IReferenceClock_AddRef(clock); if (This->refClock) IReferenceClock_Release(This->refClock); This->refClock = clock; } return S_OK; }
static ULONG WINAPI IDirectMusicSynthSinkImpl_Release(LPDIRECTMUSICSYNTHSINK iface) { IDirectMusicSynthSinkImpl *This = impl_from_IDirectMusicSynthSink(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->(): new ref = %u\n", This, ref); if (!ref) { if (This->latency_clock) IReferenceClock_Release(This->latency_clock); HeapFree(GetProcessHeap(), 0, This); DMSYNTH_UnlockModule(); } return ref; }
static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface) { DSoundRenderImpl *This = (DSoundRenderImpl *)iface; ULONG refCount = InterlockedDecrement(&This->refCount); TRACE("(%p)->() Release from %d\n", This, refCount + 1); if (!refCount) { IPin *pConnectedTo; if (This->pClock) IReferenceClock_Release(This->pClock); if (This->dsbuffer) IDirectSoundBuffer_Release(This->dsbuffer); This->dsbuffer = NULL; if (This->dsound) IDirectSound_Release(This->dsound); This->dsound = NULL; if (SUCCEEDED(IPin_ConnectedTo((IPin *)This->pInputPin, &pConnectedTo))) { IPin_Disconnect(pConnectedTo); IPin_Release(pConnectedTo); } IPin_Disconnect((IPin *)This->pInputPin); IPin_Release((IPin *)This->pInputPin); This->lpVtbl = NULL; This->IBasicAudio_vtbl = NULL; This->csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->csFilter); CloseHandle(This->state_change); CloseHandle(This->blocked); TRACE("Destroying Audio Renderer\n"); CoTaskMemFree(This); return 0; } else return refCount; }
static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface) { IDirectMusic8Impl *This = impl_from_IDirectMusic8(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->(): new ref = %u\n", This, ref); if (!ref) { IReferenceClock_Release(&This->pMasterClock->IReferenceClock_iface); HeapFree(GetProcessHeap(), 0, This->system_ports); HeapFree(GetProcessHeap(), 0, This->ppPorts); HeapFree(GetProcessHeap(), 0, This); DMUSIC_UnlockModule(); } return ref; }
HRESULT WINAPI BaseFilterImpl_SetSyncSource(IBaseFilter * iface, IReferenceClock *pClock) { BaseFilter *This = (BaseFilter*)iface; TRACE("(%p)->(%p)\n", This, pClock); EnterCriticalSection(&This->csFilter); { if (This->pClock) IReferenceClock_Release(This->pClock); This->pClock = pClock; if (This->pClock) IReferenceClock_AddRef(This->pClock); } LeaveCriticalSection(&This->csFilter); return S_OK; }
static ULONG WINAPI TransformFilter_Release(IBaseFilter * iface) { TransformFilterImpl *This = (TransformFilterImpl *)iface; ULONG refCount = InterlockedDecrement(&This->refCount); TRACE("(%p/%p)->() Release from %d\n", This, iface, refCount + 1); if (!refCount) { ULONG i; if (This->pClock) IReferenceClock_Release(This->pClock); for (i = 0; i < This->npins; i++) { IPin *pConnectedTo; if (SUCCEEDED(IPin_ConnectedTo(This->ppPins[i], &pConnectedTo))) { IPin_Disconnect(pConnectedTo); IPin_Release(pConnectedTo); } IPin_Disconnect(This->ppPins[i]); IPin_Release(This->ppPins[i]); } CoTaskMemFree(This->ppPins); This->lpVtbl = NULL; This->csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->csFilter); TRACE("Destroying transform filter\n"); FreeMediaType(&This->pmt); CoTaskMemFree(This); return 0; } else return refCount; }
ULONG WINAPI BaseFilterImpl_Release(IBaseFilter * iface) { BaseFilter *This = (BaseFilter *)iface; ULONG refCount = InterlockedDecrement(&This->refCount); TRACE("(%p)->() Release from %d\n", This, refCount + 1); if (!refCount) { if (This->pClock) IReferenceClock_Release(This->pClock); This->lpVtbl = NULL; This->csFilter.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->csFilter); } return refCount; }
static ULONG WINAPI SynthPortImpl_IDirectMusicPort_Release(LPDIRECTMUSICPORT iface) { SynthPortImpl *This = impl_from_SynthPortImpl_IDirectMusicPort(iface); ULONG ref = InterlockedDecrement(&This->ref); TRACE("(%p)->(): new ref = %u\n", This, ref); if (!ref) { IDirectMusicSynth_Activate(This->synth, FALSE); IDirectMusicSynth_Close(This->synth); IDirectMusicSynth_Release(This->synth); IDirectMusicSynthSink_Release(This->synth_sink); IReferenceClock_Release(This->pLatencyClock); HeapFree(GetProcessHeap(), 0, This); } DMUSIC_UnlockModule(); return ref; }
/* Cleanup at end of life */ static void SampleGrabber_cleanup(SG_Impl *This) { TRACE("(%p)\n", This); if (This->info.pGraph) WARN("(%p) still joined to filter graph %p\n", This, This->info.pGraph); if (This->allocator) IMemAllocator_Release(This->allocator); if (This->refClock) IReferenceClock_Release(This->refClock); if (This->memOutput) IMemInputPin_Release(This->memOutput); if (This->grabberIface) ISampleGrabberCB_Release(This->grabberIface); if (This->mtype.pbFormat) CoTaskMemFree(This->mtype.pbFormat); if (This->bufferData) CoTaskMemFree(This->bufferData); if(This->seekthru_unk) IUnknown_Release(This->seekthru_unk); This->critSect.DebugInfo->Spare[0] = 0; DeleteCriticalSection(&This->critSect); }
/* For ClassFactory */ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter) { IDirectMusic8Impl *dmusic; HRESULT ret; TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter); *ret_iface = NULL; if (unkouter) return CLASS_E_NOAGGREGATION; dmusic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusic8Impl)); if (!dmusic) return E_OUTOFMEMORY; dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl; dmusic->ref = 0; /* Will be inited by QueryInterface */ dmusic->pMasterClock = NULL; dmusic->ppPorts = NULL; dmusic->nrofports = 0; ret = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&dmusic->pMasterClock, NULL); if (FAILED(ret)) { HeapFree(GetProcessHeap(), 0, dmusic); return ret; } ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface); if (FAILED(ret)) { IReferenceClock_Release(&dmusic->pMasterClock->IReferenceClock_iface); HeapFree(GetProcessHeap(), 0, dmusic); return ret; } create_system_ports_list(dmusic); return S_OK; }
HRESULT DMUSIC_CreateSynthPortImpl(LPCGUID guid, LPVOID *object, LPUNKNOWN unkouter, LPDMUS_PORTPARAMS port_params, LPDMUS_PORTCAPS port_caps, DWORD device) { SynthPortImpl *obj; HRESULT hr = E_FAIL; int i; TRACE("(%p,%p,%p,%p,%p,%d)\n", guid, object, unkouter, port_params, port_caps, device); *object = NULL; obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SynthPortImpl)); if (!obj) return E_OUTOFMEMORY; obj->IDirectMusicPort_iface.lpVtbl = &SynthPortImpl_DirectMusicPort_Vtbl; obj->IDirectMusicPortDownload_iface.lpVtbl = &SynthPortImpl_DirectMusicPortDownload_Vtbl; obj->IDirectMusicThru_iface.lpVtbl = &SynthPortImpl_DirectMusicThru_Vtbl; obj->ref = 0; /* Will be inited by QueryInterface */ obj->fActive = FALSE; obj->params = *port_params; obj->caps = *port_caps; hr = DMUSIC_CreateReferenceClockImpl(&IID_IReferenceClock, (LPVOID*)&obj->pLatencyClock, NULL); if (hr != S_OK) { HeapFree(GetProcessHeap(), 0, obj); return hr; } if (SUCCEEDED(hr)) hr = CoCreateInstance(&CLSID_DirectMusicSynth, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynth, (void**)&obj->synth); if (SUCCEEDED(hr)) hr = CoCreateInstance(&CLSID_DirectMusicSynthSink, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicSynthSink, (void**)&obj->synth_sink); if (SUCCEEDED(hr)) hr = IDirectMusicSynth_SetMasterClock(obj->synth, obj->pLatencyClock); if (SUCCEEDED(hr)) hr = IDirectMusicSynthSink_SetMasterClock(obj->synth_sink, obj->pLatencyClock); if (SUCCEEDED(hr)) hr = IDirectMusicSynth_SetSynthSink(obj->synth, obj->synth_sink); if (SUCCEEDED(hr)) hr = IDirectMusicSynth_Open(obj->synth, port_params); if (0) { if (port_params->dwValidParams & DMUS_PORTPARAMS_CHANNELGROUPS) { obj->nrofgroups = port_params->dwChannelGroups; /* Setting default priorities */ for (i = 0; i < obj->nrofgroups; i++) { TRACE ("Setting default channel priorities on channel group %i\n", i + 1); obj->group[i].channel[0].priority = DAUD_CHAN1_DEF_VOICE_PRIORITY; obj->group[i].channel[1].priority = DAUD_CHAN2_DEF_VOICE_PRIORITY; obj->group[i].channel[2].priority = DAUD_CHAN3_DEF_VOICE_PRIORITY; obj->group[i].channel[3].priority = DAUD_CHAN4_DEF_VOICE_PRIORITY; obj->group[i].channel[4].priority = DAUD_CHAN5_DEF_VOICE_PRIORITY; obj->group[i].channel[5].priority = DAUD_CHAN6_DEF_VOICE_PRIORITY; obj->group[i].channel[6].priority = DAUD_CHAN7_DEF_VOICE_PRIORITY; obj->group[i].channel[7].priority = DAUD_CHAN8_DEF_VOICE_PRIORITY; obj->group[i].channel[8].priority = DAUD_CHAN9_DEF_VOICE_PRIORITY; obj->group[i].channel[9].priority = DAUD_CHAN10_DEF_VOICE_PRIORITY; obj->group[i].channel[10].priority = DAUD_CHAN11_DEF_VOICE_PRIORITY; obj->group[i].channel[11].priority = DAUD_CHAN12_DEF_VOICE_PRIORITY; obj->group[i].channel[12].priority = DAUD_CHAN13_DEF_VOICE_PRIORITY; obj->group[i].channel[13].priority = DAUD_CHAN14_DEF_VOICE_PRIORITY; obj->group[i].channel[14].priority = DAUD_CHAN15_DEF_VOICE_PRIORITY; obj->group[i].channel[15].priority = DAUD_CHAN16_DEF_VOICE_PRIORITY; } } } if (SUCCEEDED(hr)) return IDirectMusicPort_QueryInterface((LPDIRECTMUSICPORT)obj, guid, object); if (obj->synth) IDirectMusicSynth_Release(obj->synth); if (obj->synth_sink) IDirectMusicSynthSink_Release(obj->synth_sink); if (obj->pLatencyClock) IReferenceClock_Release(obj->pLatencyClock); HeapFree(GetProcessHeap(), 0, obj); return hr; }
static void test_wmreader_interfaces(void) { HRESULT hr; IWMReader *reader; IWMReaderAdvanced *advanced; IWMReaderAdvanced2 *advanced2; IWMHeaderInfo *header; IWMHeaderInfo2 *header2; IWMHeaderInfo3 *header3; IWMProfile *profile; IWMProfile2 *profile2; IWMProfile3 *profile3; IWMPacketSize *packet; IWMPacketSize2 *packet2; IWMReaderAccelerator *accel; IWMReaderTimecode *timecode; IWMReaderNetworkConfig *netconfig; IWMReaderNetworkConfig2 *netconfig2; IWMReaderStreamClock *clock; IWMReaderTypeNegotiation *negotiation; IWMDRMReader *drmreader; IWMDRMReader2 *drmreader2; IWMDRMReader3 *drmreader3; IWMReaderPlaylistBurn *playlist; IWMLanguageList *langlist; IReferenceClock *refclock; hr = WMCreateReader( NULL, 0, &reader ); ok(hr == S_OK, "WMCreateReader failed 0x%08x\n", hr); if(FAILED(hr)) { win_skip("Failed to create IWMReader\n"); return; } hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAdvanced, (void **)&advanced); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAdvanced2, (void **)&advanced2); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo, (void **)&header); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo2, (void **)&header2); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMHeaderInfo3, (void **)&header3); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMProfile, (void **)&profile); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMProfile2, (void **)&profile2); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMProfile3, (void **)&profile3); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMPacketSize, (void **)&packet); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMPacketSize2, (void **)&packet2); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderAccelerator, (void **)&accel); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderTimecode, (void **)&timecode); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderNetworkConfig, (void **)&netconfig); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderNetworkConfig2, (void **)&netconfig2); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderStreamClock, (void **)&clock); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderTypeNegotiation, (void **)&negotiation); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader, (void **)&drmreader); ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader2, (void **)&drmreader2); ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMDRMReader3, (void **)&drmreader3); ok(hr == E_NOINTERFACE, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMReaderPlaylistBurn, (void **)&playlist); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IWMLanguageList, (void **)&langlist); ok(hr == S_OK, "Failed 0x%08x\n", hr); hr = IWMReader_QueryInterface(reader, &IID_IReferenceClock, (void **)&refclock); ok(hr == S_OK, "Failed 0x%08x\n", hr); if(packet) IWMPacketSize_Release(packet); if(packet2) IWMPacketSize2_Release(packet2); if(advanced) IWMReaderAdvanced_Release(advanced); if(advanced2) IWMReaderAdvanced2_Release(advanced2); if(profile) IWMProfile_Release(profile); if(profile2) IWMProfile2_Release(profile2); if(profile3) IWMProfile3_Release(profile3); if(header) IWMHeaderInfo_Release(header); if(header2) IWMHeaderInfo2_Release(header2); if(header3) IWMHeaderInfo3_Release(header3); if(accel) IWMReaderAccelerator_Release(accel); if(timecode) IWMReaderTimecode_Release(timecode); if(netconfig) IWMReaderNetworkConfig_Release(netconfig); if(netconfig2) IWMReaderNetworkConfig2_Release(netconfig2); if(clock) IWMReaderStreamClock_Release(clock); if(negotiation) IWMReaderTypeNegotiation_Release(negotiation); if(playlist) IWMReaderPlaylistBurn_Release(playlist); if(langlist) IWMLanguageList_Release(langlist); if(refclock) IReferenceClock_Release(refclock); IWMReader_Release(reader); }