| 80 | } |
| 81 | |
| 82 | void AudioSampleTable::LoadFrom(const AudioSampleTable& table, size_t sourceStartIndex, size_t length) |
| 83 | { |
| 84 | // Ensure we stay in bounds of source table |
| 85 | if (sourceStartIndex >= table._entries.size()) |
| 86 | return; |
| 87 | length = std::min(length, table._entries.size() - sourceStartIndex); |
| 88 | |
| 89 | // Asset packs may allocate more images for an object that original, or original object may |
| 90 | // not allocate any images at all. |
| 91 | if (_entries.size() < length) |
| 92 | { |
| 93 | _entries.resize(length); |
| 94 | } |
| 95 | |
| 96 | for (size_t i = 0; i < length; i++) |
| 97 | { |
| 98 | const auto& sourceEntry = table._entries[sourceStartIndex + i]; |
| 99 | if (sourceEntry.Asset) |
| 100 | { |
| 101 | auto stream = sourceEntry.Asset->GetStream(); |
| 102 | if (stream != nullptr) |
| 103 | { |
| 104 | auto& entry = _entries[i]; |
| 105 | entry.Asset = sourceEntry.Asset; |
| 106 | entry.PathIndex = sourceEntry.PathIndex; |
| 107 | entry.Modifier = sourceEntry.Modifier; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | void AudioSampleTable::Load() |
| 114 | { |
no test coverage detected