diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-riff.cpp | 23 | ||||
| -rw-r--r-- | source/core/slang-riff.h | 8 |
2 files changed, 24 insertions, 7 deletions
diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp index 0eb0381e1..c1e3e81c3 100644 --- a/source/core/slang-riff.cpp +++ b/source/core/slang-riff.cpp @@ -758,6 +758,24 @@ void RiffContainer::_addChunk(Chunk* chunk) } } +void RiffContainer::setCurrentChunk(Chunk* chunk) +{ + SLANG_ASSERT(chunk); + + switch (chunk->m_kind) + { + case Chunk::Kind::Data: + m_listChunk = nullptr; + m_dataChunk = static_cast<RiffContainer::DataChunk*>(chunk); + break; + + case Chunk::Kind::List: + m_dataChunk = nullptr; + m_listChunk = static_cast<RiffContainer::ListChunk*>(chunk); + break; + } +} + void RiffContainer::startChunk(Chunk::Kind kind, FourCC fourCC) { SLANG_ASSERT(m_listChunk || m_rootList == nullptr); @@ -857,7 +875,10 @@ void RiffContainer::setPayload(Data* data, const void* payload, size_t size) data->m_ownership = Ownership::Arena; data->m_size = size; - data->m_payload = m_arena.allocateAligned(size, kPayloadMinAlignment); + if (size) + { + data->m_payload = m_arena.allocateAligned(size, kPayloadMinAlignment); + } if (payload) { diff --git a/source/core/slang-riff.h b/source/core/slang-riff.h index 1e2c883b9..c858158e6 100644 --- a/source/core/slang-riff.h +++ b/source/core/slang-riff.h @@ -24,17 +24,11 @@ typedef uint32_t FourCC; #define SLANG_FOUR_CC(c0, c1, c2, c3) \ ((FourCC(c0) << 0) | (FourCC(c1) << 8) | (FourCC(c2) << 16) | (FourCC(c3) << 24)) -#define SLANG_FOUR_CC_GET_FIRST_CHAR(x) char((x) & 0xff) -#define SLANG_FOUR_CC_REPLACE_FIRST_CHAR(x, c) (((x) & 0xffffff00) | FourCC(c)) - #else #define SLANG_FOUR_CC(c0, c1, c2, c3) \ ((FourCC(c0) << 24) | (FourCC(c1) << 16) | (FourCC(c2) << 8) | (FourCC(c3) << 0)) -#define SLANG_FOUR_CC_GET_FIRST_CHAR(x) char((x) >> 24) -#define SLANG_FOUR_CC_REPLACE_FIRST_CHAR(x, c) (((x) & 0x00ffffff) | (FourCC(c) << 24)) - #endif enum @@ -451,6 +445,8 @@ public: /// Ctor RiffContainer(); + void setCurrentChunk(Chunk* chunk); + protected: void _addChunk(Chunk* chunk); ListChunk* _newListChunk(FourCC subType); |
