diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-07-25 17:42:36 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-07-25 17:43:12 +1000 |
| commit | 80d7df910987db5201402fe987124f29f09344f3 (patch) | |
| tree | 7e8c1e04ab40026087343efee95a771c7839b32f /src/codecs | |
| parent | 7b72e5479ee6d11f76c49f7463ba0e7f4e5165c5 (diff) | |
| download | tangara-fw-80d7df910987db5201402fe987124f29f09344f3.tar.gz | |
fuck off
Diffstat (limited to 'src/codecs')
| -rw-r--r-- | src/codecs/include/codec.hpp | 12 | ||||
| -rw-r--r-- | src/codecs/mad.cpp | 8 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/codecs/include/codec.hpp b/src/codecs/include/codec.hpp index 299b16e4..e8be8f0a 100644 --- a/src/codecs/include/codec.hpp +++ b/src/codecs/include/codec.hpp @@ -40,6 +40,18 @@ class ICodec { kInternalError, }; + static auto ErrorString(Error err) -> std::string { + switch (err) { + case Error::kOutOfInput: + return "out of input"; + case Error::kMalformedData: + return "malformed data"; + case Error::kInternalError: + return "internal error"; + } + return "uhh"; + } + /* * Alias for more readable return types. All codec methods, success or * failure, should also return the number of bytes they consumed. diff --git a/src/codecs/mad.cpp b/src/codecs/mad.cpp index 8b4e2561..29e34a0f 100644 --- a/src/codecs/mad.cpp +++ b/src/codecs/mad.cpp @@ -145,11 +145,13 @@ auto MadMp3Decoder::ContinueStream(cpp::span<const std::byte> input, for (int channel = 0; channel < synth_.pcm.channels; channel++) { uint32_t sample_24 = mad_fixed_to_pcm(synth_.pcm.samples[channel][current_sample_], 24); - output[output_byte++] = static_cast<std::byte>((sample_24 >> 16) & 0xFF); - output[output_byte++] = static_cast<std::byte>((sample_24 >> 8) & 0xFF); - output[output_byte++] = static_cast<std::byte>((sample_24)&0xFF); + // 24 bit samples must still be aligned to 32 bits. The LSB is ignored. output[output_byte++] = static_cast<std::byte>(0); + + output[output_byte++] = static_cast<std::byte>((sample_24)&0xFF); + output[output_byte++] = static_cast<std::byte>((sample_24 >> 8) & 0xFF); + output[output_byte++] = static_cast<std::byte>((sample_24 >> 16) & 0xFF); } current_sample_++; } |
