| 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 | |
| 1272 | void 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); |
nothing calls this directly
no test coverage detected