[Interest] is it ok to push audio on a background thread, not a timer?

David M. Cotter dave at kjams.com
Tue May 19 02:42:10 CEST 2020


>> i have a cross platform (mac / win) app that plays audio.
>> i'm using the push method for audio PCM
>> instead of using a timer, i'm just running the pump on a background thread.
>> 
>> This works fine on mac, but produces silence on windows.
>> 
>> is this... a limitation?
> 
> No, it's a bug in your code.
> 
> Like every QObject class, unless noted otherwise, you may not call methods on 
> the object from outside the object's thread of affinity (the one it was 
> created in or moved to with moveToThread). Your code is abusing the API in 
> both cases if you're using the API from another thread.
To be clear: I'm not  initting any Qt objects in the constructor, that all  happens inside the run() function, in the i_auP->Start(&i_outP); call.

Specifically: both i_qGeneratorP and i_qOutputP are allocated there. I think they're the only Qt objects use within the new thread?

Is there some other object you think is being cross-thread abused?

You mention "both cases", what cases are you referring to?

-dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200518/b7fd1bdf/attachment.html>


More information about the Interest mailing list