Discussion:
using TVLCPlugin (ActiveX) causes the .exe to hang
(too old to reply)
JL
2007-12-17 18:58:55 UTC
Permalink
Hi,

On a general level, what reasons could cause that using an ActiveX in
application, the application refuses to close (have to kill it with
process explorer. The app hangs so bad, it even stops WinXP from
shutting down)?

I've recently played with an ActiveX (an ActiveX implementing the VLC
Player). I believe that the code below is quite OK, but anyway running
the app completely freezes the application - after it has done all that
it was supposed to do. I've debugged to code, and everything is executed
right until the last line of code. But then the thing freezes.

Could this be so simple, that the ActiveX code it self simply has a bug?
Or do you see something wrong below?

Jyri

-------------------------------------------

procedure TForm1.FormCreate(Sender: TObject);

var Voption : array of String;
var myVLC : TVLCPlugin;
var inputfile,outputfile:string;
begin

inputfile := Paramstr(1);
outputfile := 'D:\\stream.ts';

// Create the plugin -> done run-time
myVLC:= TVLCPlugin.Create(self);
myVLC.Parent := Self;

SetLength(Voption,2);
Voption[0] := ':dshow-adev=""none"":dshow-size=""""';
Voption[1] :=
':sout=#transcode{vcodec=mp2v,vb=1024,scale=1,acodec=mp2a,ab=192,channels=2}:duplicate{dst=std{access=file,mux=ts,dst=[TARGET]}}';
Voption[1]:= StringReplace(Voption[1],'[TARGET]',outputfile,[]);


myVLC.addTarget(inputfile, Voption, VLCPlayListReplaceAndGo, -1);


{ We are converting an input file (mpeg, avi, etc. to a .TS-file)
depending on how long movie you're converting, this might exit in a
second or after 15 minutes.}

While Integer(myVLC.Playing)<>0 do
begin
sleep(1000);
if Integer(myVLC.Playing)=0 then begin // converting OK and ready
myVLC.stop;
myVLC.playlistClear;
Break;
end;
end;

// Free the VLC - plugin.
FreeAndNil(myVLC);

ShowMessage('Done'); // I can see the message

Application.Terminate;
end;
Remy Lebeau (TeamB)
2007-12-17 20:45:03 UTC
Permalink
var Voption : array of String;
Dynamic arrays and Delphi Strings are not compatible with ActiveX. For
strings, you must use BSTR (either directly or via Delphi's WideString
type), and the only safe type of array is ActiveX's own SAFEARRAY type (look
at the SafeArray...() API functions).
outputfile := 'D:\\stream.ts';
Don't double up your slashes in Delphi. That is only required in C/C++.
Voption[0] := ':dshow-adev=""none"":dshow-size=""""';
You don't need to double up on double quotations in Delphi, either.
myVLC.addTarget(inputfile, Voption, VLCPlayListReplaceAndGo, -1);
What is the exact signature of addTarget()?
While Integer(myVLC.Playing)<>0 do
begin
sleep(1000);
Depending on the threading model of the ActiveX object, you will likely need
to process pending window messages instead of just blinding sleeping.


Gambit
harrie
2007-12-18 03:22:45 UTC
Permalink
Post by JL
Hi,
On a general level, what reasons could cause that using an ActiveX in
application, the application refuses to close (have to kill it with
process explorer. The app hangs so bad, it even stops WinXP from
shutting down)?
I've recently played with an ActiveX (an ActiveX implementing the VLC
Player). I believe that the code below is quite OK, but anyway running
the app completely freezes the application - after it has done all that
it was supposed to do. I've debugged to code, and everything is executed
right until the last line of code. But then the thing freezes.
Could this be so simple, that the ActiveX code it self simply has a bug?
Or do you see something wrong below?
Video transcoding is fraught with danger at the best of times so there
are any number of things that can go wrong with this. Plus the ActiveX
component is less stable than the VLC application itself which only
compounds matters.

Remy's pointed out potential problems with the Options var, and I'd say
that any errors with this when transcoding is pretty fatal.

I would test the Options string in the VLC application first and when
you have this working try it with the ActiveX component.

Also the TVLCPlugin uses the old interface so you could try using
TVLCPlugin2 instead. Alternatively you link directly to the libvlc but
then that would require you to meet the GNU General Public License.
Loading...