GCC helpfully indicates, that:
warning: this ‘if’ clause does not guard (…) this statement, but
the latter is misleadingly indented as if it were guarded by the ‘if’.
Also, improve readability while we're touching these lines.
This bug was detected via Coverity static analysis:
Variable tempfile going out of scope leaks the storage it points to.
The leak happens when invalid keyboard layout file is being loaded:
$ touch xx.kl
$ dosbox .
C:\>keyb xx
Issue reported by Dagar and Pr3tty F1y, and confirmed as a bug by ripsaw8080.
Thank you!
This fixes the GoG release of Betrayal at Krondor which (either due to CD mastering
issues or a faulty rip), requests playback of a given track at the tail end
of the prior track.
In debugging and performing this fix, many debug messages were improved as well
as making some small small code adjustments, such as using iterators to point to
individual tracks (track->attribute) instead of using the tracks array
(tracks[track -1].attribute).
Clang static analyzer returned a false-positive issue in line 671:
The right operand of '<' is a garbage value
Variables needed to be moved up, because otherwise initialization
crosses to the next case.
Static analysis indicated an issue, when line was being passed as 2nd
argument to strcat:
Null pointer passed as an argument to a 'nonnull' parameter
Replace repeated strcat with creating a formatted string and use
the opportunity to do a small format cleanup.
These files assume, that WIN32 is defined by compiler or MSVC project
file, when in MSYS2 and MinGW environments, it is defined in config.h
and appears after dosbox.h is included, which in turn is included by
associated header (cdrom.h in this case).
Fixes: #42
Use C++11 static_assert to assure, that code behaves correctly; if
Chip or Channel structs will be changed to non-std layout or a different
first fields will be introduced, that will invalidate the offset
calculation.
Additionally, add asserts to prevent possibility of introducing a bug
when offset stored in one the tables is 0.
Silence compiler warnings:
enumeration value 'sm2Percussion' not handled in switch [-Wswitch]
enumeration value 'sm3Percussion' not handled in switch [-Wswitch]
Thanks to @ripsaw8080 for insight into CD-DA channel mapping,
@hail-to-the-ryzen for testing and flagging a position-tracking bug,
and @dreamer_ for guidance and code review.
The CD-DA volume and channel mapping loops were moved to generic mixer
calls and no longer require a pre-processing loop:
- Application-controlled CD-DA volume adjustment is now applied using
an existing mixer volume scalar that was previously unused by the
CD-DA code.
- Mapping of CD-DA left and right channels is now applied at the tail
end of the mixer's sample ingest sequence.
The following have been removed:
- The CD-DA callback chunk-wise circular buffer
- The decode buffers in the Opus and MP3 decoders
- The decode buffer and conversion buffers in SDL_Sound
These removals and API changes allow the image player's buffer
to be passed-through ultimately to the audio codec, skipping multiple
intermediate buffers.