X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Flib%2Fvorbis%2Fvorbis.pas;h=87833bd69edbc81911bd7d4dbae16ca81022252e;hb=fa24d1d2238f0f9d9eb9b10c8701e28eb529a8d6;hp=8962f5046fe7efcbbd17aaefaad982917c0e56f9;hpb=9bc2f6da5fde4dfddbfa66c8bcb984fbadfe1c9f;p=d2df-sdl.git diff --git a/src/lib/vorbis/vorbis.pas b/src/lib/vorbis/vorbis.pas index 8962f50..87833bd 100644 --- a/src/lib/vorbis/vorbis.pas +++ b/src/lib/vorbis/vorbis.pas @@ -28,8 +28,8 @@ uses {$IF DEFINED(WINDOWS)} {$IFDEF VORBIS_WINDOZE_STATIC} - {$LINKLIB libvorbis.a} {$LINKLIB libvorbisfile.a} + {$LINKLIB libvorbis.a} {$ELSE} {$DEFINE OGG_DYNAMIC} const vorbislib = 'libvorbis-0.dll'; @@ -37,8 +37,10 @@ uses {$ENDIF} {$ELSEIF DEFINED(UNIX)} {$DEFINE OGG_DYNAMIC} - const vorbislib = 'libvorbis.so'; - const vorbisfilelib = 'libvorbisfile.so'; + {$LINKLIB libvorbis} + {$LINKLIB libvorbisfile} + const vorbislib = 'libvorbis'; + const vorbisfilelib = 'libvorbisfile'; {$ELSE} {$ERROR libvorbis not supported on this platform. Fix it!} {$ENDIF} @@ -416,11 +418,20 @@ type implementation +//k8: sighs. you HAVE to have a 16-byte aligned buffer, otherwise +// 32-bit SSE2-enabled builds *WILL* fail. +// it means that you *CANNOT* simply use a passed pointer. +// therefore this fuckery with internal buffer (because +// i am not sure that FPC will align stack variables +// correctly). function ov_read_ext(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool): clong; var ofs: cint; Num: cint; Res: cint; + buf: array[0..3000] of Byte; + rd: cint; + bptr: ^Byte; begin // check blocksize here! {if length mod 4 <> 0 then @@ -429,17 +440,27 @@ begin ofs := 0; num := length; + bptr := @buf; + while ((PtrUInt(bptr) and $0f) <> 0) do Inc(bptr); + while num > 0 do begin - res := ov_read(vf, buffer + ofs, num, bigendianp, word, sgned, nil); + rd := num; + if (rd > 2048) then rd := 2048; + res := ov_read(vf, bptr, rd, bigendianp, word, sgned, nil); + //res := ov_read(vf, buffer + ofs, num, bigendianp, word, sgned, nil); if res < 0 then Exit(res); if res = 0 then Break; - ofs := ofs + res; - num := num - res; + //ofs := ofs + res; + //num := num - res; + Move(bptr^, buffer^, res); + buffer := buffer+res; + ofs := ofs+res; + num := num-res; end; Result := ofs;