self._stream_ref=weakref.ref(stream)# Keep a weak reference before the stream is initialized to avoid a memory cycle that would delay releasing audio resources
self._stream=None# We will store the actual reference once it's initialized and we're guaranteed to get MediaStreamDidEnd and do the cleanup