| 116 | } |
| 117 | |
| 118 | int SoundSample::SetChunkStream(std::string filePath, bool isMp3, bool logErrors) |
| 119 | { |
| 120 | SDL_RWops *handle = OpenAssetAsSdlRwOps(filePath.c_str(), /*threadsafe=*/true); |
| 121 | if (handle == nullptr) { |
| 122 | if (logErrors) |
| 123 | LogError(LogCategory::Audio, "OpenAsset failed (from SoundSample::SetChunkStream) for {}: {}", filePath, SDL_GetError()); |
| 124 | return -1; |
| 125 | } |
| 126 | file_path_ = std::move(filePath); |
| 127 | isMp3_ = isMp3; |
| 128 | stream_ = CreateStream(handle, isMp3); |
| 129 | if (!stream_->open()) { |
| 130 | stream_ = nullptr; |
| 131 | if (logErrors) |
| 132 | LogError(LogCategory::Audio, "Aulib::Stream::open (from SoundSample::SetChunkStream) for {}: {}", file_path_, SDL_GetError()); |
| 133 | return -1; |
| 134 | } |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | int SoundSample::SetChunk(ArraySharedPtr<std::uint8_t> fileData, std::size_t dwBytes, bool isMp3) |
| 139 | { |
no test coverage detected