public void TestCountryCode() { int hr = 0; int code1, code2; hr = tuner.get_CountryCode(out code1); DsError.ThrowExceptionForHR(hr); Debug.Assert(hr == 0, "IAMTVTuner.get_CountryCode"); hr = tuner.put_CountryCode(code1 + 1); DsError.ThrowExceptionForHR(hr); Debug.Assert(hr == 0, "IAMTVTuner.put_CountryCode"); hr = tuner.get_CountryCode(out code2); DsError.ThrowExceptionForHR(hr); Debug.Assert(code2 == (code1 + 1), "IAMTVTuner.get / put_CountryCode"); }
/// <summary> /// Performs a tuning to the given channel /// </summary> /// <param name="analogChannel">The channel to tune to</param> public void PerformTune(AnalogChannel analogChannel) { if (_tuner == null || analogChannel == null) { throw new NullReferenceException(); } if (analogChannel.IsTv) { SetFrequencyOverride(analogChannel); } if (_currentChannel != null) { if (analogChannel.IsRadio != _currentChannel.IsRadio) { if (analogChannel.IsRadio) { Log.Log.WriteFile("analog: set to FM radio"); _tuner.put_Mode(AMTunerModeType.FMRadio); } else { Log.Log.WriteFile("analog: set to TV"); _tuner.put_Mode(AMTunerModeType.TV); } } if (analogChannel.Country.Id != _currentChannel.Country.Id) { _tuner.put_TuningSpace(analogChannel.Country.Id); _tuner.put_CountryCode(analogChannel.Country.Id); } if (analogChannel.TunerSource != _currentChannel.TunerSource) { _tuner.put_InputType(0, analogChannel.TunerSource); } if (analogChannel.IsRadio) { if (analogChannel.Frequency != _currentChannel.Frequency) { _tuner.put_Channel((int)analogChannel.Frequency, AMTunerSubChannel.Default, AMTunerSubChannel.Default); } } else { if (analogChannel.ChannelNumber != _currentChannel.ChannelNumber) { _tuner.put_Channel(analogChannel.ChannelNumber, AMTunerSubChannel.Default, AMTunerSubChannel.Default); } } } else { if (analogChannel.IsRadio) { Log.Log.WriteFile("analog: set to FM radio"); _tuner.put_Mode(AMTunerModeType.FMRadio); } else { Log.Log.WriteFile("analog: set to TV"); _tuner.put_Mode(AMTunerModeType.TV); } _tuner.put_TuningSpace(analogChannel.Country.Id); _tuner.put_CountryCode(analogChannel.Country.Id); _tuner.put_InputType(0, analogChannel.TunerSource); if (analogChannel.IsRadio) { _tuner.put_Channel((int)analogChannel.Frequency, AMTunerSubChannel.Default, AMTunerSubChannel.Default); } else { _tuner.put_Channel(analogChannel.ChannelNumber, AMTunerSubChannel.Default, AMTunerSubChannel.Default); } } _tuner.get_VideoFrequency(out _videoFrequency); _tuner.get_AudioFrequency(out _audioFrequency); _tunerLocked = false; _currentChannel = analogChannel; UpdateSignalQuality(); UpdateMinMaxChannel(); Log.Log.WriteFile("Analog: Tuned to country:{0} video:{1} Hz audio:{2} Hz locked:{3}", analogChannel.Country.Id, _videoFrequency, _audioFrequency, _tunerLocked); }