<span style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px;background-color:rgb(255,255,255)">I&#39;m writing a game and using RTAudio for processing. Before I enter the main loop, I call startStream. However, while the physics and graphics stuff runs in the main loop (on the same thread that I made the call to startStream in), my callback for processing the stream never gets called. I&#39;ve discovered, though, if I just call startStream then wait for user input (like in the duplex example), my callback DOES get called. <br>
<br>After doing some more research,</span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px"> it appears that the stream is getting stopped </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">and closed somehow right after I call startStream(). It happens in </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">RtAudio.cpp at RtApiIDs :: callBackEvent() on line 4534. The Sleep(50) call </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">is made, then, once it returns, the memory location *isRunning (in </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">RtAudio.cpp on line 4925) gets set to false. So sometime during that call </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">to Sleep (50), that assignment to false happens, which causes the threads </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">responsible for calling the callback to terminate. But, for some reason, if </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">I sleep the thread right after the call to startStream is made (by waiting for </span><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px">user input), that assignment to false DOESN&#39;T happen.</span><p style="margin-top:15px;margin-right:0px;margin-bottom:0px!important;margin-left:0px;padding:0px;border:0px;color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px;background-color:rgb(251,251,251)">
Note that I&#39;m using a duplex stream, also I&#39;m using the SFML library for my game code. Also, I&#39;ve compiled RtAudio for DSOUND on Windows.</p><div><span style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px;background-color:rgb(255,255,255)"><br>
</span></div><div><span style="color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:20px;background-color:rgb(255,255,255)">How can I make sure that my callback gets called while also running the main loop for the game?</span>
</div>