Expose more MiniAudio-Functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1554
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Expose more MiniAudio-Functions

Post by User_Russian »

It is possible that in this code the structures from C to PB are incorrectly translated.
Test code.

Code: Select all

XIncludeFile "miniaudio.pbi"
EnableExplicit

Procedure GetDevList(List Dev.s())
  Protected Res = #False, context.ma_context
  
  If ma_context_init(#Null, 0, #Null, @context) = #MA_SUCCESS
    
  EndIf
  
  ProcedureReturn Res
EndProcedure

Define NewList Dev.s()

GetDevList(Dev())

ForEach Dev()
  Debug Dev()
Next
The application crashes.
When I checked ma_context structure size in Visual Studio I found out that in x86 the size is 386 bytes, and in x64 the size is 720 bytes. But in PB the size is different. in x86 the size is 136 bytes, and in x64 the size is 232 bytes.
I haven't checked the size of the other structures, but it might also be incorrect.
Or maybe the miniaudio version is different and this code is for an older version where the structures were smaller.
User avatar
idle
Always Here
Always Here
Posts: 5921
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Expose more MiniAudio-Functions

Post by idle »

I didn't look at x86, the partial port was just for exploring a solution and it's problematic as miniaudio returns structures but I found that I could include it with inline c using my compiler tool which Fred is now implementing as headersection.
If you wait for PB 6.30 b2 you should then be able to use miniaudio with inline c but it's still not so straight forward as it will require you to have a gcc tool chain installed for the c type resolutions and they may also conflict with PB c types though there may be a way to suppress those issues using pragmas..
User avatar
kenmo
Addict
Addict
Posts: 2047
Joined: Tue Dec 23, 2003 3:54 am

Re: Expose more MiniAudio-Functions

Post by kenmo »

Piero wrote: Tue Sep 09, 2025 6:22 am I hope SDL2 works better :? (seems very good for some HID stuff)
SDL2 and SDL3 (new this year) both work great in PureBasic! It's specifically the GUID struct functions I was having trouble with.

@idle Thanks for the starting point! I haven't installed the beta yet.

That's all, I won't hijack this MiniAudio discussion :)
Post Reply