25 May '13 - 11:25 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Multithreaded usage with BASS Audio and MIDI - crashes and questions  (Read 300 times)
justin
Posts: 1


« on: 14 Jan '12 - 20:38 »
Reply with quoteQuote

Hi,

I'm new to BASS, but not new to developing audio software. I've been asked to debug a CocoaTouch app which uses BASS. There's an issue with concurrent execution in the app which exhibits similar to this:

http://www.un4seen.com/forum/?topic=12872.msg89534#msg89534

in that multiple threads deadlock within BASS calls. One of of those threads is the UI thread. This makes the app unusable. MIDI playback also halts. Other threads are still active at this time. There's also a memory smasher, so the debugger goes out the window. I've searched the forum, and have seen that some calls/mutations should not be made from the callbacks. Having worked with audio and complex threading problems before, I'm also wondering how multithreading is *supposed* to be handled with BASS at a fundamental level - what is and what is not threadsafe?

- What constraints I should adhere to in concurrent contexts?
- What constraints I should adhere to while in callbacks?

The app is currently using BASS from multiple threads, and is locking in the callbacks. Are the callbacks being made from the realtime thread?

Perhaps I've missed an introductory article which goes over this. The samples I've seen so far are comparably primitive in these regards - they do a good job demonstrating specific features, but there's really not a nontrivial threading example from what I have seen…

Thanks for your help!
« Last Edit: 14 Jan '12 - 21:47 by justin » Logged
Ian @ un4seen
Administrator
Posts: 15276


« Reply #1 on: 16 Jan '12 - 15:23 »
Reply with quoteQuote

The main thing to avoid in a callback function is anything that will need to wait for another thread, particularly the main/UI thread. The typical cause of a deadlock is when a callback function does something that needs to wait for the main thread (eg. UI update), while at the same time the main thread is making a BASS call that needs to wait for the callback to return. To avoid that problem, you can have the callback function just post a message/event to the main thread, and then do the work (eg. UI update) in the message/event handler. The NETRADIO example in the BASS package does this, as does the SYNTH example in the BASSMIDI package.

If you still have any callback deadlock problems, please describe (with code) what your callback functions are doing.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines