Lib->Multithreaded

Multi-platform modular music creation studio
Post Reply
RaXnTraX
Posts: 7
Joined: Tue Feb 22, 2022 2:10 pm

Lib->Multithreaded

Post by RaXnTraX »

Just FYI :

I am using sv_audio_callback() in another thread than sv_remove_module()/sv_disconnect_module().
Although I am using sv_lock()/sv_unlock() I "sometimes" get an IMA on sv_audio_callback().
The solution is to use my own Mutex.
Perhaps something to look into?
Ol sen
Posts: 20
Joined: Sat Feb 12, 2022 6:26 am

Re: Lib->Multithreaded

Post by Ol sen »

nm -gU sunvox.dylib > extract.h
where..
T = text section symbol,
S = otherwise places symbol.

Code: Select all

S _g_sundog_sound_cnt
S _g_sundog_sound_mutex
T __Z17sundog_sound_lockP12sundog_sound // sundog_sound_lock(sundog_sound*)
T __Z19sundog_sound_unlockP12sundog_sound // sundog_sound_unlock(sundog_sound*)
T __Z11smutex_initP6smutexj
T __Z11smutex_lockP6smutex
T __Z13smutex_unlockP6smutex
T __Z14smutex_destroyP6smutex
T __Z14smutex_trylockP6smutex
To be precise, there are even deep vulnerabilities that can easily be exploited for other things than noise making.
Always check first what really is inside a lib before using it. Telling this no to make anyone afraid.
Its general good advice to look inside pre-compiled stuff. It even helps understanding whats going on.

But.. i do the same, have no drop outs. Guessing my threads do no block each other.
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Lib->Multithreaded

Post by NightRadio »

What SV_INIT_FLAG_* flags do you use in sv_init()?
RaXnTraX
Posts: 7
Joined: Tue Feb 22, 2022 2:10 pm

Re: Lib->Multithreaded

Post by RaXnTraX »

Oops, my fault!
RaXnTraX
Posts: 7
Joined: Tue Feb 22, 2022 2:10 pm

Re: Lib->Multithreaded

Post by RaXnTraX »

Although the SV_INIT_FLAG_ONE_THREAD flag is not set in sv_init(), I still get (very rarely (1 out of 100 times more or less)) a crash on sv_audio_callback() when switching between instruments.

By switching instruments I mean
//remove previous
sv_lock_slot(0)
sv_disconnect_module(0,...)
sv_remove_module(0,...)
sv_unlock_slot(0)
...
//load new
sv_lock_slot(0)
sv_load_module(0,...)
sv_unlock_slot(0)
I am not sure whether it is on disconnect, remove or load.
Surely I could move the switching to the "sv_audio_callback() thread", but stll, something must be wrong somewhere...(?)
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Lib->Multithreaded

Post by NightRadio »

So what SV_INIT_FLAG_* flags do you use? :)
And what is your system?
RaXnTraX
Posts: 7
Joined: Tue Feb 22, 2022 2:10 pm

Re: Lib->Multithreaded

Post by RaXnTraX »

-Flags -> SV_INIT_FLAG_USER_AUDIO_CALLBACK | SV_INIT_FLAG_AUDIO_FLOAT32
-Win10/64bit
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: Lib->Multithreaded

Post by NightRadio »

Thanks!
Unfortunately there is too little information to say something about your case, sorry.
In Linux i can use Valgrind to get all hidden memory problems of the app. In Windows i don't know... maybe Deleaker or something similar.
At least the debugger report can clarify something.
Or the stripped down version of source code, maybe...
Post Reply