From 64fbb923cae22bb6fd6e31843fe940f4674e227f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 24 Aug 2019 22:39:10 -0400 Subject: [PATCH] MIDIDecoder: Make readContinuedValue an internal function This doesn't rely on any member state, so it can be decoupled from the interface entirely. --- include/boo/audiodev/MIDIDecoder.hpp | 2 -- lib/audiodev/MIDIDecoder.cpp | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/boo/audiodev/MIDIDecoder.hpp b/include/boo/audiodev/MIDIDecoder.hpp index 79a1047..8ce82bb 100644 --- a/include/boo/audiodev/MIDIDecoder.hpp +++ b/include/boo/audiodev/MIDIDecoder.hpp @@ -9,8 +9,6 @@ class IMIDIReader; class MIDIDecoder { IMIDIReader& m_out; uint8_t m_status = 0; - bool _readContinuedValue(std::vector::const_iterator& it, std::vector::const_iterator end, - uint32_t& valOut); public: MIDIDecoder(IMIDIReader& out) : m_out(out) {} diff --git a/lib/audiodev/MIDIDecoder.cpp b/lib/audiodev/MIDIDecoder.cpp index e469fb8..d795272 100644 --- a/lib/audiodev/MIDIDecoder.cpp +++ b/lib/audiodev/MIDIDecoder.cpp @@ -7,11 +7,11 @@ namespace boo { - +namespace { constexpr uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); } -bool MIDIDecoder::_readContinuedValue(std::vector::const_iterator& it, - std::vector::const_iterator end, uint32_t& valOut) { +bool readContinuedValue(std::vector::const_iterator& it, std::vector::const_iterator end, + uint32_t& valOut) { uint8_t a = *it++; valOut = a & 0x7f; @@ -33,6 +33,7 @@ bool MIDIDecoder::_readContinuedValue(std::vector::const_iterator& it, return true; } +} // Anonymous namespace std::vector::const_iterator MIDIDecoder::receiveBytes(std::vector::const_iterator begin, std::vector::const_iterator end) { @@ -52,7 +53,7 @@ std::vector::const_iterator MIDIDecoder::receiveBytes(std::vector::const_iterator MIDIDecoder::receiveBytes(std::vector