Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkcgen <kcgen@users.noreply.github.com>2022-07-29 00:59:49 +0300
committerkcgen <kcgen@users.noreply.github.com>2022-07-29 01:01:04 +0300
commit5ba9646f0dfd665583728dd18ef8625a64f520c9 (patch)
tree29a0370d1c0566e5c3161513b39e18a7aecfae3f
parent73909db4948359f85e8ba4d3527c965aa094abb7 (diff)
Only mix whole stereo frames in SB 16-bit DMA modekc/sb-dma-1
Thanks to co-authors: - @Brandon Roberts for catching this and testing. - @Antti Peltola and and @Burrito78 for media procurement to assist in reproduction. In alphabetic order: Co-authored-by: Antti Peltola <antti.peltola@kolumbus.fi> Co-authored-by: Brandon Roberts <brandon@bxroberts.org> Co-authored-by: Burrito78 <Burrito78@users.noreply.github.com>
-rw-r--r--.clang-format2
-rw-r--r--src/hardware/sblaster.cpp43
2 files changed, 25 insertions, 20 deletions
diff --git a/.clang-format b/.clang-format
index d94f112cd..88de09553 100644
--- a/.clang-format
+++ b/.clang-format
@@ -20,7 +20,7 @@ TabWidth: 8
IndentWidth: 8
ContinuationIndentWidth: 8
-ColumnLimit: 80
+ColumnLimit: 120
# C/C++ Language specifics
#
diff --git a/src/hardware/sblaster.cpp b/src/hardware/sblaster.cpp
index 09ba53d46..2a568e2ae 100644
--- a/src/hardware/sblaster.cpp
+++ b/src/hardware/sblaster.cpp
@@ -785,30 +785,35 @@ static void PlayDMATransfer(uint32_t bytes_requested)
bytes_read = ReadDMA16(bytes_to_read, sb.dma.remain_size);
samples = bytes_read / dma16_to_sample_divisor + sb.dma.remain_size;
frames = check_cast<uint16_t>(samples / channels);
+
+ if (frames) {
+ // Only add whole frames when in stereo DMA mode, or
#if defined(WORDS_BIGENDIAN)
- if (sb.dma.sign) {
- sb.chan->AddSamples_s16_nonnative(frames,
- maybe_silence(samples, sb.dma.buf.b16));
- } else {
- sb.chan->AddSamples_s16u_nonnative(frames,
- maybe_silence(samples,
- reinterpret_cast<uint16_t *>(sb.dma.buf.b16)));
- }
+ if (sb.dma.sign) {
+ sb.chan->AddSamples_s16_nonnative(frames,
+ maybe_silence(samples, sb.dma.buf.b16));
+ } else {
+ sb.chan->AddSamples_s16u_nonnative(frames,
+ maybe_silence(samples, reinterpret_cast<uint16_t *>(sb.dma.buf.b16)));
+ }
#else
- if (sb.dma.sign) {
- sb.chan->AddSamples_s16(frames,
- maybe_silence(samples, sb.dma.buf.b16));
- } else {
- sb.chan->AddSamples_s16u(frames,
- maybe_silence(samples,
- reinterpret_cast<uint16_t *>(sb.dma.buf.b16)));
- }
+ if (sb.dma.sign) {
+ sb.chan->AddSamples_s16(frames,
+ maybe_silence(samples, sb.dma.buf.b16));
+ } else {
+ sb.chan->AddSamples_s16u(frames,
+ maybe_silence(samples, reinterpret_cast<uint16_t *>(sb.dma.buf.b16)));
+ }
#endif
- if (samples & 1) {
+ }
+ else if (samples & 1) {
+ // Carry over the dangling sample into the next round, or
sb.dma.remain_size = 1;
sb.dma.buf.b16[0] = sb.dma.buf.b16[samples - 1];
- } else {
- sb.dma.remain_size=0;
+ }
+ else {
+ // The DMA transfer is done
+ sb.dma.remain_size = 0;
}
} else { // 16-bit mono
bytes_read = ReadDMA16(bytes_to_read);