cores icon indicating copy to clipboard operation
cores copied to clipboard

AudioStream: Add destructor. Enables dynamic creation and destruction.

Open chipaudette opened this issue 5 months ago • 2 comments

There's been great work on dynamic creation and destruction of AudioConnection instances. But, one has not been able to dynamically destroy AudioStream instances. This pull request seeks to remove this limitation.

In my view, the primary issue preventing dynamic destruction of AudioStream instancs is that the user had no way of removing an AudioStream instance from the AudioStream update list. You could go ahead and delete your instance, but the update list would still try to use that stale pointer. That would cause the system to hang.

This pull request adds a destructor to AudioStream. Now, when an AudioStream instance is destroyed, it removes the instance from the AudioStream update list.

The user must still remember to close out all of the AudioConnections that use the destroyed AudioStream instance, but that's at least possible for the user to do. Without AudioStream having a destructor, there is no way for the user to remove the instance to the update list.

This pull request includes both Teensy3 and Teensy4. It has been tested on a Teensy 4.1 and a Teensy 3.6.

chipaudette avatar Sep 09 '24 14:09 chipaudette