Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-06

Allegro.pas version 4.2.2 released

8 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Guillermo Martínez Jiménez

A new version of Allegro.pas was released yesterday. Allegro.pas is a wrapper to allow Pascal compilers (such as Free Pascal) to use the Allegro library in games or multimedia programs.

This version introduces new functions that allows to create, write and read files using the LZSS compression algorithm.

Also I've created a public mailing list, but it needs some hours to be active so be patient if you find an error page.

That's all today. Don't forget to download and test it.

http://allegro-pas.sourceforge.net/

EarMaster - Bent Olsen
to Guillermo Martínez Jiménez

Hi all,

I've been playing with audio unit framework on Mac OSX 10.4, and trying to make a sample from Xcode (PlayAudioFileLite) running on Lazarus 0.9.25/rev 15279 with FPC 2.2.0.

I'm nearly done, and I'm only getting an error -50 (error in user parameter list) on the last API call from the callback process.

I don't have the sufficient experience with C/C++ vs. Pascal calling conventions, but I've been lucky with other API calls, except for the last one. I'm hoping one of you can help translate this call, which btw the way works fine in Xcode - the sample is playing an audio file.

The API call is in the AudioFile.h:

Extern OSStatus
AudioFileReadPackets ( AudioFileID inAudioFile, Boolean inUseCache,
UInt32 *outNumBytes,
AudioStreamPacketDescription
*outPacketDescriptions,
SInt64 inStartingPacket,
UInt32 *ioNumPacket,
void *outBuffer)
AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;

I've translated this to:

function AudioFileReadPacket(inAudioFile: AudioFileID;
                             inUseCache: Boolean;
                             var outNumBytes: UInt32;
                             var outPacketDescriptions:
AudioStreamPacketDescription; //also tried Pointer
                             inStartingPacket: SInt64;
                             var ioNumPacket: UInt32;
                             var outBuffer: Pointer): OSStatus; external
name '_AudioFileReadPackets'; mwpascal;

I've tried to change the types of parameters in various combination, but yet it didn't give me a clue on which of the parameters is in a wrong type.

I'm sorry if this off topic, but I'll be happy if one of you can tell me what I'm translating wrong.

Best regards,
Normann

Vincent Snijders
to EarMaster - Bent Olsen
EarMaster - Bent Olsen wrote 24 lines
Extern OSStatus AudioFileReadPackets ( AudioFileID inAudioFile, Boolean inUseCache, UInt32 *outNumBytes, AudioStreamPacketDescription *outPacketDescriptions, SInt64 inStartingPacket, UInt32 *ioNumPacket, void *outBuffer) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER; I've translated this to: function AudioFileReadPacket(inAudioFile: AudioFileID; inUseCache: Boolean; var outNumBytes: UInt32; var outPacketDescriptions: AudioStreamPacketDescription; //also tried Pointer inStartingPacket: SInt64; var ioNumPacket: UInt32; var outBuffer: Pointer): OSStatus; external name '_AudioFileReadPackets'; mwpascal;
I think it should be (no var for the pointer):
function AudioFileReadPacket(inAudioFile: AudioFileID;
                              inUseCache: Boolean;
                              var outNumBytes: UInt32;
                              var outPacketDescriptions:
AudioStreamPacketDescription; //also tried Pointer
                              inStartingPacket: SInt64;
                              var ioNumPacket: UInt32;
                              outBuffer: Pointer): OSStatus; external
name '_AudioFileReadPackets'; mwpascal;

Vincent

Marco van de Voort
to Vincent Snijders

In our previous episode, Vincent Snijders said:

I think it should be (no var for the pointer):

... and if ObjC's concept of a boolean is the same as FPC's. Maybe longbool ?

EarMaster - Bent Olsen
to Vincent Snijders: I think it should be (no var for the pointer): function AudioFileReadPacket(inAudioFile:…
Show quoted text 8 lines
-----Original Message----- From: [mailto:fpc-pascal- On Behalf Of Vincent Snijders Sent: 29. august 2008 12:27 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Mac OSX API call I think it should be (no var for the pointer):

I tried, and same result.

Could a Mac OSX API call return -50 even though the types are correct, but the contents of them are not what it expected?

I would assume -50 is only after a check for types in the parameter list, and check is done before even calling the API.

Thanks,
Normann

Show quoted text 11 lines
function AudioFileReadPacket(inAudioFile: AudioFileID; inUseCache: Boolean; var outNumBytes: UInt32; var outPacketDescriptions: AudioStreamPacketDescription; //also tried Pointer inStartingPacket: SInt64; var ioNumPacket: UInt32; outBuffer: Pointer): OSStatus; external name '_AudioFileReadPackets'; mwpascal; Vincent
EarMaster - Bent Olsen
to Marco van de Voort: In our previous episode, Vincent Snijders said: ... and if ObjC's concept of a boolean is…
Show quoted text 14 lines
-----Original Message----- From: [mailto:fpc-pascal- On Behalf Of Marco van de Voort Sent: 29. august 2008 12:39 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Mac OSX API call In our previous episode, Vincent Snijders said: > > I think it should be (no var for the pointer): ... and if ObjC's concept of a boolean is the same as FPC's. Maybe longbool ?

I did thought the boolean type could have a different size, and I did make a sizeof in Xcode and in FPC, and the both returned a size of 1. This don't mean, there's an alignment issue?

Thanks,
Normann

Jonas Maebe
to EarMaster - Bent Olsen: I tried, and same result. Could a Mac OSX API call return -50 even though the types are…
EarMaster - Bent Olsen wrote 17 lines
> From: [mailto:fpc-pascal- > On Behalf Of Vincent Snijders > Sent: 29. august 2008 12:27 > To: FPC-Pascal users discussions > Subject: Re: [fpc-pascal] Mac OSX API call > > I think it should be (no var for the pointer): I tried, and same result. Could a Mac OSX API call return -50 even though the types are correct, but the contents of them are not what it expected? I would assume -50 is only after a check for types in the parameter list, and check is done before even calling the API.

External functions have no idea what the declaration of the function in your source code is. A couple of the parameters your are passing (inAudioFile a outPacketDescriptions) however are pointers to opaque structures, and the called function is probably performing some sanity checks on those structures to ensure that they are valid.

Jonas

Jonas Maebe
to Jonas Maebe
Jonas Maebe wrote 26 lines
On 29 Aug 2008, at 11:58, EarMaster - Bent Olsen wrote: >> From: [mailto:fpc-pascal- >> On Behalf Of Vincent Snijders >> Sent: 29. august 2008 12:27 >> To: FPC-Pascal users discussions >> Subject: Re: [fpc-pascal] Mac OSX API call >> >> I think it should be (no var for the pointer): > > I tried, and same result. > > Could a Mac OSX API call return -50 even though the types are > correct, but > the contents of them are not what it expected? > > I would assume -50 is only after a check for types in the parameter > list, > and check is done before even calling the API. External functions have no idea what the declaration of the function in your source code is. A couple of the parameters your are passing (inAudioFile a outPacketDescriptions) however are pointers to opaque structures, and the called function is probably performing some sanity checks on those structures to ensure that they are valid.

Or alternatively, one of the other parameters could be invalid as well (either on their own or in combination with the other parame