Closed jackhallybone closed 8 years ago
The problem is that the underlying library requires to run either in callback mode or in read/write-function mode. This has to be decided when the Stream is created, and can't be changed later. There's nothing I can do about this on the Python side to change this. Sorry.
Okay, thank you - I didn't realise that! Is it possible to, or worth considering, creating the stream only when the stream is started, if that is the first point where it would be required? I guess this would allow Stream properties to be set and updated, up until the point where the stream actually starts and properties must be fixed?
This would be possible, yes. It would have the disadvantage that the Stream
object would report errors only when first used, and those errors would potentially refer to incorrect property values that were set at a different time. I prefer the current behavior where errors are created at the time where the incorrect values were set.
That said, it is probably pretty easy to create a wrapper for the Stream
object, that only initializes the object when actually used. This is something you can probably easily do in your own code base. If you want to share it, I could link to it in the README, or even incorporate it in PySoundCard.
Okay, thank you, I understand. We've got a workaround for the moment, but I'll let you know if we end up writing anything worth sharing/incorporating. Cheers
We are trying to set the callback after the Stream initialisation, something like below, which doesn't work:
This could be useful, for example, to allow the user to setup the audio properties, before handing us the stream to setup the callback and read/write.
Perhaps using properties to set the callback, and only then create the callback_wrapper, could solve this?
Then from outside you can do
at any time (before stream.start) to set the callback.