private int getDeviceID(IBaseFilter tunerFilter)
        {
            IKsPin pKsPin = DsFindPin.ByDirection(tunerFilter, PinDirection.Output, 0) as IKsPin;

            if (pKsPin != null)
            {
                IntPtr raw;
                reply = pKsPin.KsQueryMediums(out raw);
                DsError.ThrowExceptionForHR(reply);

                try
                {
                    RegPinMedium rpm;

                    IntPtr addr = new IntPtr(raw.ToInt32() + 8);
                    rpm = (RegPinMedium)Marshal.PtrToStructure(addr, typeof(RegPinMedium));
                    return((int)rpm.dw1);
                }
                finally
                {
                    if (IntPtr.Zero != raw)
                    {
                        Marshal.FreeCoTaskMem(raw);
                    }
                }
            }

            return(-1);
        }
Exemplo n.º 2
0
        private void DumpPinMediumTest()
        {
            int hr;

            IntPtr         ip     = IntPtr.Zero;
            IKsPin         pKsPin = m_IPinOut as IKsPin;
            KSMultipleItem pmi    = new KSMultipleItem();

            // KsQueryMediums returns a KSMultipleItem immediately followed by
            // KSMultipleItem.Count instances of PinMedium
            hr = pKsPin.KsQueryMediums(out ip);
            Marshal.ThrowExceptionForHR(hr);

            try
            {
                // Read the KSMultipleItem
                Marshal.PtrToStructure(ip, pmi);
                Debug.Assert(pmi.Count > 0, "Medium count");

                if (pmi.Count > 0)
                {
                    RegPinMedium pTemp = new RegPinMedium();
                    ip = (IntPtr)(ip.ToInt32() + Marshal.SizeOf(typeof(KSMultipleItem)));

                    for (int i = 0; i < pmi.Count; i++)
                    {
                        // Read the PinMedium
                        Marshal.PtrToStructure(ip, pTemp);
                        Debug.WriteLine(string.Format("{0} ({1}) ({2})", pTemp.clsMedium, pTemp.dw1, pTemp.dw2));
                    }
                }
            }
            finally
            {
                Marshal.FreeCoTaskMem(ip);
            }
        }