PDA

View Full Version : Delphi LoadDeviceState/SaveDeviceState problem



diram
December 13, 2006, 13:28:26
Hello,

I have this fragment of code:



if DlgImage.ICVideo.DeviceValid then
begin

DlgImage.ICVideo.LiveStop;

end;

if Length(gSetup.ICVideo) > 0 then
begin

DlgImage.ICVideo.LoadDeviceState(gSetup.ICVideo, False);

end;

if DlgImage.ICVideo.DeviceValid then
begin

DlgImage.ICVideo.LiveStart;

end else
begin

cmdVideoSetup.Execute;

end;


Content of previuosly saved gSetup.ICVideo is:


<device_state libver="3.0" filemajor="1" fileminor="0">
<device name="Conexant&apos;s BtPCI Capture" base_name="Conexant&apos;s BtPCI Capture">
<videonorm>PAL_B</videonorm>
<videoformat>UYVY (640x480)</videoformat>
<inputchannel>02 Video: Composite</inputchannel>
<fps>25.</fps>
<vcdpropertyitems>
<item guid="{284C0E06-010B-45BF-8291-09D90A459B28}" name="Brightness">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="-735" />
</element>
</item>
<item guid="{284C0E07-010B-45BF-8291-09D90A459B28}" name="Contrast">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="119" />
</element>
</item>
<item guid="{284C0E08-010B-45BF-8291-09D90A459B28}" name="Hue">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="0" />
</element>
</item>
<item guid="{284C0E09-010B-45BF-8291-09D90A459B28}" name="Saturation">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="98" />
</element>
<element guid="{B57D3001-0AC6-4819-A609-272A33140ACA}" name="Auto">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E04}" value="0" />
</element>
</item>
<item guid="{284C0E0A-010B-45BF-8291-09D90A459B28}" name="Sharpness">
<element guid="{B57D3001-0AC6-4819-A609-272A33140ACA}" name="Auto">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E04}" value="1" />
</element>
</item>
<item guid="{284C0E0B-010B-45BF-8291-09D90A459B28}" name="Gamma">
<element guid="{B57D3001-0AC6-4819-A609-272A33140ACA}" name="Auto">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E04}" value="1" />
</element>
</item>
<item guid="{284C0E0C-010B-45BF-8291-09D90A459B28}" name="Color Enable">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="1" />
</element>
</item>
<item guid="{284C0E0D-010B-45BF-8291-09D90A459B28}" name="White Balance">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="0" />
</element>
</item>
<item guid="{284C0E0E-010B-45BF-8291-09D90A459B28}" name="Backlight Compensation">
<element guid="{B57D3000-0AC6-4819-A609-272A33140ACA}" name="Value">
<itf guid="{99B44940-BFE1-4083-ADA1-BE703F4B8E03}" value="1" />
</element>
</item>
<item guid="{90D57033-E43B-4366-AAEB-7A7A10B448B4}" name="Signal Detected" />
</vcdpropertyitems>
</device>


When I pass this xml to LoadDeviceState I will get "The device has become invalid (e.g. ...)". What is wrong? When I change OpenDevice param to True I will get exception "The operation was only partially successful, e.g. ...".

Also, the LoadDeviceState is not input protected. When config string is zerolength then procedure fails to exception "Access violation ... in msvcr71.dll".

Stefan Geissler
December 13, 2006, 15:26:24
Diram,

I guess that at entering your function you have no valid device selected. Thus the LoadDeviceState with parameter false will not open a device. and the "The device has become invalid (e.g. ...)" message is shown.

"The operation was only partially successful, e.g. ..." message is shown, if a device could have been opened, but one of the parameters seems to be wrong. A value "-735" of brightness seems to be at least doubtful. The value is returned by the WDM driver of your grabber and not manipulated by IC Imaging Control.

Pointing to the "" (zero length) problem, we will have a look at this. Thank you for reporting this issue.

diram
December 14, 2006, 12:31:19
Hello,

thank you for fast answer. I rewrote initialization code to this:



if not DlgImage.ICVideo.DeviceValid then
begin

if Length(gSetup.ICVideo) > 0 then
begin

try

DlgImage.ICVideo.LoadDeviceState(gSetup.ICVideo, True);

except

on E: EOleException do

if Cardinal(E.ErrorCode) <> ICError_INCOMPLETE then
begin

raise;

end;

end;

end;

end;

if DlgImage.ICVideo.DeviceValid then
begin

DlgImage.ICVideo.LiveStart;

end else
begin

cmdVideoSourceSetup.Execute;

end;


There is ICError_INCOMPLETE exception error ignoring. ShowDeviceProperties dialog shows Brightness range from -4625 to 4580, setting any value in this range working good and online. Maybe ICError_INCOMPLETE is raised by another parameter.

I have the problem with ICError_INCOMPLETE only with AverMedia EZ Capture card with nonoriginal drivers, BT878 chip. When I connect DFK21F04 all working good without any exceptions.