mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-02-23 05:07:16 +01:00
move audio playback code to a more reasonable place
This commit is contained in:
parent
cab8a1f3c5
commit
5033318daa
@ -179,7 +179,3 @@ void Latte_Start();
|
|||||||
void Latte_Stop();
|
void Latte_Stop();
|
||||||
bool Latte_GetStopSignal(); // returns true if stop was requested or if in stopped state
|
bool Latte_GetStopSignal(); // returns true if stop was requested or if in stopped state
|
||||||
void LatteThread_Exit();
|
void LatteThread_Exit();
|
||||||
|
|
||||||
void LatteThread_InitBootSound();
|
|
||||||
void LatteThread_StreamBootSound();
|
|
||||||
void LatteThread_ShutdownBootSound();
|
|
||||||
|
@ -127,3 +127,7 @@ void LatteShaderCache_writeSeparablePixelShader(uint64 shaderBaseHash, uint64 sh
|
|||||||
|
|
||||||
// todo - refactor this
|
// todo - refactor this
|
||||||
sint32 LatteDecompiler_getTextureSamplerBaseIndex(LatteConst::ShaderType shaderType);
|
sint32 LatteDecompiler_getTextureSamplerBaseIndex(LatteConst::ShaderType shaderType);
|
||||||
|
|
||||||
|
void LatteShaderCache_InitBootSound();
|
||||||
|
void LatteShaderCache_StreamBootSound();
|
||||||
|
void LatteShaderCache_ShutdownBootSound();
|
@ -301,6 +301,10 @@ void LatteShaderCache_Load()
|
|||||||
loadBackgroundTexture(true, g_shaderCacheLoaderState.textureTVId);
|
loadBackgroundTexture(true, g_shaderCacheLoaderState.textureTVId);
|
||||||
loadBackgroundTexture(false, g_shaderCacheLoaderState.textureDRCId);
|
loadBackgroundTexture(false, g_shaderCacheLoaderState.textureDRCId);
|
||||||
|
|
||||||
|
// initialise resources for playing bootup sound
|
||||||
|
if(GetConfig().play_boot_sound)
|
||||||
|
LatteShaderCache_InitBootSound();
|
||||||
|
|
||||||
sint32 numLoadedShaders = 0;
|
sint32 numLoadedShaders = 0;
|
||||||
uint32 loadIndex = 0;
|
uint32 loadIndex = 0;
|
||||||
|
|
||||||
@ -367,6 +371,9 @@ void LatteShaderCache_Load()
|
|||||||
g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureTVId);
|
g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureTVId);
|
||||||
if (g_shaderCacheLoaderState.textureDRCId)
|
if (g_shaderCacheLoaderState.textureDRCId)
|
||||||
g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureDRCId);
|
g_renderer->DeleteTexture(g_shaderCacheLoaderState.textureDRCId);
|
||||||
|
|
||||||
|
// free resources for playing boot sound
|
||||||
|
LatteShaderCache_ShutdownBootSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateFunc, bool isPipelines)
|
void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateFunc, bool isPipelines)
|
||||||
@ -497,7 +504,7 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
|
|||||||
|
|
||||||
// finish frame
|
// finish frame
|
||||||
g_renderer->SwapBuffers(true, true);
|
g_renderer->SwapBuffers(true, true);
|
||||||
LatteThread_StreamBootSound();
|
LatteShaderCache_StreamBootSound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,3 +816,48 @@ void LatteShaderCache_handleDeprecatedCacheFiles(fs::path pathGeneric, fs::path
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioAPIPtr g_BootSndAudioDev = nullptr;
|
||||||
|
std::unique_ptr<BootSoundReader> g_BootSndFileReader;
|
||||||
|
FSCVirtualFile* g_bootSndFileHandle = 0;
|
||||||
|
|
||||||
|
void LatteShaderCache_InitBootSound()
|
||||||
|
{
|
||||||
|
const sint32 samplesPerBlock = 4800;
|
||||||
|
const sint32 audioBlockSize = samplesPerBlock * 2 * 2;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
g_BootSndAudioDev = IAudioAPI::CreateDeviceFromConfig(true, 48000, 2, samplesPerBlock, 16);
|
||||||
|
}
|
||||||
|
catch (const std::runtime_error& ex)
|
||||||
|
{
|
||||||
|
cemuLog_log(LogType::Force, "Failed to initialise audio device for bootup sound");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_BootSndAudioDev->Play();
|
||||||
|
|
||||||
|
std::string sndPath = fmt::format("{}/meta/{}", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()), "bootSound.btsnd");
|
||||||
|
sint32 fscStatus = FSC_STATUS_UNDEFINED;
|
||||||
|
g_bootSndFileHandle = fsc_open(sndPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus);
|
||||||
|
if(!g_bootSndFileHandle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_BootSndFileReader = std::make_unique<BootSoundReader>(g_bootSndFileHandle, audioBlockSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatteShaderCache_StreamBootSound()
|
||||||
|
{
|
||||||
|
if(g_BootSndAudioDev && g_bootSndFileHandle && g_BootSndFileReader)
|
||||||
|
{
|
||||||
|
if (g_BootSndAudioDev->NeedAdditionalBlocks())
|
||||||
|
g_BootSndAudioDev->FeedBlock(g_BootSndFileReader->getSamples());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LatteShaderCache_ShutdownBootSound()
|
||||||
|
{
|
||||||
|
g_BootSndFileReader.reset();
|
||||||
|
if(g_bootSndFileHandle)
|
||||||
|
fsc_close(g_bootSndFileHandle);
|
||||||
|
g_BootSndAudioDev.reset();
|
||||||
|
}
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
#include "util/helpers/helpers.h"
|
#include "util/helpers/helpers.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <audio/IAudioAPI.h>
|
|
||||||
#include <Filesystem/fsc.h>
|
|
||||||
#include <util/bootSound/BootSoundReader.h>
|
|
||||||
#include "config/ActiveSettings.h"
|
#include "config/ActiveSettings.h"
|
||||||
|
|
||||||
#include "Cafe/CafeSystem.h"
|
#include "Cafe/CafeSystem.h"
|
||||||
@ -184,17 +181,8 @@ int Latte_ThreadEntry()
|
|||||||
|
|
||||||
// before doing anything with game specific shaders, we need to wait for graphic packs to finish loading
|
// before doing anything with game specific shaders, we need to wait for graphic packs to finish loading
|
||||||
GraphicPack2::WaitUntilReady();
|
GraphicPack2::WaitUntilReady();
|
||||||
|
|
||||||
// initialise resources for playing bootup sound
|
|
||||||
if(GetConfig().play_boot_sound)
|
|
||||||
LatteThread_InitBootSound();
|
|
||||||
|
|
||||||
// load disk shader cache
|
// load disk shader cache
|
||||||
LatteShaderCache_Load();
|
LatteShaderCache_Load();
|
||||||
|
|
||||||
// free resources for playing boot sound
|
|
||||||
LatteThread_ShutdownBootSound();
|
|
||||||
|
|
||||||
// init registers
|
// init registers
|
||||||
Latte_LoadInitialRegisters();
|
Latte_LoadInitialRegisters();
|
||||||
// let CPU thread know the GPU is done initializing
|
// let CPU thread know the GPU is done initializing
|
||||||
@ -274,48 +262,3 @@ void LatteThread_Exit()
|
|||||||
#endif
|
#endif
|
||||||
cemu_assert_unimplemented();
|
cemu_assert_unimplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioAPIPtr g_BootSndAudioDev = nullptr;
|
|
||||||
std::unique_ptr<BootSoundReader> g_BootSndFileReader;
|
|
||||||
FSCVirtualFile* g_bootSndFileHandle = 0;
|
|
||||||
|
|
||||||
void LatteThread_InitBootSound()
|
|
||||||
{
|
|
||||||
const sint32 samplesPerBlock = 4800;
|
|
||||||
const sint32 audioBlockSize = samplesPerBlock * 2 * 2;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
g_BootSndAudioDev = IAudioAPI::CreateDeviceFromConfig(true, 48000, 2, samplesPerBlock, 16);
|
|
||||||
}
|
|
||||||
catch (const std::runtime_error& ex)
|
|
||||||
{
|
|
||||||
cemuLog_log(LogType::Force, "Failed to initialise audio device for bootup sound");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_BootSndAudioDev->Play();
|
|
||||||
|
|
||||||
std::string sndPath = fmt::format("{}/meta/{}", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()), "bootSound.btsnd");
|
|
||||||
sint32 fscStatus = FSC_STATUS_UNDEFINED;
|
|
||||||
g_bootSndFileHandle = fsc_open(sndPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus);
|
|
||||||
if(!g_bootSndFileHandle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_BootSndFileReader = std::make_unique<BootSoundReader>(g_bootSndFileHandle, audioBlockSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LatteThread_StreamBootSound()
|
|
||||||
{
|
|
||||||
if(g_BootSndAudioDev && g_bootSndFileHandle && g_BootSndFileReader)
|
|
||||||
{
|
|
||||||
if (g_BootSndAudioDev->NeedAdditionalBlocks())
|
|
||||||
g_BootSndAudioDev->FeedBlock(g_BootSndFileReader->getSamples());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LatteThread_ShutdownBootSound()
|
|
||||||
{
|
|
||||||
g_BootSndFileReader.reset();
|
|
||||||
if(g_bootSndFileHandle)
|
|
||||||
fsc_close(g_bootSndFileHandle);
|
|
||||||
g_BootSndAudioDev.reset();
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user