開發我的DirectShow應用程序時出現奇怪的問題。我正在使用Delphi 6與DSPACK DirectShow組件庫。當我嘗試使用TPinInfo.achName屬性(_PinInfo)在過濾器中查找引腳時,其中一個IBaseFilter實例似乎無法識別它擁有的引腳。 (注意,在這種情況下,它是TSampleGrabber組件創建的IBaseFilter,它表現出這種奇怪的行爲)。儘管它是由QueryPinInfo返回的ID,但無法通過名稱/ ID在DirectShow過濾器中找到引腳
事件,封裝下面的代碼示例中的序列是這樣的:
- 查找在IBaseFilter實例的第一個可用的輸入引腳。在下面的代碼中,這是傳遞給testPinInfo()的引腳。
- 在返回的引腳上執行QueryPinInfo()以獲取該信息。返回的信息顯示pin的achName爲'Input'。
- 嘗試使用IBaseFilter.findPin()在相同的IBaseFilter實例中找到名爲'Input'的引腳。
- 返回NIL指示無法找到該名稱的PIN。這在我看來是一個非常奇怪的情況(錯誤)。
有誰知道什麼樣的條件可能會導致這種情況?我不認爲這是內存損壞問題,因爲當我在調試器中檢查它們時,涉及的數據結構看起來很好。有些IBaseFilter實現可能忽略正確實現FindPin()方法嗎?
這裏的代碼如下:
procedure testPinInfo(intfInputPin: IPin);
var
intfTestPin: IPin;
pinInfo_input: TPinInfo;
begin
intfTestPin := nil;
// Get the pin information.
ZeroMemory(@pinInfo_input, SizeOf(pinInfo_input));
intfInputPin.QueryPinInfo(pinInfo_input);
// Now immediately turn around and try to find the pin in the filter that
// owns it, using the name found in pinInfo_input
pinInfo_input.pFilter.FindPin(pinInfo_input.achName, intfTestPin);
// >>> intfTestPin is NIL (unassigned). This is an error.
end;