mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-08 07:51:19 +12:00
substitute jthread for thread
This commit is contained in:
parent
adc988eb1b
commit
4468e7a7f2
1 changed files with 9 additions and 4 deletions
|
@ -821,8 +821,9 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr sint32 samplesPerBlock = 4800;
|
constexpr sint32 samplesPerBlock = 4800;
|
||||||
|
static std::atomic<bool> audiothread_keeprunning = true;
|
||||||
|
|
||||||
void LatteShaderCache_StreamBootSound(const std::stop_token& token)
|
void LatteShaderCache_StreamBootSound()
|
||||||
{
|
{
|
||||||
AudioAPIPtr bootSndAudioDev;
|
AudioAPIPtr bootSndAudioDev;
|
||||||
std::unique_ptr<BootSoundReader> bootSndFileReader;
|
std::unique_ptr<BootSoundReader> bootSndFileReader;
|
||||||
|
@ -850,7 +851,7 @@ void LatteShaderCache_StreamBootSound(const std::stop_token& token)
|
||||||
|
|
||||||
if(bootSndAudioDev && bootSndFileHandle && bootSndFileReader)
|
if(bootSndAudioDev && bootSndFileHandle && bootSndFileReader)
|
||||||
{
|
{
|
||||||
while(!token.stop_requested())
|
while(audiothread_keeprunning)
|
||||||
{
|
{
|
||||||
if (bootSndAudioDev->NeedAdditionalBlocks())
|
if (bootSndAudioDev->NeedAdditionalBlocks())
|
||||||
bootSndAudioDev->FeedBlock(bootSndFileReader->getSamples());
|
bootSndAudioDev->FeedBlock(bootSndFileReader->getSamples());
|
||||||
|
@ -863,14 +864,18 @@ void LatteShaderCache_StreamBootSound(const std::stop_token& token)
|
||||||
fsc_close(bootSndFileHandle);
|
fsc_close(bootSndFileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::jthread g_bootSndPlayThread;
|
static std::thread g_bootSndPlayThread;
|
||||||
void LatteShaderCache_InitBootSound()
|
void LatteShaderCache_InitBootSound()
|
||||||
{
|
{
|
||||||
|
audiothread_keeprunning = true;
|
||||||
if(!g_bootSndPlayThread.joinable())
|
if(!g_bootSndPlayThread.joinable())
|
||||||
g_bootSndPlayThread = std::jthread{LatteShaderCache_StreamBootSound};
|
g_bootSndPlayThread = std::thread{LatteShaderCache_StreamBootSound};
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatteShaderCache_ShutdownBootSound()
|
void LatteShaderCache_ShutdownBootSound()
|
||||||
{
|
{
|
||||||
|
audiothread_keeprunning = false;
|
||||||
|
if(g_bootSndPlayThread.joinable())
|
||||||
|
g_bootSndPlayThread.join();
|
||||||
g_bootSndPlayThread = {};
|
g_bootSndPlayThread = {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue