SunVox for ZGE

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Sat Apr 10, 2021 9:42 am

Did you try setting "CallingConvention" property of the ZExternalLibrary component to "cdecl"?

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Sat Apr 10, 2021 10:06 am

The result is the same with "cdecl" on linux.

By the way, is it better to use "Stdcall" or "Cdecl"? The wikipedia page is a bit obscure for me :oops:

User avatar
Kjell
Posts: 1755
Joined: Sat Feb 23, 2008 11:15 pm

Re: SunVox for ZGE

Post by Kjell » Sat Apr 10, 2021 10:17 am

Hi Ats,
Ats wrote:
Sat Apr 10, 2021 10:06 am
By the way, is it better to use "Stdcall" or "Cdecl"?
They are just different conventions. The biggest difference is that libraries that use STDCALL clean up the memory used to call a function themselves, while CDECL expects the caller to do this instead ( in that case ZGE takes care of this ). The author of a library can just pick which convention they prefer ( most platforms / compilers support both ).

K

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Sat Apr 10, 2021 10:20 am

In addition to what Kjell wrote, "stdcall" is mostly a thing on Windows. "cdecl" is the most common convention on other platforms.

Do the Sunvox calls before "sv_load_from_memory" seem to work?

"sv_init" is supposed to return a value larger than zero if successful so please check for that.

Maybe you can also try calling the Sunvox library from a simple C project just to check that your Sunvox binary is ok.

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Sat Apr 10, 2021 10:44 am

Thanks for the explanations. So setting the CallingConvention automatically could be another use of adding LINUX as a builtin constant.

Anyway, I test using sunvox_lofi.so and it's working. So either my old linux computer is too old, which seems a bit odd, or the sunvox.so library is broken. I'm going to plug another computer to test. There are so much power cables around me right now... :lol:

Here's the linux trace using sunvox_lofi.so :

Code: Select all

Desired audio buffer size: 2048 frames
ALSA: pulse
ALSA HW Default rate: 44100
ALSA HW Rate: 44100 frames
ALSA HW Buffer size: 4096 frames
ALSA HW Period size: 227
ALSA HW Periods: 0
ALSA SW Avail min: 227
ALSA SW Start threshold: 1
ALSA SW Stop threshold: 4096
SOUND: sundog_sound_deinit() begin
SOUND: sundog_sound_deinit() end
Max memory used: 1848214

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Sat Apr 10, 2021 11:57 am

After a bit of work to make my test run on Linux 64, I'm having the same results. So the sunvox.so lib might be broken?

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Sat Apr 10, 2021 1:15 pm

Ats wrote:
Sat Apr 10, 2021 11:57 am
So the sunvox.so lib might be broken?
If this is the officially built sunvox.so file then I would try to check with the sunvox community: https://warmplace.ru/forum/viewforum.php?f=12

Let me know how it goes and if I can help in some other way.

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Sun Apr 11, 2021 5:04 pm

Turns out only some musics are crashing sunvox.so
NightRadio should be on it: https://warmplace.ru/forum/viewtopic.php?f=12&t=5735 :wink:

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Tue Apr 20, 2021 7:59 am

You were right on the other thread, .elf 64 file needs .so 64 library file.
Now it's not crashing, but it's not working either.

Here's the result for the linux x86_64 SunVox test with a music file that was previously working with sunvox.so (not sunvox_lofi.so)

Code: Select all

// launch app + sunvox init 
// I'm oppening slot 0...

Wrong slot number 1891074528! Correct values: 0...15
Wrong slot number 1891074528! Correct values: 0...15
Wrong slot number 1891074528! Correct values: 0...15

// not playing music
// then after closing app

Wrong slot number 1891074480! Correct values: 0...15
Wrong slot number 1891074480! Correct values: 0...15
SOUND: sundog_sound_deinit() begin
SOUND: sundog_sound_deinit() end
Max memory used: 116332
The slot number is random each time.

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Tue Apr 20, 2021 8:40 am

In order to verify, I compiled SDL2 Player_linux.bin on my old i386.
The musics that where previously working with 32bits sunvox_lofi.so aren't working anymore.
Again, no crash, but no music either:

Code: Select all

// open app

Desired audio buffer size: 2048 frames
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM pulse
ALSA ERROR: Can't open audio device pulse: No such file or directory
ALSA: default
ALSA HW Default rate: 44100
ALSA HW Rate: 44100 frames
ALSA HW Buffer size: 3763 frames
ALSA HW Period size: 940
ALSA HW Periods: 0
ALSA SW Avail min: 940
ALSA SW Start threshold: 1
ALSA SW Stop threshold: 3763

// music isn't playing
// then quit app

SOUND: sundog_sound_deinit() begin
SOUND: sundog_sound_deinit() end
Max memory used: 1429381
Edit:
All right, my fault. Too many cables around me to plug and unplug, and the audio cable was on the wrong slot.
It's working perfectly on i386, 32bits linux and sunvox_lofi.so library...

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Tue Apr 20, 2021 8:58 am

Please try this:

Since you can build ZDesigner, try building it in 64-bit mode. Then use it to generate the binary.

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Tue Apr 20, 2021 9:41 am

Interesting test. So I set Delphi Compiler to "Release config - Win 64bit platform" and compiled ZDesigner.exe
Then I compiled the SunVox example to x86_64 linux, then run the elf on my x86_64 linux computer.
I verified that I'm effectively using linux x86_64 sunvos.so too.

The result is the same during initialization:
Wrong slot number 1891074528! Correct values: 0...15

(I'm currently building ZgeBullet.so on the i386 to see how it goes)

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Tue Apr 20, 2021 11:01 am

Ok. Just to be sure, I made an update now that makes ZDesigner output 64-bit compatible output regardless if it is built in 32-bit or 64-bit.

User avatar
VilleK
Site Admin
Posts: 2151
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: SunVox for ZGE

Post by VilleK » Wed Apr 21, 2021 7:20 am

Please try inserting writeln-statements to see that the correct code is executed.

In ZExpressions.pas

line 2309, insert line with "writeln('checking args: ' + argtypes);"

line 2351, change the line with "assert" into "writeln('fail');"

Then build and check if those lines appear in the output.

User avatar
Ats
Posts: 408
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: SunVox for ZGE

Post by Ats » Wed Apr 21, 2021 8:38 am

I like it when I have things to test with my morning coffee :wink:
But the results aren't incredible:

Code: Select all

 ./SunVox_x86_64_debug
checking args: 
fail
checking args: 
fail
checking args: 
fail
checking args: 
fail
checking args: 
fail
Wrong slot number -1803177552! Correct values: 0...15
checking args: 
fail
checking args: 
fail
checking args: 
fail
Wrong slot number -1803177552! Correct values: 0...15
checking args: 
fail
Wrong slot number -1803177552! Correct values: 0...15
checking args: 
fail
Wrong slot number -1803177600! Correct values: 0...15
checking args: 
fail
Wrong slot number -1803177600! Correct values: 0...15
SOUND: sundog_sound_deinit() begin
SOUND: sundog_sound_deinit() end
Max memory used: 116332
(just to be sure, other versions of sunvox.so (ex: 32bits) only displays "./sunvox.so" and exit)

Post Reply