AudioFormatWriter deletes the OutputStream


#1

Seems a little bit unfriendly for AudioFormatWriter to delete OutputStream…what if I want to keep the output stream?


#2

In that case, tough luck. But since nobody’s ever asked for it, I guess it’s a pretty uncommon thing to do.

I’ve been thinking of coming up with a new type of smart pointer for situations like that, where objects take pointers to other objects that they may or may not delete. At the moment I’ve got various booleans called things like “shouldDeleteWhenFinished”, but have been considering wrapping the pointers in a smart pointer that contains this ownership information instead, which would simplify the code quite a bit, and make the user-end code more readable.


#3

Thats a great idea! I never did like those ‘should delete’ bools. But I do like having the choice.


#4

Maybe a non-intrusive scheme like http://ootips.org/yonat/4dev/linked_ptr.h ?


#5

This is an old thread – but I just had a scenario where it would have been easier to not have the OutputStream deleted… Simple enough to deal with, but it would have been great to have the option for AudioFormatWriter to not delete the outputStream… Put this down as a feature request.

Thanks,

Rail