SoundStream.OnGetData(...) is already called from another thread and the return result is put into a buffer (actually a triple buffer). All you should be doing is generating/loading your samples from within that function. Don't try to do it in the main thread and synchronize it yourself. Not to mention that since the OnGetData(...) function is called from another thread your code isn't thread safe.