示例#1
0
        private void OnValueChanged(object sender, System.EventArgs e)
        {
            int hr;

            hr = tuner.put_Channel((int)nudChannel.Value, 0, 0);
            DsError.ThrowExceptionForHR(hr);
        }
示例#2
0
 void Network_ChannelSet(int new_channel)
 {
     if (this.InvokeRequired)
     {
         Network.SimpleIntEvent d = new Network.SimpleIntEvent(Network_ChannelSet);
         this.Invoke(d, new object[] { new_channel });
     }
     else
     {
         if (new_channel >= min_channel && new_channel <= max_channel)
         {
             tuner.put_Channel(new_channel, AMTunerSubChannel.Default, AMTunerSubChannel.Default);
             tuner.get_Channel(out channel, out sub_channel, out sub_channel2);
             Network.SendStatus(channel, volume, (this.currentState == PlayState.Running));
         }
     }
 }
示例#3
0
        /// <summary>
        ///  Determines if the tuner can tune to a particular channel.
        /// </summary>
        /// <remarks>
        ///  <para>
        ///  An automated scan to find available channels:
        ///  <list type="number">
        ///   <item>Use <see cref="ChanelMinMax"/> to determine
        ///			the range of available channels.</item>
        ///   <item>For each channel, call ChannelAvailable. If this method returns false, do not
        ///			display the channel to the user. If this method returns true, it
        ///			will have found the exact frequency for the channel.</item>
        ///	  <item>If ChannelAvailable is finding too many channels with just noise then
        ///			check the <see cref="SignalPresent"/> property after calling ChannelAvailable.
        ///			If SignalPresent is true, then the channel is most likely a valid, viewable
        ///			channel. However this risks missing viewable channels with moderate noise.
        ///			See <see cref="SignalPresent"/> for more information on locking on to
        ///			a channel.</item>
        ///  </list>
        ///  </para>
        ///
        ///  <para>
        ///  It is no longer required to perform a scan for each chanel's exact
        ///  frequency. The tuner automatically finds the exact frequency each
        ///  time the channel is changed. </para>
        ///
        ///  <para>
        ///  This method correctly uses frequency-overrides. As described in
        ///  the DirectX SDK topic "Collecting Fine-Tuning Information", this method
        ///  does not use the IAMTVTuner.AutoTune() method. Instead it uses the
        ///  suggested put_Channel() method. </para>
        /// </remarks>
        /// <param name="channel">TV channel number</param>
        /// <returns>True if the channel's frequence was found, false otherwise.</returns>
        public bool ChannelAvailable(int channel)
        {
            int hr = tvTuner.put_Channel(channel, AMTunerSubChannel.Default, AMTunerSubChannel.Default);

            if (hr < 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            return(hr == 0);
        }
示例#4
0
        public void TestChannel()
        {
            int hr = 0;
            int chan1, chan2;
            AMTunerSubChannel vidSubChan, audSubChan;

            hr = tuner.get_Channel(out chan1, out vidSubChan, out audSubChan);
            DsError.ThrowExceptionForHR(hr);
            Debug.Assert(hr == 0, "IAMTVTuner.get_Channel");

            hr = tuner.put_Channel(chan1 + 1, AMTunerSubChannel.Default, AMTunerSubChannel.Default);
            DsError.ThrowExceptionForHR(hr);
            Debug.Assert(hr == 0, "IAMTVTuner.put_Channel");

            hr = tuner.get_Channel(out chan2, out vidSubChan, out audSubChan);
            DsError.ThrowExceptionForHR(hr);
            Debug.Assert(chan2 == (chan1 + 1), "IAMTVTuner.get / put_Channel");
        }
示例#5
0
        protected override void SetChannel(Channel channel)
        {
            if (channel == null)
            {
                throw new ArgumentNullException("channel", "Can't set channel!");
            }
            if ((channel.PhysicalChannel == -1) && (channel.MajorChannel == -1))
            {
                throw new ArgumentException("Can't set channel, PhysicalChannel or MajorChannel must be set", "channel");
            }
            if (_amTvTuner == null)
            {
                throw new ArgumentNullException("_amTvTuner", "Can't set channel!");
            }

            int hr = _amTvTuner.put_Channel(channel.PhysicalChannel != -1 ? channel.PhysicalChannel : channel.MajorChannel, 0, 0);

            DsError.ThrowExceptionForHR(hr);
        }
 /// <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);
 }