@@ -167,13 +167,14 @@ class BootSoundPlayer
167
167
BootSoundPlayer () = default ;
168
168
~BootSoundPlayer ()
169
169
{
170
- StopSound () ;
170
+ m_stopRequested = true ;
171
171
}
172
172
173
173
void StartSound ()
174
174
{
175
175
if (!m_bootSndPlayThread.joinable ())
176
176
{
177
+ m_fadeOutRequested = false ;
177
178
m_stopRequested = false ;
178
179
m_volumeFactor = 1 .0f ;
179
180
m_bootSndPlayThread = std::thread{[this ]() {
@@ -182,9 +183,9 @@ class BootSoundPlayer
182
183
}
183
184
}
184
185
185
- void StopSound ()
186
+ void FadeOutSound ()
186
187
{
187
- m_stopRequested = true ;
188
+ m_fadeOutRequested = true ;
188
189
}
189
190
190
191
void ApplyFadeOutEffect (std::span<sint16> samples, float fadeStep)
@@ -239,19 +240,18 @@ class BootSoundPlayer
239
240
constexpr sint32 audioBlockSize = samplesPerBlock * (bitsPerSample/8 ) * nChannels;
240
241
BootSoundReader bootSndFileReader (bootSndFileHandle, audioBlockSize);
241
242
242
- while (m_volumeFactor > 0 )
243
+ while (m_volumeFactor > 0 && !m_stopRequested )
243
244
{
244
245
while (bootSndAudioDev->NeedAdditionalBlocks ())
245
246
{
246
247
sint16* data = bootSndFileReader.getSamples ();
247
248
if (data == nullptr )
248
249
{
249
250
// break outer loop
250
- m_volumeFactor = 0 .0f ;
251
251
m_stopRequested = true ;
252
252
break ;
253
253
}
254
- if (m_stopRequested )
254
+ if (m_fadeOutRequested )
255
255
ApplyFadeOutEffect ({data, samplesPerBlock * 2 }, 1 .0f / (sampleRate * 10 .0f ));
256
256
257
257
bootSndAudioDev->FeedBlock (data);
@@ -266,6 +266,7 @@ class BootSoundPlayer
266
266
267
267
private:
268
268
std::thread m_bootSndPlayThread;
269
+ std::atomic_bool m_fadeOutRequested = false ;
269
270
std::atomic_bool m_stopRequested = false ;
270
271
float m_volumeFactor = 1 .0f ;
271
272
};
@@ -485,7 +486,7 @@ void LatteShaderCache_Load()
485
486
if (g_shaderCacheLoaderState.textureDRCId )
486
487
g_renderer->DeleteTexture (g_shaderCacheLoaderState.textureDRCId );
487
488
488
- g_bootSndPlayer.StopSound ();
489
+ g_bootSndPlayer.FadeOutSound ();
489
490
}
490
491
491
492
void LatteShaderCache_ShowProgress (const std::function <bool (void )>& loadUpdateFunc, bool isPipelines)
0 commit comments