Microsoft DirectX 9.0

Collecting Fine-Tuning Information

Although cable frequencies are generally expected to be exact, broadcast frequencies may be adjusted up or down several kHz by the broadcast station to reduce potential interference with neighboring channels.

When the TV Tuner filter tunes to a channel, it scans for the most precise signal. To save this information in the registry for subsequent tune operations, do the following:

  1. Call IAMTuner::ChannelMinMax to determine the range of frequency entries in the current frequency table.
  2. Call the IAMTuner::put_Channel method once for each frequency index in the range.
  3. Call IAMTVTuner::StoreAutoTune to save the fine-tuning information in the registry. The information is stored under the registry key for the current tuning space.

The following code shows these steps:

long lMin = 0, lMax = 0;
hr = pTuner->ChannelMinMax(&lMin, &lMax);
if (SUCCEEDED(hr))
{
    for (long i = lMin; i <= lMax; i++)
    {
        pTuner->put_Channel(i, AMTUNER_SUBCHAN_DEFAULT,
            AMTUNER_SUBCHAN_DEFAULT)
    }
    pTuner->StoreAutoTune();
}

With earlier versions of the TV Tuner filter, the IAMTVTuner::AutoTune method was recommended for fine-tuning. However, this method ignores any frequency overrides, so its use is no longer recommended. The following code is equivalent to the AutoTune method, but works correctly with frequency overrides:

HRESULT MyAutoTune(IAMTVTuner *pTuner, long lIndex, long *plFoundSignal)
{
    long SignalStrength = AMTUNER_NOSIGNAL;
    HRESULT hr;
    hr = pTuner->put_Channel(lIndex, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
    if (NOERROR == hr)
        pTuner->SignalPresent(&SignalStrength);
    *plFoundSignal = (SignalStrength != AMTUNER_NOSIGNAL);
    // Assume AMTUNER_HASNOSIGNALSTRENGTH means tuned
    return hr;
}

With broadcast reception, it is not always possible to get a horizontal lock, although the picture is viewable. In these cases, the tuner hardware will have a frequency lock, but the decoder won't have horizontal lock. This condition can be detected when using put_Channel or AutoTune by examining the return code.

Value Description
S_OK The tune operation succeeded and the tuner got a frequency lock.
S_FALSE There were no errors in during the tune operation, but the tuner was not able to get a frequency lock. It is highly unlikely that there is a viewable channel resulting from this operation.

Any other return code indicates some error occurred.

A return value of S_OK does not guarantee that the decoder has a horizontal lock. The AutoTune method updates the FoundSignal parameter to indicate whether or not horizontal lock was achieved. The IAMTuner::SignalPresent method returns the same information.

When the return value is S_OK, however, the application has the option of ignoring the FoundSignal parameter, because the tuner is reporting a frequency lock. There is the possibility of a frequency lock on noise, but this possibility should be weighed against the possibility of skipping viewable channels.

Registry Conversion

In order to support frequency overrides, the internal format of the registry key that holds fine-tuning information has changed. The original format is still supported for backward compatibility, but it does not support frequency overrides.

The old registry format is converted to the new format whenever the IAMTVTuner::StoreAutoTune method is called. If your application adds frequency overrides, it should call the StoreAutoTune method in order to convert to the new registry format. It is not necessary to collect any fine-tuning information before calling StoreAutoTune.