Lazarus
Programming => Operating Systems => Windows => Topic started by: SirLucifer on January 28, 2010, 03:51:08 pm
-
This is the second SIGxxx exception I've come across, and I really don't like these *NIX messages.
What does this mean? That a signal is ill, or what? Of course it is... I'm on Windows, we don't have signals...
Well... Enough comedy.
Honestly, what does it mean?
Some code:
uses
DShow { and a bunch of other stuff }
Procedure TAnalyzer.Check(Result: HResult);
begin
If Failed(Result) Then
Raise Exception.Create(SysErrorMessage(Result));
end;
Function TAnalyzer.AnalyzeDirectX: Boolean;
Var Err : HResult;
Filename : WideString;
GraphBuilder : IGraphBuilder;
MediaControl : IMediaControl;
MediaEvent : IMediaEvent;
begin
Check(CoCreateInstance(CLSID_FilterGraph, Nil, CLSCTX_INPROC, IID_IGraphBuilder, GraphBuilder));
Try
Check(GraphBuilder.QueryInterface(IID_IMediaControl, MediaControl));
Check(GraphBuilder.QueryInterface(IID_IMediaEvent, MediaEvent));
Filename := UTF8ToSys(Files[FileIndex]);
Check(GraphBuilder.RenderFile(PWideChar(Filename), Nil)); // <--- Exception here!
Finally
MediaEvent := Nil;
MediaControl := Nil;
GraphBuilder := Nil;
End;
end;
Regards all!
-
Honestly, what does it mean?
http://en.wikipedia.org/wiki/SIGILL
-
Thanks theo!
It seems I'm calling an illegal function, but how is that really possible when the first two functioncalls of that interface is ok and successful?
-
I have no idea what you're doing.
From googling I've found this.
http://www.c-plusplus.de/forum/viewtopic-var-t-is-254847.html
Maybe you're missing somthing?
Anyway, this is also problematic:
Filename := UTF8ToSys(Files[FileIndex]);
I do not think it is the reason for the errror, but you should use
UTF8Decode instead of UTF8ToSys which returns an AnsiString.
-
I have no idea what you're doing.
What I'm trying to do, is parse a video using DirectShow.
Following the example at http://msdn.microsoft.com/en-us/library/dd389098%28VS.85%29.aspx (http://msdn.microsoft.com/en-us/library/dd389098%28VS.85%29.aspx) I can't really see what I'm missing.
What's missing in my original post, though, is the call to CoInitialize, which occurs right before the call to TAnalyzer.AnalyzeDirectX.
Anyone got a suggestion?
-
I have no idea what you're doing.
What I'm trying to do, is parse a video using DirectShow.
Following the example at http://msdn.microsoft.com/en-us/library/dd389098%28VS.85%29.aspx (http://msdn.microsoft.com/en-us/library/dd389098%28VS.85%29.aspx) I can't really see what I'm missing.
What's missing in my original post, though, is the call to CoInitialize, which occurs right before the call to TAnalyzer.AnalyzeDirectX.
Anyone got a suggestion?
I don't know if it is the problem, but try to add
filename:=filename+' ';
AFTER the
Check(GraphBuilder.RenderFile(PWideChar(Filename), Nil)); // <--- Exception here!
line.
-
Thanks for the replies.
marcov,
I don't know if it is the problem, but try to add
filename:=filename+' ';
AFTER the
Check(GraphBuilder.RenderFile(PWideChar(Filename), Nil)); // <--- Exception here!
line.
This makes no sense at all, since the exception would occur before the modification to 'filename'.
Anyway, I found the cause and it's quite sillly, actually.
I assumed the GraphBuilder.QueryInterface calls were successful, since they didn't return an error, but it seems the CoCreateInstance call returns a nil object and thereby rendering GraphBuilder totally invalid.
My conclution is that COM is too unreliable to use in Free Pascal, so I will be returning to Delphi ASAP.
Thanks again all!
-
This makes no sense at all, since the exception would occur before the modification to 'filename'.
The unneeded modification might make sure that the filename string is kept alive till after the call.
Anyway, I found the cause and it's quite sillly, actually.
I assumed the GraphBuilder.QueryInterface calls were successful, since they didn't return an error, but it seems the CoCreateInstance call returns a nil object and thereby rendering GraphBuilder totally invalid.
My conclution is that COM is too unreliable to use in Free Pascal, so I will be returning to Delphi ASAP.
Thanks again all!
For COM support it is advised to work with at least 2.5.1. In fall several things were fixed and expanded which are not in 2.4.0
-
This makes no sense at all, since the exception would occur before the modification to 'filename'.
The unneeded modification might make sure that the filename string is kept alive till after the call.
String variables are always live. Problems with reference counts related to typecasting an ansistring to pchar or a widestring to pwidechar only occur in case this is done to temporary expressions (such as the value returned by a function). In such case, you have to assign the function result first to a variable/field, and then typecast said variable/field.
Adding an empty string to another string will not do anything under any circumstances (it won't even make the string unique in case it is reference counted).
-
The unneeded modification might make sure that the filename string is kept alive till after the call.
Since the Filename local variable is only used in this case, for loading, it's essentially useless after the call, so if there was a referencecount issue, I would have used UniqueString or equivalent.
Trying 2.5.1 or whatever is the latest at this time.