MCPcopy Create free account
hub / github.com/EasyRPG/Player / CreateSeDecoder

Method CreateSeDecoder

src/audio_secache.cpp:136–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136std::unique_ptr<AudioDecoderBase> AudioSeCache::CreateSeDecoder() {
137 AudioSeRef se;
138
139 auto it = cache.find(name);
140 if (it != cache.end()) {
141 se = it->second;
142 se->last_access = Game_Clock::GetFrameTime();
143
144 std::unique_ptr<AudioDecoderBase> dec = std::make_unique<AudioSeDecoder>(se);
145#ifdef USE_AUDIO_RESAMPLER
146 dec = std::make_unique<AudioResampler>(std::move(dec));
147#endif
148 Filesystem_Stream::InputStream is;
149 dec->Open(std::move(is));
150 return dec;
151 }
152
153 // Not cached yet: Decode the sample without any resampling
154
155 if (!se) {
156 se.reset(new AudioSeData());
157 }
158
159 assert(audio_decoder);
160
161 audio_decoder->GetFormat(se->frequency, se->format, se->channels);
162 se->buffer = audio_decoder->DecodeAll();
163
164 cache.insert(std::make_pair(name, se));
165
166 cache_size += se->buffer.size();
167
168#ifdef CACHE_DEBUG
169 Output::Debug("SE cache size (Add): {}", cache_size / 1024.0 / 1024.0);
170#endif
171
172 FreeCacheMemory();
173
174 std::unique_ptr<AudioDecoderBase> dec = std::unique_ptr<AudioDecoderBase>(new AudioSeDecoder(se));
175#ifdef USE_AUDIO_RESAMPLER
176 dec = std::unique_ptr<AudioDecoderBase>(new AudioResampler(std::move(dec)));
177#endif
178 Filesystem_Stream::InputStream is;
179 dec->Open(std::move(is));
180 return dec;
181}
182
183AudioSeRef AudioSeCache::GetSeData() const {
184 auto it = cache.find(name);

Callers 2

PlayOnChannelMethod · 0.80
SE_PlayMethod · 0.80

Calls 7

FreeCacheMemoryFunction · 0.85
DecodeAllMethod · 0.80
endMethod · 0.45
OpenMethod · 0.45
resetMethod · 0.45
GetFormatMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected