From 5a778181e947cfb883f85d3239f6d1f1714dacc8 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 13 Sep 2007 11:39:57 +0000 Subject: changes to make 3rd party libraries compile / work in lazarus. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@387 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/lib/bass/lazarustest.lpi | 192 ++++++++++++++++++++++++++++++++++ Game/Code/lib/bass/lazarustest.lpr | 51 +++++++++ Game/Code/lib/ffmpeg/avcodec.pas | 6 +- Game/Code/lib/ffmpeg/avformat.pas | 13 ++- Game/Code/lib/ffmpeg/avio.pas | 2 + Game/Code/lib/ffmpeg/lazarustest.lpi | 194 +++++++++++++++++++++++++++++++++++ Game/Code/lib/ffmpeg/lazarustest.lpr | 27 +++++ 7 files changed, 481 insertions(+), 4 deletions(-) create mode 100644 Game/Code/lib/bass/lazarustest.lpi create mode 100644 Game/Code/lib/bass/lazarustest.lpr create mode 100644 Game/Code/lib/ffmpeg/lazarustest.lpi create mode 100644 Game/Code/lib/ffmpeg/lazarustest.lpr (limited to 'Game/Code/lib') diff --git a/Game/Code/lib/bass/lazarustest.lpi b/Game/Code/lib/bass/lazarustest.lpi new file mode 100644 index 00000000..fd0f1c9c --- /dev/null +++ b/Game/Code/lib/bass/lazarustest.lpi @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Game/Code/lib/bass/lazarustest.lpr b/Game/Code/lib/bass/lazarustest.lpr new file mode 100644 index 00000000..6faee86d --- /dev/null +++ b/Game/Code/lib/bass/lazarustest.lpr @@ -0,0 +1,51 @@ +program lazarustest; + +{$mode objfpc}{$H+} + +uses + sysutils, + bass in 'delphi\bass.pas' + { add your units here }; + +var + chan : HSTREAM; + +begin + // check the correct BASS was loaded + if (hi(BASS_GetVersion) <> BASSVERSION) then + begin + writeln('An incorrect version of BASS.DLL was loaded'); + Halt; + end; + + //init BASS + if not BASS_Init(0,44100,0,0,nil) then + writeln('Can''t initialize device'); + + //creating stream + if fileexists( 'music.mp3 ') then + begin + chan := BASS_StreamCreateFile(FALSE,pchar('music.mp3'),0,0,0); + if chan = 0 then + begin + chan := BASS_MusicLoad(False, pchar('music.mp3'), 0, 0, BASS_MUSIC_RAMPS or BASS_MUSIC_POSRESET or BASS_MUSIC_PRESCAN, 0); + if (chan = 0) then + begin + writeln('Can''t play file'); + Exit; + end; + end; + + BASS_ChannelPlay(chan,FALSE); // start playing + end + else + begin + writeln( 'music.mp3 not found.. could not test mp3 playback'); + end; + + BASS_Free(); + writeln( 'Seems BASS is compatible with lazarus :) '); + + +end. + diff --git a/Game/Code/lib/ffmpeg/avcodec.pas b/Game/Code/lib/ffmpeg/avcodec.pas index 978b5fb6..ce08dcc9 100644 --- a/Game/Code/lib/ffmpeg/avcodec.pas +++ b/Game/Code/lib/ffmpeg/avcodec.pas @@ -576,7 +576,7 @@ type of AVIn/OutputFormat *) item_name: function (): pchar; cdecl; option: PAVOption; - end; + end; TAVCodecContext = record {720} (*** Info on struct for av_log @@ -1792,11 +1792,13 @@ procedure av_resample_close (c: PAVResampleContext); got_sub_ptr: pinteger; const buf: pchar; buf_size: integer): integer; cdecl; external av__codec; + + {$IFNDEF FPC} function avcodec_parse_frame (avctx: PAVCodecContext; pdata: PPointer; data_size_ptr: pinteger; buf: pchar; buf_size: integer): integer; cdecl; external av__codec; - + {$ENDIF} function avcodec_encode_audio (avctx: PAVCodecContext; buf: PByte; buf_size: integer; const samples: Pword): integer; cdecl; external av__codec; diff --git a/Game/Code/lib/ffmpeg/avformat.pas b/Game/Code/lib/ffmpeg/avformat.pas index 0aa98905..6d13bcdf 100644 --- a/Game/Code/lib/ffmpeg/avformat.pas +++ b/Game/Code/lib/ffmpeg/avformat.pas @@ -19,6 +19,10 @@ unit avformat; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + uses windows, avcodec, avio, rational, avutil; @@ -554,6 +558,7 @@ const const FFM_PACKET_SIZE = 4096; + {$IFNDEF FPC} function ffm_read_write_index (fd: integer): int64; cdecl; external av__format; @@ -562,20 +567,23 @@ const procedure ffm_set_write_index (s: PAVFormatContext; pos: int64; file_size: int64); cdecl; external av__format; - + {$ENDIF} + function find_info_tag (arg: pchar; arg_size: integer; tag1: pchar; info: pchar): integer; cdecl; external av__format; + {$IFNDEF FPC} function get_frame_filename(buf: pchar; buf_size: integer; path: pchar; number: integer): integer; cdecl; external av__format; + function filename_number_test (filename: pchar): integer; cdecl; external av__format; - (* grab specific *) function video_grab_init (): integer; cdecl; external av__format; + function audio_init (): integer; cdecl; external av__format; @@ -584,6 +592,7 @@ const cdecl; external av__format; function dc1394_init (): integer; cdecl; external av__format; + {$ENDIF} function strstart(str: pchar; val: pchar; ptr: PPointer): integer; cdecl; external av__format; diff --git a/Game/Code/lib/ffmpeg/avio.pas b/Game/Code/lib/ffmpeg/avio.pas index 20275ab7..7d0e8c04 100644 --- a/Game/Code/lib/ffmpeg/avio.pas +++ b/Game/Code/lib/ffmpeg/avio.pas @@ -224,12 +224,14 @@ type procedure init_checksum (s: PByteIOContext; update_checksum: pointer; checksum: cardinal); cdecl; external av__format; + {$IFNDEF FPC} function udp_set_remote_url(h: PURLContext; const uri: pchar): integer; cdecl; external av__format; function udp_get_local_port(h: PURLContext): integer; cdecl; external av__format; function udp_get_file_handle(h: PURLContext): integer; cdecl; external av__format; + {$ENDIF} implementation diff --git a/Game/Code/lib/ffmpeg/lazarustest.lpi b/Game/Code/lib/ffmpeg/lazarustest.lpi new file mode 100644 index 00000000..3cd1c3de --- /dev/null +++ b/Game/Code/lib/ffmpeg/lazarustest.lpi @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Game/Code/lib/ffmpeg/lazarustest.lpr b/Game/Code/lib/ffmpeg/lazarustest.lpr new file mode 100644 index 00000000..56efac75 --- /dev/null +++ b/Game/Code/lib/ffmpeg/lazarustest.lpr @@ -0,0 +1,27 @@ +program lazarustest; + +{$MODE Delphi} + +uses + + avcodec in 'avcodec.pas', + avformat in 'avformat.pas', + avutil in 'avutil.pas', + rational in 'rational.pas', + opt in 'opt.pas', + avio in 'avio.pas', + sysutils; + +begin + // This compiles with all units in.. + // but I cant run it, if its compiled with lazarus or delphi + // I get errors about not finding functions in dll's + + try +// av_register_all(); + writeln( 'If you see this then ffmpeg is probably lazarus compatible' ); + except + writeln( 'ffmpeg is NOT lazarus compatible' ); + end; +end. + -- cgit v1.2.3