bastibe/PySoundCard

Don't call stop() in __exit__()?

Closed this issue · 1 comments

I'm not quite sure, but it seems more sensible to only call self.close() in __exit__().

I don't even know the implications of the call to stop().
Either it is "superseded" by the following call to close(), in which case it would be superfluous.
Or it blocks until all pending buffers are played out, which is probably not what you expect from __exit__().

stop waits for all queued samples to play. This is necessary in __exit__(), else

with Stream(...) as s:
   s.write(...)

would abort as soon as s.write() returns, which is one block length before all samples are played.

close in contrast is equivalent to abort and will not wait for queued samples to play.