Example #1
0
        protected ArrayList findAudioSources(ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter)
        {
            ArrayList          sources         = new ArrayList();
            IAMAudioInputMixer audioInputMixer = deviceFilter as IAMAudioInputMixer;

            if (audioInputMixer != null)
            {
                // Get a pin enumerator off the filter
                IEnumPins pinEnum;
                int       hr = deviceFilter.EnumPins(out pinEnum);
                pinEnum.Reset();
                if ((hr == 0) && (pinEnum != null))
                {
                    // Loop through each pin
                    IPin[] pins = new IPin[1];
#if VS2003 || DSHOWNET
                    int f;
#else
                    IntPtr f = IntPtr.Zero;
#endif
                    do
                    {
                        // Get the next pin
#if VS2003 || DSHOWNET
                        hr = pinEnum.Next(1, pins, out f);
#else
                        hr = pinEnum.Next(1, pins, f);
#endif
                        if ((hr == 0) && (pins[0] != null))
                        {
                            // Is this an input pin?
                            PinDirection dir = PinDirection.Output;
                            hr = pins[0].QueryDirection(out dir);
                            if ((hr == 0) && (dir == (PinDirection.Input)))
                            {
                                // Add the input pin to the sources list
                                AudioSource source = new AudioSource(pins[0]);
                                sources.Add(source);
                            }
                            pins[0] = null;
                        }
                    }while(hr == 0);

                    Marshal.ReleaseComObject(pinEnum); pinEnum = null;
                }
            }

            // If there is only one source, don't return it
            // because there is nothing for the user to choose.
            // (Hopefully that single source is already enabled).
            if (sources.Count == 1)
            {
                sources.Clear();
            }

            return(sources);
        }
Example #2
0
        public void DoTests()
        {
            // Get an audio device
            m_AudioFilter = GetAudioFilter();

            // While some IAMAudioImputMixer methods work on both filters
            // and pins, some (like Enable) require a pin.  Get the first input pin.
            IPin inPin = DsFindPin.ByDirection(m_AudioFilter, PinDirection.Input, 0);

            // QI to an IAMAudioInputMixer
            m_iaim = inPin as IAMAudioInputMixer;

            try
            {
                TestMixLevel();
                TestEnable();
                TestMono();
                TestLoudness();
                TestBass();
                TestTreble();
                TestPan();
            }
            finally
            {
                if (m_AudioFilter != null)
                {
                    Marshal.ReleaseComObject(m_AudioFilter);
                    m_AudioFilter = null;
                }
                if (inPin != null)
                {
                    Marshal.ReleaseComObject(inPin);
                    inPin = null;
                }

                m_iaim = null;
            }
        }