These issues were identified by the STACK tool.
By default, the C++ new operator will throw an exception on allocation
failure, rather than returning a null pointer.
The result is that testing the returned pointer for null is redundant
and _may_ be removed by the compiler. This is thus optimization
unstable and may result in incorrect behaviour at runtime.
However, we do not use exceptions as they are not supported by all
compilers and may be disabled.
To make this stable without removing the null check, you could qualify
the new operator call with std::nothrow to indicate that this should
return a null, rather than throwing an exception.
However, using (std::nothrow) was not desirable due to the Symbian
toolchain lacking a <new> header.
A global solution to this was also not easy by redefining "new" as "new
(std::nothrow)" due to custom constructors in NDS toolchain and various
common classes.
Also, this would then need explicit checks for OOM adding to all new
usages as per C malloc which is untidy.
For now to remove this optimisation unstable code is best as it is
likely to not be present anyway, and OOM will cause a system library
exception instead, even without exceptions enabled in the application
code.
Formerly when an unsupported block was found the opening would fail. Instead
now all the valid blocks till that occasion will be played.
This fixes an missing sound in Full Throttle (thanks to clone2727 for
reporting), which is using a VOC file which fails to specify the proper block
length for its sound block.
This should allow the QDM2 codec to work again with Common::Bitstream
instead of the older getBits() reader, but this aborts with a reading
past end of stream error...
getBits(n) would cause a runtime error if n is greater than 32,
but using getBits() to skip is no longer necessary as the newer
BitStream class has a skip method, which is used instead.
This removes the internal getBitContext bitwise reading code and
replaces with Common::BitStream.
However, this breaks the codec as in one location, the internal buffer
of getBitContext reader is used and this can't be directly replaced.
This will need to be understood and rewritten.
The number of channels in AAC can differ from the actual number of channels needed making us require this. The channel count inside the container is always the correct one.
find -name '*.h' -or -name '*.cpp' | xargs sed -r -i 's@\(([A-Za-z0-9]+)\*\)@(\1 *)@g'
This seems to have caught some params as well which is not undesirable IMO.
It also caught some strings containing this which is undesirable so I
excluded them manually. (engines/sci/engine/kernel_tables.h)
This drops the (unused) ability to play based on a list of input blocks. This
was formely only used by the NDS specific VOC streaming code, which has been
removed in 9fa9f68789.
Now all VOCs are streamed rather than preloaded. This deprecates the
STREAM_AUDIO_FROM_DISK define, which was previously used to stream VOCs from
disk.
This might very well break some engines which relied on the stream not being
changed after makeVOCStream! I adapted all engines which had a check for
STREAM_AUDIO_FROM_DISK in their code.
It would be wise to check all other engines using VOC to see if this might
cause any problems for them.