From add3a16f25b02b73cdfac00ce4bd936a1dc54696 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Thu, 3 Nov 2016 14:45:20 -0500 Subject: [PATCH] Increase buffer size. Don't use sizeof on heap buffer (returns pointer size). --- apu/apu.cpp | 9 +++++++-- gtk/Makefile.am | 5 +++++ memmap.cpp | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apu/apu.cpp b/apu/apu.cpp index c897e90f..f1fe4b5e 100644 --- a/apu/apu.cpp +++ b/apu/apu.cpp @@ -336,9 +336,9 @@ bool8 S9xMixSamples (uint8 *buffer, int sample_count) { if (msu::resampler->avail() >= sample_count) { - uint8 *msu_sample = new uint8[sizeof(dest)]; + uint8 *msu_sample = new uint8[shrink_buffer_size]; msu::resampler->read((short *)msu_sample, sample_count); - for(uint32 i = 0; i < sizeof(dest); ++i) + for(uint32 i = 0; i < sample_count; ++i) dest[i] += msu_sample[i]; } } @@ -481,7 +481,12 @@ bool8 S9xInitSound (int buffer_ms, int lag_ms) if (Settings.SixteenBitSound) spc::buffer_size <<= 1; if (Settings.MSU1) + { + /* MSU1 is 44.1KHz, 16-bit audio */ msu::buffer_size = buffer_ms * 44100 / 1000; + msu::buffer_size *= 2; /* Double byte-count for stereo */ + msu::buffer_size *= 2; /* Double byte-count for 16-bit audio */ + } printf("Sound buffer size: %d (%d samples)\n", spc::buffer_size, sample_count); diff --git a/gtk/Makefile.am b/gtk/Makefile.am index fad1cf22..aa39c195 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -136,6 +136,11 @@ snes9x_gtk_SOURCES += \ ../apu/bapu/smp/smp.cpp \ ../apu/bapu/smp/smp_state.cpp +# MSU1 +snes9x_gtk_SOURCES += \ + ../msu1.cpp \ + ../msu1.h + # DSP snes9x_gtk_SOURCES += \ ../dsp.cpp \ diff --git a/memmap.cpp b/memmap.cpp index 72fc90fb..8a511b67 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -201,6 +201,7 @@ #endif #include +#include #include "snes9x.h" #include "memmap.h" @@ -1889,7 +1890,7 @@ bool8 CMemory::LoadMultiCartInt () memmove(ROM + Multi.cartOffsetA, ROM, Multi.cartSizeA + Multi.cartSizeB); else if(Multi.cartOffsetB) // clear cart A so the bios can detect that it's not present memset(ROM, 0, Multi.cartOffsetB); - + FILE *fp; size_t size; char path[PATH_MAX + 1];