Converting to Delphi, need some help

169 views
Skip to first unread message

be...@broadcastpartners.nl

unread,
Jul 25, 2016, 7:41:40 AM7/25/16
to ember-plus-development
Several years ago I succesfully converted the Ember C++ code to Delphi to work with Studer mixing consoles.
Now I have to focus on interfacing with Lawo mixing consoles, so I started with Ember+ 1.7.0.
I managed to compile a libember_slim.dll and converted the C++ header files to Delphi.
The first project is part of the __sample_consumer.c example program, specifically the GetDirectory command.

The program I have is very simple, but it crashes in various ways.It either allocates 1304 bytes of memory, releases the memory and calls EmberThrowError with "buffer overrun", or it crashes on glowReader_init with a similar 1304 value.
The differences between the crashes are related to declaring functions as stdcall or cdecl.

It is obvious that I must have made a mistake in converting the code from C++ to Delphi but with 5.000 lines of code it is hard to find a starting point.

Is someone able to give me some hints? Do I have to declare the functions as stdcall (which is what I would assume), have the structs to be declared as 'packed record'?

be...@broadcastpartners.nl

unread,
Jul 27, 2016, 10:06:26 AM7/27/16
to ember-plus-development
I have figured out that the functions have to be declared as cdecl which is not the default for Windows.
Structs must not be declared as packed record, just record.

be...@broadcastpartners.nl

unread,
Jul 27, 2016, 10:36:10 AM7/27/16
to ember-plus-development
The following code sends a GetDirectory command to the provider:

  ZeroMemory(@MyGlowCommand, SizeOf(GlowCommand));
 
MyGlowCommand.number := Integer(GlowCommandType_GetDirectory);
  glowOutput_init
(@MyGlowOutput, @Buffer, BufferSize, 0);
  glowOutput_beginPackage
(@MyGlowOutput, true);
  glow_writeQualifiedCommand
(
   
@MyGlowOutput,
   
@MyGlowCommand,
   
FSession.pCursorPath,
   
FSession.cursorPathLength,
   
FSession.pCursor.type_);
 
Size := glowOutput_finishPackage(@MyGlowOutput);

As a result I get 53 bytes and after decoding it says 'Crystal' which is the name of the mixing console.

How do I get the children of this node?

How do I subscribe/unsubscribe to: Sources --> Fader --> Motor dB Value, or:Sources --> States --> PFL1 active?

Reply all
Reply to author
Forward
0 new messages