Exemplo n.º 1
0
        public static Tuple <IBaseFilter, IBasicAudio> AddSoundRenderer(this IGraphBuilder pGraphBuilder)
        {
            var baseFilter = DsUtils.GetFilter(Clsid.DSoundRender, false);

            if (baseFilter == null)
            {
                TraceSink.GetTraceSink().TraceWarning("Could not instantiate DirectSound Filter.");
                return(null);
            }

            // add the DirectSound filter to the graph
            var hr = pGraphBuilder.AddFilter(baseFilter, "DirectSound Filter");

            if (DsHlp.FAILED(hr))
            {
                Marshal.FinalReleaseComObject(baseFilter);

                TraceSink.GetTraceSink().TraceWarning("Could not add DirectSound Filter to the filter graph.");
                return(null);
            }

            IBasicAudio basicAudio = baseFilter as IBasicAudio;

            if (basicAudio == null)
            {
                pGraphBuilder.RemoveFilter(baseFilter);
                Marshal.FinalReleaseComObject(baseFilter);

                TraceSink.GetTraceSink().TraceWarning("Could not get IBasicAudio interface.");
                return(null);
            }

            return(new Tuple <IBaseFilter, IBasicAudio>(baseFilter, basicAudio));
        }
Exemplo n.º 2
0
        public static IBaseFilter AddFilter(this IGraphBuilder pGraphBuilder, FilterDescription filterDescription)
        {
            var baseFilter = DsUtils.GetFilter(filterDescription.ClassId, true);
            var hr         = pGraphBuilder.AddFilter(baseFilter, filterDescription.Name);

            if (DsHlp.FAILED(hr))
            {
                Marshal.FinalReleaseComObject(baseFilter);

                hr.ThrowExceptionForHR();
            }

            return(baseFilter);
        }