If a file byte stream fails creation fails, should the stream be released? There seems to be mixed messaging around this. E.g. Mp4Edit.cpp has
result = AP4_FileByteStream::Create(output_filename, AP4_FileByteStream::STREAM_MODE_WRITE, output);
if (AP4_FAILED(result)) {
fprintf(stderr, "ERROR: cannot open output file (%s)\n", output_filename);
input->Release();
return 1;
}
I.e. yes, the stream should be released (input->Release();).
However, from Mp4Dump.cpp
AP4_Result result = AP4_FileByteStream::Create(dump_filename, AP4_FileByteStream::STREAM_MODE_WRITE, output);
if (AP4_FAILED(result)) {
fprintf(stderr, "ERROR: %d cannot open file for dumping track %d",
result, track_id);
}
no release is performed.
Maybe worth upstreaming something once it's clear which should be done. If nothing else it could be worth documenting in Ap4FileByteStream.h, which currently doesn't mention what should be done.
/**
* Create a stream from a file (opened or created).
*
* @param name Name of the file to open or create
* @param mode Mode to use for the file
* @param stream Reference to a pointer where the stream object will
* be returned
* @return AP4_SUCCESS if the file can be opened or created, or an error code if
* it cannot
*/
static AP4_Result Create(const char* name, Mode mode, AP4_ByteStream*& stream);
If a file byte stream fails creation fails, should the stream be released? There seems to be mixed messaging around this. E.g. Mp4Edit.cpp has
I.e. yes, the stream should be released (
input->Release();).However, from Mp4Dump.cpp
no release is performed.
Maybe worth upstreaming something once it's clear which should be done. If nothing else it could be worth documenting in
Ap4FileByteStream.h, which currently doesn't mention what should be done.