[Interest] is it ok to push audio on a background thread, not a timer?
David M. Cotter
dave at kjams.com
Tue May 19 04:33:03 CEST 2020
>>> 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.
>
> That's not clear from your code:
> QAudioOutput *audioOutput(auP->i_qGeneratorP->i_qOutputP.get());
>
> The CAudioUnit class is not defined anywhere in your code.
that class is NOT a QObject, it's my own class, which does not care about thread affinity
>> Specifically: both i_qGeneratorP and i_qOutputP are allocated there. I think
>> they're the only Qt objects use within the new thread?
>
> If you say so, but I can't confirm that you've done the right thing since I
> can't see those classes
they are both QObjects, and are allocated with "new" during i_auP->Start()
> Note that you do initialise the i_auP pointer in your constructor's initialisation list
which is not a QObject, it's my own wrapper class
> You call this GetCUnit_Out() function in both threads. I can't tell what this
> function is doing, I don't know what i_qGeneratorP is
it's a QObject, specifically a QIODevice
> and what thread its i_qOutputP pointer is filled in.
as i said, i_qOutputP is new'd during i_auP->Start(), and is of type QAudioOutput
> PS: if you're using Hungarian notation, doesn't the "i" prefix indicate
> "integer"?
no. 25 years ago, we use "i_" to indicate "instance (member) variables" in the "THINK Class Library"
i've had that habit ever since
> Why are you using it for pointers?
cuz it's an instance variable of a pointer
> Perhaps you're too young for proper Hungarian writing :-)
lol, i wonder if i'm older than you :)
:)
More information about the Interest
mailing list