mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 17:19:19 +02:00
parent
89b471a8d6
commit
ab566789a8
@ -15,6 +15,8 @@ begin
|
|||||||
// This is needed, or loading the VLC libraries will fail with a SIGFPE
|
// This is needed, or loading the VLC libraries will fail with a SIGFPE
|
||||||
setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
|
setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
|
||||||
exOverflow, exUnderflow, exPrecision]);
|
exOverflow, exUnderflow, exPrecision]);
|
||||||
|
With TVLCLibrary.Create(Nil) do
|
||||||
|
Initialize;
|
||||||
P:=TVLCMediaPlayer.Create(Nil);
|
P:=TVLCMediaPlayer.Create(Nil);
|
||||||
if ParamCount=1 then
|
if ParamCount=1 then
|
||||||
With P do
|
With P do
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
|
{$IFDEF UNIX}
|
||||||
{$linklib pthread}
|
{$linklib pthread}
|
||||||
|
{$ENDIF}
|
||||||
|
{$mode objfpc}
|
||||||
|
{$H+}
|
||||||
|
|
||||||
program tvlc;
|
program tvlc;
|
||||||
|
|
||||||
uses cthreads, libvlc, math;
|
uses {$ifdef unix}cthreads,{$endif}libvlc, math;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
Args: Array[0..3] of pchar;
|
Args: Array[0..3] of pchar;
|
||||||
@ -11,8 +16,9 @@ begin
|
|||||||
// This is needed, or loading the VLC libraries will fail with a SIGFPE
|
// This is needed, or loading the VLC libraries will fail with a SIGFPE
|
||||||
setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
|
setexceptionmask([exInvalidOp, exDenormalized, exZeroDivide,
|
||||||
exOverflow, exUnderflow, exPrecision]);
|
exOverflow, exUnderflow, exPrecision]);
|
||||||
LoadLibVLC('libvlc.so.5',False);
|
LoadLibVLC(libname,False);
|
||||||
args[0] := PAnsiChar('libvlc.so.5');
|
args[0] := PAnsiChar('libvlc.so.5');
|
||||||
|
Args[1] := PansiChar(ParamStr(1));
|
||||||
args[2] := NIL;
|
args[2] := NIL;
|
||||||
FHandle := libvlc_new(1, @args);
|
FHandle := libvlc_new(1, @args);
|
||||||
end.
|
end.
|
||||||
|
@ -633,6 +633,9 @@ uses
|
|||||||
|
|
||||||
var
|
var
|
||||||
hlib : tlibhandle;
|
hlib : tlibhandle;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
hclib : tlibhandle;
|
||||||
|
{$ENDIF}
|
||||||
LibRefCount : Integer;
|
LibRefCount : Integer;
|
||||||
|
|
||||||
procedure Freelibvlc;
|
procedure Freelibvlc;
|
||||||
@ -643,6 +646,11 @@ begin
|
|||||||
if LibRefCount>0 then
|
if LibRefCount>0 then
|
||||||
exit;
|
exit;
|
||||||
FreeLibrary(hlib);
|
FreeLibrary(hlib);
|
||||||
|
hlib:=NilHandle;
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
FreeLibrary(hclib);
|
||||||
|
hclib:=NilHandle;
|
||||||
|
{$ENDIF}
|
||||||
libvlc_errmsg:=nil;
|
libvlc_errmsg:=nil;
|
||||||
libvlc_clearerr:=nil;
|
libvlc_clearerr:=nil;
|
||||||
libvlc_printerr:=nil;
|
libvlc_printerr:=nil;
|
||||||
@ -932,7 +940,28 @@ Procedure Loadlibvlc(lib : AnsiString; CheckProcNames : Boolean = False);
|
|||||||
raise Exception.CreateFmt('Could not load library "%s"',[FN]);
|
raise Exception.CreateFmt('Could not load library "%s"',[FN]);
|
||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Function TryLoadLib(ALib : String) : TLibHandle;
|
||||||
|
// On Windows, the vlccore lib must be loaded first.
|
||||||
|
// If it is not in the PATH then this will fail when specifying an arbitrary path.
|
||||||
|
// So we load it explicitly from the same directory first
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
Var
|
||||||
|
ADir : String;
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
begin
|
||||||
|
{$IFDEF WINDOWS}
|
||||||
|
Result:=NilHandle;
|
||||||
|
ADir:=ExtractFilePath(ALib);
|
||||||
|
if ADir<>'' then
|
||||||
|
ADir:=IncludeTrailingPathDelimiter(ADir);
|
||||||
|
hclib:=LoadLibrary(ADir+corelibname);
|
||||||
|
if (HCLib<>Nilhandle) then
|
||||||
|
{$ENDIF}
|
||||||
|
Result:=LoadLibrary(ALib);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
Var
|
Var
|
||||||
@ -945,21 +974,21 @@ begin
|
|||||||
Inc(LibRefCount);
|
Inc(LibRefCount);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
hlib:=LoadLibrary(lib);
|
hlib:=TryLoadLib(lib);
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
// MVC: This automatism is highly questionable; The end user should in fact determine the library.
|
// MVC: This automatism is highly questionable; The end user should in fact determine the library.
|
||||||
if (hlib=NilHandle) then
|
if (hlib=NilHandle) then
|
||||||
begin
|
begin
|
||||||
D:=ExtractFilePath(lib);
|
D:=ExtractFilePath(lib);
|
||||||
// Try default name in same directiory.
|
// Try default name in same directiory.
|
||||||
hlib:=LoadLibrary(d+corelibname);
|
hlib:=TryLoadLib(d+libname);
|
||||||
if (hLib=NilHandle) and (d='') then
|
if (hLib=NilHandle) and (d='') then
|
||||||
begin
|
begin
|
||||||
// No directory specified, try default name in installation directory.
|
// No directory specified, try default name in installation directory.
|
||||||
if (DefaultlibPath='') then
|
if (DefaultlibPath='') then
|
||||||
DefaultLibPath:=GetVLCLibPath;
|
DefaultLibPath:=GetVLCLibPath;
|
||||||
if (DefaultLibPath<>'') then
|
if (DefaultLibPath<>'') then
|
||||||
hLib:=LoadLibrary(IncludeTrailingPathDelimiter(DefaultlibPath)+corelibname);
|
hLib:=TryLoadLib(IncludeTrailingPathDelimiter(DefaultlibPath)+libname);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
Loading…
Reference in New Issue
Block a user