MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ProcessPreview

Method ProcessPreview

engine/PoseidonOpenAL/SoundSystemOAL.cpp:1262–1341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1260 const float seekTo = audio::DevicePreviewOffsetSeconds(now, _devicePreviewAnchorMs, _devicePreviewLengthSec);
1261 // Stash the seek on the wave so DoPlay applies it once the AL
1262 // source actually exists (Play() defers to next Commit, so
1263 // alSourcef here would no-op against a 0 source).
1264 if (auto* w = dynamic_cast<WaveOAL*>(wave))
1265 w->_pendingSeekSeconds = seekTo;
1266 wave->Play();
1267
1268 LOG_DEBUG(Audio, "StartDevicePreview: playing '{}' from offset {:.2f}s (anchor={}ms)",
1269 static_cast<const char*>(name), seekTo, _devicePreviewAnchorMs);
1270}
1271
1272void SoundSystemOAL::ProcessPreview()
1273{
1274 if (!_doPreview)
1275 return;
1276
1277 uint32_t now = GlobalTickCount();
1278 if (now < _previewTime)
1279 return;
1280
1281 float deltaT = 0.1f;
1282
1283 if (!_previewSpeech)
1284 {
1285 SoundPars pars{};
1286 ResolvePreviewSoundArray("speech", pars);
1287 RStringB name = pars.name;
1288 LOG_DEBUG(Audio, "Preview: loading speech '{}'", static_cast<const char*>(name));
1289 IWave* wave = CreateWave(name, false, true);
1290 _previewSpeech = wave;
1291 if (wave)
1292 {
1293 wave->SetKind(WaveSpeech);
1294 wave->EnableAccommodation(false);
1295 wave->SetSticky(true);
1296 wave->SetVolume(pars.vol, pars.freq, true);
1297 wave->Repeat(1);
1298 wave->Play();
1299 }
1300 else
1301 {
1302 LOG_WARN(Audio, "Preview: failed to create speech wave '{}'", static_cast<const char*>(name));
1303 _doPreview = false;
1304 }
1305 }
1306 else if (PreviewAdvance(_previewSpeech, deltaT) && !_previewEffect)
1307 {
1308 SoundPars pars{};
1309 ResolvePreviewSoundArray("effect", pars);
1310 RStringB name = pars.name;
1311 LOG_DEBUG(Audio, "Preview: loading effect '{}'", static_cast<const char*>(name));
1312 IWave* wave = CreateWave(name, true, false);
1313 _previewEffect = wave;
1314 if (wave)
1315 {
1316 wave->EnableAccommodation(false);
1317 wave->SetSticky(true);
1318 wave->SetVolume(pars.vol, pars.freq, true);
1319 wave->SetPosition(_listenerPos + _listenerDir * 50, _listenerVel, true);

Callers

nothing calls this directly

Calls 12

GlobalTickCountFunction · 0.85
ResolvePreviewSoundArrayFunction · 0.85
PreviewAdvanceFunction · 0.85
ResolvePreviewMusicTrackFunction · 0.85
SetStickyMethod · 0.80
SetKindMethod · 0.45
EnableAccommodationMethod · 0.45
SetVolumeMethod · 0.45
RepeatMethod · 0.45
PlayMethod · 0.45
SetPositionMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected