| 160 | } |
| 161 | |
| 162 | bool AudioClip::ExtractData(Array<byte>& resultData, AudioDataInfo& resultDataInfo) |
| 163 | { |
| 164 | ASSERT(!IsVirtual()); |
| 165 | if (WaitForLoaded()) |
| 166 | return true; |
| 167 | ScopeLock lock(Locker); |
| 168 | auto storageLock = Storage->LockSafe(); |
| 169 | |
| 170 | // Allocate memory |
| 171 | ASSERT(_totalChunksSize > 0); |
| 172 | resultData.Resize(_totalChunksSize); |
| 173 | |
| 174 | // Load and copy data |
| 175 | if (LoadChunks(ALL_ASSET_CHUNKS)) |
| 176 | return true; |
| 177 | int32 pos = 0; |
| 178 | Storage->LockChunks(); |
| 179 | for (int32 i = 0; i < _totalChunks; i++) |
| 180 | { |
| 181 | const auto chunk = GetChunk(i); |
| 182 | const uint32 size = chunk->Size(); |
| 183 | Platform::MemoryCopy(resultData.Get() + pos, chunk->Get(), size); |
| 184 | pos += size; |
| 185 | } |
| 186 | Storage->UnlockChunks(); |
| 187 | ASSERT(pos == _totalChunksSize); |
| 188 | |
| 189 | // Copy header |
| 190 | resultDataInfo = AudioHeader.Info; |
| 191 | |
| 192 | return false; |
| 193 | } |
| 194 | |
| 195 | bool AudioClip::ExtractDataFloat(Array<float>& resultData, AudioDataInfo& resultDataInfo) |
| 196 | { |