xxxxx@sunplusct.com wrote:
Hi Tim,
Thanks for your reply!
>> in all your exploration, you never encountered the function KsGetDeviceForDeviceObject?
>>
I use following codes to get device pointer:
BOOL CCaptureDevice::Isr_DSPIRQ(PKINTERRUPT Interupt, PVOID ServiceContext)
{
PDEVICE_OBJECT FdoData = (PDEVICE_OBJECT)ServiceContext;
PKSDEVICE pDevice;
pDevice=KsGetDeviceForDeviceObject(FdoData);
…
}
But the system crashes when it goes to ‘KsGetDeviceForDeviceObject’.
Do you know what’s the reason?
You probably need to set a breakpoint on that statement or use KdPrint
to make sure that ServiceContext really contains your device object. As
long as you are passing the correct device object to IoConnectInterrupt,
it should work fine.
The reason is as in following:
I use Graphedit to test, and the connection is as below:
DeviceA –> my transform filter –> Render
DeviceB –> my transform filter –> Render
There are some setting values in my design and I save the values in registry. The setting value in DeviceA and DeviceB may be different.
For example, I may set resolution heigh for DeviceA and set resolution low for DeviceB. And I will set following values in registry:
HKLM,Software\Spect\DevA"Resolution",0x10001,0x01
HKLM,Software\Spect\DevB"Resolution",0x10001,0x00
Since DeviceA and Device B share the same transform filter, the transform filter needs to distinguish which source filter is connecting to it.
But how do you tell them apart physically? You don’t, right? All you
care about is that they use different registry settings. All you need
to do is make sure that the “first” device uses one set of registry
keys, and the “second” device uses another set of registry keys, for
some definition of “first” and “second”. You don’t care which slot the
“first” device is in, right? If so, then that’s easy. There are
SEVERAL ways to do this.
You can tell the two devices apart by fetching the UINumber from the
DEVICE_CAPABILITIES structure in the QueryCapabilities callback in your
KSDEVICE_DISPATCH structure. That number will be different for the two
boards. You could, for example, make that available as a custom
property that your transform filter could query. That way, it could
save its state using that UINumber as a subkey.
Alternatively, you could just keep an “instance number” as a static
global in your driver. Every time you create a new filter, save the
“instance number” and bump it for next time. Again, you report that as
a property. so the transform filter can tell the difference between
“first” and “second”.
As for my original design, the transform filter use following method to get the upstream:
pUpstream->QueryFilterInfo(&Info);
So, the transform filter can get source filter’s name from ‘Info.achName’. For instance, if the filter get the source filter’s name as ‘DeviceB’, then it will read following registry path to get the setting value:
Software\Spect\DevB"Resolution"
However, if my 2 devices have the same source filter name, how can I tell the transform filter which source filter is connecting to it?
Do you know how to solve the problem
There are many, many, many ways to solve this problem. Duplicating
driver code is absolutely the WRONG way to do it.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.