From 58fd39d57a0fd91603c20e665f42a1268ba5788a Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 20 Dec 2014 04:24:43 +0100 Subject: [PATCH] Zelda HLE: Value-initialize the std::arrays. I was under the wrong impression that std::array's default constructor performed value initialization. Turns out it does not, so an array of POD will not be initialized. --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 3 ++ Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h | 40 +++++++-------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 5f99618a7d..18424e573c 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -549,6 +549,9 @@ void ZeldaAudioRenderer::PrepareFrame() if (m_buf_back_left[0] != 0 || m_buf_back_right[0] != 0) PanicAlert("Zelda HLE using back mixing buffers"); + m_buf_back_left.fill(0); + m_buf_back_right.fill(0); + // TODO: Dolby/reverb mixing here. m_prepared = true; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h index 1b5b32057b..7dbfadbf82 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.h @@ -88,14 +88,14 @@ private: // Mixing buffers. typedef std::array MixingBuffer; - MixingBuffer m_buf_front_left; - MixingBuffer m_buf_front_right; - MixingBuffer m_buf_back_left; - MixingBuffer m_buf_back_right; - MixingBuffer m_buf_front_left_reverb; - MixingBuffer m_buf_front_right_reverb; - MixingBuffer m_buf_back_left_reverb; - MixingBuffer m_buf_back_right_reverb; + MixingBuffer m_buf_front_left{}; + MixingBuffer m_buf_front_right{}; + MixingBuffer m_buf_back_left{}; + MixingBuffer m_buf_back_right{}; + MixingBuffer m_buf_front_left_reverb{}; + MixingBuffer m_buf_front_right_reverb{}; + MixingBuffer m_buf_back_left_reverb{}; + MixingBuffer m_buf_back_right_reverb{}; // Base address where VPBs are stored linearly in RAM. u32 m_vpb_base_addr; @@ -104,7 +104,7 @@ private: // Sine table transferred from MRAM. Contains sin(x) values for x in // [0.0;pi/4] (sin(x) in [1.0;0.0]), in 1.15 fixed format. - std::array m_sine_table; + std::array m_sine_table{}; // Fills up a buffer with the input samples for a voice, represented by its // VPB. @@ -121,22 +121,6 @@ private: // Coefficients used for resampling. std::array m_resampling_coeffs{}; - // If non zero, base MRAM address for sound data transfers from ARAM. On - // the Wii, this points to some MRAM location since there is no ARAM to be - // used. If zero, use the top of ARAM. - u32 m_aram_base_addr = 0; - void* GetARAMPtr() const; - - // Downloads PCM encoded samples from ARAM. Handles looping and other - // parameters appropriately. - template void DownloadPCMSamplesFromARAM(s16* dst, VPB* vpb, u16 requested_samples_count); - - // Downloads AFC encoded samples from ARAM and decode them. Handles looping - // and other parameters appropriately. - void DownloadAFCSamplesFromARAM(s16* dst, VPB* vpb, u16 requested_samples_count); - void DecodeAFC(VPB* vpb, s16* dst, size_t block_count); - std::array m_afc_coeffs{}; - // Downloads samples from MRAM while handling appropriate length / looping // behavior. void DownloadRawSamplesFromMRAM(s16* dst, VPB* vpb, u16 requested_samples_count); @@ -145,7 +129,7 @@ private: // and other parameters appropriately. void DownloadAFCSamplesFromARAM(s16* dst, VPB* vpb, u16 requested_samples_count); void DecodeAFC(VPB* vpb, s16* dst, size_t block_count); - std::array m_afc_coeffs; + std::array m_afc_coeffs{}; }; class ZeldaUCode : public UCodeInterface @@ -192,12 +176,12 @@ private: // these sync mails contain 16 bit values that are used as bitfields to // control voice skipping on a voice per voice level. u32 m_sync_max_voice_id = 0; - std::array m_sync_voice_skip_flags; + std::array m_sync_voice_skip_flags{}; // Command buffer (circular queue with r/w indices). Filled by HandleMail // when the state machine is in WRITING_CMD state. Commands get executed // when entering WAITING state and we are not rendering audio. - std::array m_cmd_buffer; + std::array m_cmd_buffer{}; u32 m_read_offset = 0; u32 m_write_offset = 0; u32 m_pending_commands_count = 0;