mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-02-22 04:37:15 +01:00
fix bugs and clean up
This commit is contained in:
parent
a7a116a6f1
commit
9354db6a16
@ -178,4 +178,8 @@ void LatteRenderTarget_updateViewport();
|
||||
void Latte_Start();
|
||||
void Latte_Stop();
|
||||
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();
|
||||
|
@ -376,25 +376,6 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
|
||||
|
||||
auto lastFrameUpdate = tick_cached();
|
||||
|
||||
AudioAPIPtr audioDev;
|
||||
const sint32 samplesPerBlock = 4800;
|
||||
const sint32 audioBlockSize = samplesPerBlock * 2 * 2;
|
||||
try
|
||||
{
|
||||
audioDev = 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");
|
||||
}
|
||||
audioDev->Play();
|
||||
|
||||
std::string sndPath = fmt::format("{}/meta/{}", CafeSystem::GetMlcStoragePath(CafeSystem::GetForegroundTitleId()), "bootSound.btsnd");
|
||||
sint32 fscStatus = FSC_STATUS_UNDEFINED;
|
||||
static auto bootsndFile = fsc_open(sndPath.c_str(), FSC_ACCESS_FLAG::OPEN_FILE | FSC_ACCESS_FLAG::READ_PERMISSION, &fscStatus);
|
||||
|
||||
static BootSoundReader reader{bootsndFile, audioBlockSize};
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (Latte_GetStopSignal())
|
||||
@ -516,15 +497,8 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
|
||||
|
||||
// finish frame
|
||||
g_renderer->SwapBuffers(true, true);
|
||||
|
||||
if(audioDev && bootsndFile)
|
||||
{
|
||||
if (audioDev->NeedAdditionalBlocks())
|
||||
audioDev->FeedBlock(reader.getSamples());
|
||||
}
|
||||
|
||||
LatteThread_StreamBootSound();
|
||||
}
|
||||
audioDev->Stop();
|
||||
}
|
||||
|
||||
void LatteShaderCache_LoadVulkanPipelineCache(uint64 cacheTitleId)
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include "util/helpers/helpers.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <audio/IAudioAPI.h>
|
||||
#include <Filesystem/fsc.h>
|
||||
#include <util/bootSound/BootSoundReader.h>
|
||||
#include "config/ActiveSettings.h"
|
||||
|
||||
#include "Cafe/CafeSystem.h"
|
||||
@ -181,6 +184,8 @@ int Latte_ThreadEntry()
|
||||
|
||||
// before doing anything with game specific shaders, we need to wait for graphic packs to finish loading
|
||||
GraphicPack2::WaitUntilReady();
|
||||
|
||||
LatteThread_InitBootSound();
|
||||
// load disk shader cache
|
||||
LatteShaderCache_Load();
|
||||
// init registers
|
||||
@ -193,9 +198,11 @@ int Latte_ThreadEntry()
|
||||
std::this_thread::yield();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
LatteThread_HandleOSScreen();
|
||||
LatteThread_StreamBootSound();
|
||||
if (Latte_GetStopSignal())
|
||||
LatteThread_Exit();
|
||||
}
|
||||
LatteThread_ShutdownBootSound();
|
||||
gxRingBufferReadPtr = gx2WriteGatherPipe.gxRingBuffer;
|
||||
LatteCP_ProcessRingbuffer();
|
||||
cemu_assert_debug(false); // should never reach
|
||||
@ -262,3 +269,49 @@ void LatteThread_Exit()
|
||||
#endif
|
||||
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");
|
||||
}
|
||||
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);
|
||||
|
||||
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);
|
||||
if(g_BootSndAudioDev)
|
||||
{
|
||||
g_BootSndAudioDev->Stop();
|
||||
g_BootSndAudioDev.reset();
|
||||
}
|
||||
}
|
@ -418,7 +418,8 @@ namespace snd_core
|
||||
try
|
||||
{
|
||||
g_padAudio = IAudioAPI::CreateDeviceFromConfig(false, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16);
|
||||
g_padVolume = g_padAudio->GetVolume();
|
||||
if(g_padAudio)
|
||||
g_padVolume = g_padAudio->GetVolume();
|
||||
}
|
||||
catch (std::runtime_error& ex)
|
||||
{
|
||||
|
@ -113,6 +113,9 @@ AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(bool TV, sint32 rate, sint32 chann
|
||||
const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api;
|
||||
auto& selectedDevice = TV ? config.tv_device : config.pad_device;
|
||||
|
||||
if(selectedDevice.empty())
|
||||
return {};
|
||||
|
||||
IAudioAPI::DeviceDescriptionPtr device_description;
|
||||
if (IAudioAPI::IsAudioAPIAvailable(audio_api))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user