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

Method StartCategoryPreview

engine/PoseidonOpenAL/SoundSystemOAL.cpp:1152–1210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1150 // worker holds the lambda; the mission-load call site runs inside
1151 // the loading screen where that cannot happen, but guard the late
1152 // case by running synchronously when no pool exists.
1153 if (auto* pool = GetGlobalTaskPool())
1154 {
1155 pool->Submit(work);
1156 }
1157 else
1158 {
1159 work();
1160 }
1161}
1162void SoundSystemOAL::StartCategoryPreview(WaveKind kind)
1163{
1164 if (!_enablePreview)
1165 return;
1166
1167 // Stop the legacy 3-stage chain AND the device-picker preview if
1168 // either is running — the category preview is a different focus
1169 // mode and should be heard alone.
1170 _previewSpeech.Free();
1171 _previewEffect.Free();
1172 _previewMusic.Free();
1173 _previewDevice.Free();
1174 _devicePreviewAnchorMs = 0;
1175 _devicePreviewLengthSec = 0.0f;
1176 _doPreview = false;
1177
1178 // Tear the previous category preview down — even if it's the same
1179 // kind — so a volume slider drag restarts the wave and the user
1180 // hears the new level immediately on the next cycle.
1181 _previewCategory.Free();
1182 _previewCategoryKind = kind;
1183
1184 const char* slot = (kind == WaveSpeech) ? "speech" : (kind == WaveMusic) ? "music" : "effect";
1185 SoundPars pars{};
1186 if (kind == WaveMusic)
1187 {
1188 if (!ResolvePreviewMusicTrack("musicTrack", pars))
1189 ResolvePreviewSoundArray(slot, pars);
1190 }
1191 else
1192 {
1193 ResolvePreviewSoundArray(slot, pars);
1194 }
1195 RStringB name = pars.name;
1196 float vol = pars.vol, freq = pars.freq;
1197 bool is3D = (kind == WaveEffect); // matches legacy chain — only effect is 3D
1198 IWave* wave = nullptr;
1199 wave = CreateWave(name, is3D, !is3D);
1200 _previewCategory = wave;
1201 if (!wave)
1202 {
1203 LOG_WARN(Audio, "StartCategoryPreview({}): failed to create wave '{}'", slot, static_cast<const char*>(name));
1204 return;
1205 }
1206 wave->SetKind(kind);
1207 wave->EnableAccommodation(false);
1208 wave->SetSticky(true);
1209 float baseVol = (kind == WaveMusic) ? 0.5f : 1.0f; // legacy halves music

Callers 1

Calls 10

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

Tested by

no test coverage detected