/// <summary> /// Creates the tuner filter instance /// </summary> /// <param name="graph">The stored graph</param> /// <param name="graphBuilder">The graphbuilder</param> /// <returns>true, if the graph building was successful</returns> public bool CreateFilterInstance(Graph graph, IFilterGraph2 graphBuilder) { Log.Log.WriteFile("analog: AddTvTunerFilter {0}", _tunerDevice.Name); if (DevicesInUse.Instance.IsUsed(_tunerDevice)) { return(false); } IBaseFilter tmp; int hr; try { hr = graphBuilder.AddSourceFilterForMoniker(_tunerDevice.Mon, null, _tunerDevice.Name, out tmp); } catch (Exception) { Log.Log.WriteFile("analog: cannot add filter to graph"); return(false); } if (hr != 0) { Log.Log.Error("analog: AddTvTunerFilter failed:0x{0:X}", hr); throw new TvException("Unable to add tvtuner to graph"); } _filterTvTuner = tmp; DevicesInUse.Instance.Add(_tunerDevice); _tuner = _filterTvTuner as IAMTVTuner; if (string.IsNullOrEmpty(graph.Tuner.Name) || !_tunerDevice.Name.Equals( graph.Tuner.Name)) { Log.Log.WriteFile("analog: Detecting capabilities of the tuner"); graph.Tuner.Name = _tunerDevice.Name; int index; _audioPin = FilterGraphTools.FindMediaPin(_filterTvTuner, MediaType.AnalogAudio, MediaSubType.Null, PinDirection.Output, out index); graph.Tuner.AudioPin = index; return(CheckCapabilities(graph)); } Log.Log.WriteFile("analog: Using stored capabilities of the tuner"); _audioPin = DsFindPin.ByDirection(_filterTvTuner, PinDirection.Output, graph.Tuner.AudioPin); _supportsFMRadio = (graph.Tuner.RadioMode & RadioMode.FM) != 0; _supportsAMRadio = (graph.Tuner.RadioMode & RadioMode.AM) != 0; return(true); }