MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / SetChunkStream

Method SetChunkStream

Source/utils/soundsample.cpp:118–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118int 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
138int SoundSample::SetChunk(ArraySharedPtr<std::uint8_t> fileData, std::size_t dwBytes, bool isMp3)
139{

Callers 1

LoadAudioFileFunction · 0.80

Calls 4

OpenAssetAsSdlRwOpsFunction · 0.85
LogErrorFunction · 0.85
CreateStreamFunction · 0.85
openMethod · 0.65

Tested by

no test coverage detected