public int RequestAllocator(IMemAllocator pPreferred, AllocatorProperties pProps, out IMemAllocator ppActual) { int hr; Debug.WriteLine(string.Format("RequestAllocator {0} Align: {1} Buffer: {2} #: {3}", pPreferred != null, pProps.cbAlign, pProps.cbBuffer, pProps.cBuffers)); Debug.Assert(pPreferred != null, "No allocator provided"); // Need to set it to something. Let's hope for the best. ppActual = pPreferred; lock (this) // Protect the m_ variables { // Release any previous allocator if ((m_MemAlloc != null) && (m_MemAlloc != pPreferred)) { Marshal.ReleaseComObject(m_MemAlloc); m_MemAlloc = null; } if (pPreferred != null) { m_MemAlloc = pPreferred; hr = S_Ok; } else { // Todo - In theory, we should provide our own allocator if one isn't offered. // In practice, no one accepts an allocator if I offer one. hr = E_Fail; } } return(hr); }
/// <summary> /// Ändert die zu verwendende Speicherverwaltung. /// </summary> /// <param name="allocator">Die neue Speicherverwaltung.</param> /// <param name="bReadOnly">Gesetzt, wenn auf die Speicherverwaltung nur lesend zugegriffen werden darf.</param> public void NotifyAllocator(IMemAllocator allocator, bool bReadOnly) { // Cleanup BDAEnvironment.Release(ref m_Allocator); // Remember m_AllocatorReadOnly = bReadOnly; m_Allocator = allocator; }
/// <summary> /// Meldet die aktuelle Speicherverwaltung. /// </summary> /// <returns>Die gerade verwendete Speicherverwaltung.</returns> public IMemAllocator GetAllocator() { // Create on first call if (m_Allocator == null) { m_Allocator = (IMemAllocator)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("1e651cc0-b199-11d0-8212-00c04fc32c45"))); } // Report return(m_Allocator); }
int IAsyncReader.RequestAllocator(IMemAllocator pPreferred, AllocatorProperties pProps, out IMemAllocator ppActual) { if (pPreferred != null) { ppActual = pPreferred; if (pProps != null) { pPreferred.GetProperties(pProps); } return(S_OK); } ppActual = null; return(E_FAIL); }
/// <summary> /// Trennt diesen Endpunkt von allen anderen. /// </summary> public void Disconnect() { // Release BDAEnvironment.Release(ref m_Allocator); BDAEnvironment.Release(ref m_Connected); // Release m_ConnectType.Dispose(); m_ConnectType = new MediaType(); // Reset m_AllocatorReadOnly = false; m_Connected = IntPtr.Zero; m_Allocator = null; }
private void ShowAllocatorProperties(object sender, EventArgs e) { if (connectingPin != null) { IMemInputPin imip = connectingPin.IPin as IMemInputPin; if (imip != null) { IMemAllocator ma = null; imip.GetAllocator(out ma); if (ma != null) { AllocatorProperties pr = new AllocatorProperties(); ma.GetProperties(pr); Program.mainform.propform.SetObject(new FieldsToPropertiesProxyTypeDescriptor(pr)); } } } connectingPin = null; }
int IAsyncReader.RequestAllocator(IMemAllocator pPreferred, AllocatorProperties pProps, out IMemAllocator ppActual) { if (pPreferred != null) { ppActual = pPreferred; if (pProps != null) pPreferred.GetProperties(pProps); return S_OK; } ppActual = null; return E_FAIL; }
public int RequestAllocator(IMemAllocator pPreferred, AllocatorProperties pProps, out IMemAllocator ppActual) { ppActual = null; return(1); }
private void Setup() { m_ma = new MemoryAllocator() as IMemAllocator; }
public int RequestAllocator(IMemAllocator pPreferred, AllocatorProperties pProps, out IMemAllocator ppActual) { // always use their allocator if (pPreferred != null) { ppActual = pPreferred; allocator = pPreferred; return S_OK; } else { ppActual = null; return E_NOTIMPL; } }
public int Disconnect() { int ans = S_FALSE; Monitor.Enter(this); if (pin != null) { if (allocator != null) { allocator.Decommit(); } string id = "Unnamed pin"; pin.QueryId(out id); log.InfoFormat("Disconnect from pin '{0}'", id); pin = null; pintype = null; allocator = null; ans = S_OK; } Monitor.Exit(this); return ans; }
public int Connect(IPin pReceivePin, AMMediaType pmt) { Monitor.Enter(this); int hr = S_OK; pin = null; pintype = null; allocator = null; string id = "Unnamed pin"; pReceivePin.QueryId(out id); PinInfo pi = new PinInfo(); hr = pReceivePin.QueryPinInfo(out pi); if (hr == S_OK) { FilterInfo fi = new FilterInfo(); hr = pi.filter.QueryFilterInfo(out fi); if (hr == S_OK) { id += (" (" + fi.achName); } Guid guid; hr = pi.filter.GetClassID(out guid); if (hr == S_OK) { id += (", " + guid.ToString()); } id += ")"; } try { AMMediaType amt = null; if (pmt != null) { amt = pmt; } else #if false { IEnumMediaTypes ie; hr = pReceivePin.EnumMediaTypes(out ie); int fetched; int alloc = Marshal.SizeOf(typeof(AMMediaType)); IntPtr mtypePtr = Marshal.AllocCoTaskMem(alloc); while (ie.Next(1, mtypePtr, out fetched) == S_OK) { amt = new AMMediaType(); Marshal.PtrToStructure(mtypePtr, amt); hr = pReceivePin.QueryAccept(amt); if (hr == S_OK) { break; } DsUtils.FreeAMMediaType(amt); amt = null; } if (fetched == 0) { amt = null; } Marshal.FreeCoTaskMem(mtypePtr); } if (amt == null) #endif { amt = mediatype; } hr = pReceivePin.QueryAccept(amt); if (hr == S_FALSE) { log.InfoFormat("No media type for pin '{0}'", id); Monitor.Exit(this); return VFW_E_NO_ACCEPTABLE_TYPES; } hr = pReceivePin.ReceiveConnection(this, amt); if (hr == VFW_E_TYPE_NOT_ACCEPTED) { log.InfoFormat("No connection to pin '{0}'", id); Monitor.Exit(this); return VFW_E_NO_ACCEPTABLE_TYPES; } DsError.ThrowExceptionForHR(hr); pin = pReceivePin; pintype = amt; } catch (Exception e) { LogUtil.ExceptionLog.ErrorFormat("Caught exception in connect ({0}): {1}{2}", id, e.Message, e.StackTrace); pin = null; pintype = null; allocator = null; Monitor.Exit(this); return VFW_E_NO_TRANSPORT; } Monitor.Exit(this); log.InfoFormat("Connected to pin '{0}'", id); return S_OK; }