From a6072c51615161227bde0b041b26b8b52f75d966 Mon Sep 17 00:00:00 2001 From: Mike H Date: Tue, 20 Feb 2018 19:48:14 +0000 Subject: [PATCH] Official apps do this --- audio/playtone/source/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/audio/playtone/source/main.c b/audio/playtone/source/main.c index 71e49cb..a0bba86 100644 --- a/audio/playtone/source/main.c +++ b/audio/playtone/source/main.c @@ -35,15 +35,16 @@ int main(int argc, char **argv) }; // Make sure the sample buffer is aligned to 0x1000 bytes - u32 raw_data_size = ((SAMPLESPERBUF * BYTESPERSAMPLE * 2) + 0xfff) & ~0xfff; - u8* raw_data = memalign(0x1000, raw_data_size); + u32 raw_data_size = (SAMPLESPERBUF * BYTESPERSAMPLE * 2); + u32 raw_data_size_aligned = (raw_data_size + 0xfff) & ~0xfff; + u8* raw_data = memalign(0x1000, raw_data_size_aligned); // Ensure buffer was properly allocated if (raw_data == NULL) fatalSimple(MAKERESULT(Module_Libnx, LibnxError_OutOfMemory)); // Clear the buffer - memset(raw_data, 0, raw_data_size); + memset(raw_data, 0, raw_data_size_aligned); gfxInitDefault();