如何调试一个未指定的错误($80004005)在DirectShow put_Enable调用捕捉过滤器



我有一个使用DSPACK组件库在Delphi 6中编写的DirectShow应用程序。我有一个奇怪的问题,在过滤器上启用输入行。我搜索引脚,直到我找到输入线,在这种情况下命名为"麦克风",并调用put_Enable(true),而过滤图是活跃的。当我这样做时,我得到一个$80004005"未指定错误"作为HRESULT。

在启用输入行之前,我正在为过滤器设置输出音频媒体类型,但有些东西不正常工作。我用来创建应用程序的原始DirectShow示例工作得很好。我相信我正在遵循完全相同的步骤构建我的过滤器图,当然,我可能错过了一些东西。有没有人有什么建议或想法,我可以尝试解决这个问题?下面的代码片段部分显示了我正在做的事情,但不是所有的步骤,因为它们非常长。我用于测试的捕获设备是一个VOIP耳机,具有单个输入线,名为"麦克风"。

// The function I call to find an enable the first input line I find in the filter.
function findAndEnableFirstInputLineFound(intfBaseFilter: IBaseFilter; out strInputLineUsed: string): boolean;
var
    thePinList: TPinList;
    i: integer;
    ABool: LongBool;
begin
    strInputLineUsed := '';
    if not Assigned(intfBaseFilter) then
        raise Exception.Create('(findAndEnableFirstInputLineFound) The base filter interface object is unassigned.');
    // Now enable the first input source we can find.
    Result := false;
    thePinList := TPinList.Create(intfBaseFilter);
    try
        if thePinList.Count > 0 then
        begin
            // Scan the pin list looking for an input pin.
            i := 0;
            while (i < thePinList.Count) and (not Result) do
            begin
                if thePinList.PinInfo[i].dir = PINDIR_INPUT then
                begin
                    // Found one.  Enable it.
                    with thePinList.Items[i] as IAMAudioInputMixer do
                    begin
                        CheckDSEror(put_Enable(true)); // $80004005 error occurs here.
                        // Return the name of the input line used.
                        strInputLineUsed := thePinList.PinInfo[i].achName;
                    end; // with thePinList.Items[i] as IAMAudioInputMixer do
                    Result := true;
                    break; // Stop looping.
                end; // if thePinList.PinInfo[i].dir = PINDIR_INPUT then
                Inc(i);
            end; // while()
        end; // if thePinList.Count > 0 then
    finally
        thePinList.Free;
    end; // try
end;

// The initialization procedure that calls the function above.  It is run after the
//  the Filter Graph is activated but before it is played.
procedure TDXChain_wavaudio.initializeCaptureFilter;
var
    theMediaType: TMediaType;
    intfCapturePin: IPin;
    aryEnabledInputLines: TDynamicStringArray;
begin
    theMediaType := nil;
    intfCapturePin := nil;
    aryEnabledInputLines := nil;
    if not FFilterGraph.Active then
        raise Exception.Create('(TDXChain_wavaudio.Create::initializeCaptureFilter) The Filter Graph is INACTIVE.');
    if Assigned(FCaptureFilter) then
    begin
        // Make sure the Capture Filter's output pins supports the
        //   configured WAV format.
        with FOwner.ati_WaveFormatEx do
        begin
            // if not Assigned(findAudioMediaTypeByFormat(FCaptureFilter_mediatypes, nSamplesPerSec, wBitsPerSample, nChannels)) then
            theMediaType := findAudioMediaTypeExt_outputs(FCaptureFilter as IBaseFilter, nSamplesPerSec, wBitsPerSample, nChannels);
            if not Assigned(theMediaType) then
                // The capture device does not directly support the desired
                //  WAV format.  This is not allowed currently.
                raise Exception.Create('(TDXChain_wavaudio.Create::initializeCaptureFilter) The audio input device''s output pins does not support the given WAV format: '
                        + CRLF
                        + Format('(Device name: %s, Sample Rate: %d, Bits Per Sample: %d, Number of Channels: %d)',
                                    [FOwner.FCaptureFilterConfigInfo.filterName, nSamplesPerSec, wBitsPerSample, nChannels])
                    );
            // -------------- SET OUTPUT PINS TO MEDIA TYPE -------------
            // Set the output pins to the desired format.
            setPinAudMediaType_outputs(FCaptureFilter, theMediaType.AMMediaType);
            // Don't need the media type anymore.
            FreeAndNil(theMediaType);
        end; // with FOwner.ati_WaveFormatEx do
        // Enable at least one input line.
        if FOwner.FCaptureFilterConfigInfo.inputPinName = '' then
        begin
            //  No input name was specified so use the first one found.
            if not findAndEnableFirstInputLineFound(FCaptureFilter as IBaseFilter, FOwner.FInputLineUsed) then
                raise Exception.Create(
                    '(TDXChain_wavaudio.Create::initializeCaptureFilter) Unable to find a suitable input line for the audio input device named: '
                    + FOwner.FCaptureFilterConfigInfo.filterName);
        end
        else
        begin
            // Now find the desired available input line and enable it.
            if not findAndEnableInputLineByName(FOwner.FCaptureFilterConfigInfo.inputPinName, FCaptureFilter as IBaseFilter, FOwner.FInputLineUsed) then
                raise Exception.Create(
                    '(TDXChain_wavaudio.Create::initializeCaptureFilter) Unable to find the input line named ('
                    + FOwner.FCaptureFilterConfigInfo.inputPinName
                    + ') for the audio input device named: '
                    + FOwner.FCaptureFilterConfigInfo.filterName);
        end; // else - if FOwner.FCaptureFilterConfigInfo.inputPinName = '' then
        aryEnabledInputLines := getEnabledInputLineNames(FCaptureFilter as IBaseFilter);
        if Length(aryEnabledInputLines) < 1 then
            raise Exception.Create('(TDXChain_wavaudio.Create::initializeCaptureFilter) No input lines are enabled..');
        // ------------------ BUFFER LATENCY --------------------
        // Get a reference to the output pin for audio the capture device.
        with FCaptureFilter as IBaseFilter do
            CheckDSError(findPin(StringToOleStr('Capture'), intfCapturePin));
        if not Assigned(intfCapturePin) then
            raise Exception.Create('(TDXChain_wavaudio.Create::initializeCaptureFilter) Unable to find the audio input device''s Capture output pin.');
        // Set the capture device buffer to 50 ms worth of audio data to
        //  reduce latency.  NOTE: This will fail if the device does not
        //  support the latency you desire so make sure you watch out for that.
        setBufferLatency(intfCapturePin as IAMBufferNegotiation, FOwner.ati_BufferLatency_ms, FOwner.FMediaType);
    end; // if Assigned(FCaptureFilter) then
end;

我认为Audio Capture Filter依赖于底层硬件和驱动程序,当试图启用某些引脚混合到记录。如果底层出现错误而失败,则会将此错误转发给您。

作为一个猜测,捕获硬件可能指示一个错误,当你试图启用一个引脚时,另一个引脚已经启用,也就是说,它实际上是无法做两者的混合。

相关内容

  • 没有找到相关文章