diff options
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 7723d9782..0ede0d85c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <utility> | 9 | #include <utility> |
| 10 | 10 | ||
| 11 | #include "audio_core/audio_core.h" | ||
| 11 | #include "common/fs/fs.h" | 12 | #include "common/fs/fs.h" |
| 12 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 13 | #include "common/microprofile.h" | 14 | #include "common/microprofile.h" |
| @@ -140,6 +141,8 @@ struct System::Impl { | |||
| 140 | core_timing.SyncPause(false); | 141 | core_timing.SyncPause(false); |
| 141 | is_paused = false; | 142 | is_paused = false; |
| 142 | 143 | ||
| 144 | audio_core->PauseSinks(false); | ||
| 145 | |||
| 143 | return status; | 146 | return status; |
| 144 | } | 147 | } |
| 145 | 148 | ||
| @@ -147,6 +150,8 @@ struct System::Impl { | |||
| 147 | std::unique_lock<std::mutex> lk(suspend_guard); | 150 | std::unique_lock<std::mutex> lk(suspend_guard); |
| 148 | status = SystemResultStatus::Success; | 151 | status = SystemResultStatus::Success; |
| 149 | 152 | ||
| 153 | audio_core->PauseSinks(true); | ||
| 154 | |||
| 150 | core_timing.SyncPause(true); | 155 | core_timing.SyncPause(true); |
| 151 | kernel.Suspend(true); | 156 | kernel.Suspend(true); |
| 152 | is_paused = true; | 157 | is_paused = true; |
| @@ -154,6 +159,11 @@ struct System::Impl { | |||
| 154 | return status; | 159 | return status; |
| 155 | } | 160 | } |
| 156 | 161 | ||
| 162 | bool IsPaused() const { | ||
| 163 | std::unique_lock lk(suspend_guard); | ||
| 164 | return is_paused; | ||
| 165 | } | ||
| 166 | |||
| 157 | std::unique_lock<std::mutex> StallProcesses() { | 167 | std::unique_lock<std::mutex> StallProcesses() { |
| 158 | std::unique_lock<std::mutex> lk(suspend_guard); | 168 | std::unique_lock<std::mutex> lk(suspend_guard); |
| 159 | kernel.Suspend(true); | 169 | kernel.Suspend(true); |
| @@ -214,6 +224,8 @@ struct System::Impl { | |||
| 214 | return SystemResultStatus::ErrorVideoCore; | 224 | return SystemResultStatus::ErrorVideoCore; |
| 215 | } | 225 | } |
| 216 | 226 | ||
| 227 | audio_core = std::make_unique<AudioCore::AudioCore>(system); | ||
| 228 | |||
| 217 | service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); | 229 | service_manager = std::make_shared<Service::SM::ServiceManager>(kernel); |
| 218 | services = std::make_unique<Service::Services>(service_manager, system); | 230 | services = std::make_unique<Service::Services>(service_manager, system); |
| 219 | interrupt_manager = std::make_unique<Hardware::InterruptManager>(system); | 231 | interrupt_manager = std::make_unique<Hardware::InterruptManager>(system); |
| @@ -290,7 +302,7 @@ struct System::Impl { | |||
| 290 | if (Settings::values.gamecard_current_game) { | 302 | if (Settings::values.gamecard_current_game) { |
| 291 | fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath)); | 303 | fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, filepath)); |
| 292 | } else if (!Settings::values.gamecard_path.GetValue().empty()) { | 304 | } else if (!Settings::values.gamecard_path.GetValue().empty()) { |
| 293 | const auto gamecard_path = Settings::values.gamecard_path.GetValue(); | 305 | const auto& gamecard_path = Settings::values.gamecard_path.GetValue(); |
| 294 | fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, gamecard_path)); | 306 | fs_controller.SetGameCard(GetGameFileFromPath(virtual_filesystem, gamecard_path)); |
| 295 | } | 307 | } |
| 296 | } | 308 | } |
| @@ -308,6 +320,8 @@ struct System::Impl { | |||
| 308 | } | 320 | } |
| 309 | 321 | ||
| 310 | void Shutdown() { | 322 | void Shutdown() { |
| 323 | SetShuttingDown(true); | ||
| 324 | |||
| 311 | // Log last frame performance stats if game was loded | 325 | // Log last frame performance stats if game was loded |
| 312 | if (perf_stats) { | 326 | if (perf_stats) { |
| 313 | const auto perf_results = GetAndResetPerfStats(); | 327 | const auto perf_results = GetAndResetPerfStats(); |
| @@ -333,14 +347,15 @@ struct System::Impl { | |||
| 333 | kernel.ShutdownCores(); | 347 | kernel.ShutdownCores(); |
| 334 | cpu_manager.Shutdown(); | 348 | cpu_manager.Shutdown(); |
| 335 | debugger.reset(); | 349 | debugger.reset(); |
| 350 | kernel.CloseServices(); | ||
| 336 | services.reset(); | 351 | services.reset(); |
| 337 | service_manager.reset(); | 352 | service_manager.reset(); |
| 338 | cheat_engine.reset(); | 353 | cheat_engine.reset(); |
| 339 | telemetry_session.reset(); | 354 | telemetry_session.reset(); |
| 340 | cpu_manager.Shutdown(); | ||
| 341 | time_manager.Shutdown(); | 355 | time_manager.Shutdown(); |
| 342 | core_timing.Shutdown(); | 356 | core_timing.Shutdown(); |
| 343 | app_loader.reset(); | 357 | app_loader.reset(); |
| 358 | audio_core.reset(); | ||
| 344 | gpu_core.reset(); | 359 | gpu_core.reset(); |
| 345 | perf_stats.reset(); | 360 | perf_stats.reset(); |
| 346 | kernel.Shutdown(); | 361 | kernel.Shutdown(); |
| @@ -350,6 +365,14 @@ struct System::Impl { | |||
| 350 | LOG_DEBUG(Core, "Shutdown OK"); | 365 | LOG_DEBUG(Core, "Shutdown OK"); |
| 351 | } | 366 | } |
| 352 | 367 | ||
| 368 | bool IsShuttingDown() const { | ||
| 369 | return is_shutting_down; | ||
| 370 | } | ||
| 371 | |||
| 372 | void SetShuttingDown(bool shutting_down) { | ||
| 373 | is_shutting_down = shutting_down; | ||
| 374 | } | ||
| 375 | |||
| 353 | Loader::ResultStatus GetGameName(std::string& out) const { | 376 | Loader::ResultStatus GetGameName(std::string& out) const { |
| 354 | if (app_loader == nullptr) | 377 | if (app_loader == nullptr) |
| 355 | return Loader::ResultStatus::ErrorNotInitialized; | 378 | return Loader::ResultStatus::ErrorNotInitialized; |
| @@ -392,8 +415,9 @@ struct System::Impl { | |||
| 392 | return perf_stats->GetAndResetStats(core_timing.GetGlobalTimeUs()); | 415 | return perf_stats->GetAndResetStats(core_timing.GetGlobalTimeUs()); |
| 393 | } | 416 | } |
| 394 | 417 | ||
| 395 | std::mutex suspend_guard; | 418 | mutable std::mutex suspend_guard; |
| 396 | bool is_paused{}; | 419 | bool is_paused{}; |
| 420 | std::atomic<bool> is_shutting_down{}; | ||
| 397 | 421 | ||
| 398 | Timing::CoreTiming core_timing; | 422 | Timing::CoreTiming core_timing; |
| 399 | Kernel::KernelCore kernel; | 423 | Kernel::KernelCore kernel; |
| @@ -407,6 +431,7 @@ struct System::Impl { | |||
| 407 | std::unique_ptr<Tegra::GPU> gpu_core; | 431 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 408 | std::unique_ptr<Hardware::InterruptManager> interrupt_manager; | 432 | std::unique_ptr<Hardware::InterruptManager> interrupt_manager; |
| 409 | std::unique_ptr<Core::DeviceMemory> device_memory; | 433 | std::unique_ptr<Core::DeviceMemory> device_memory; |
| 434 | std::unique_ptr<AudioCore::AudioCore> audio_core; | ||
| 410 | Core::Memory::Memory memory; | 435 | Core::Memory::Memory memory; |
| 411 | Core::HID::HIDCore hid_core; | 436 | Core::HID::HIDCore hid_core; |
| 412 | CpuManager cpu_manager; | 437 | CpuManager cpu_manager; |
| @@ -479,6 +504,10 @@ SystemResultStatus System::Pause() { | |||
| 479 | return impl->Pause(); | 504 | return impl->Pause(); |
| 480 | } | 505 | } |
| 481 | 506 | ||
| 507 | bool System::IsPaused() const { | ||
| 508 | return impl->IsPaused(); | ||
| 509 | } | ||
| 510 | |||
| 482 | void System::InvalidateCpuInstructionCaches() { | 511 | void System::InvalidateCpuInstructionCaches() { |
| 483 | impl->kernel.InvalidateAllInstructionCaches(); | 512 | impl->kernel.InvalidateAllInstructionCaches(); |
| 484 | } | 513 | } |
| @@ -491,6 +520,14 @@ void System::Shutdown() { | |||
| 491 | impl->Shutdown(); | 520 | impl->Shutdown(); |
| 492 | } | 521 | } |
| 493 | 522 | ||
| 523 | bool System::IsShuttingDown() const { | ||
| 524 | return impl->IsShuttingDown(); | ||
| 525 | } | ||
| 526 | |||
| 527 | void System::SetShuttingDown(bool shutting_down) { | ||
| 528 | impl->SetShuttingDown(shutting_down); | ||
| 529 | } | ||
| 530 | |||
| 494 | void System::DetachDebugger() { | 531 | void System::DetachDebugger() { |
| 495 | if (impl->debugger) { | 532 | if (impl->debugger) { |
| 496 | impl->debugger->NotifyShutdown(); | 533 | impl->debugger->NotifyShutdown(); |
| @@ -640,6 +677,14 @@ const HID::HIDCore& System::HIDCore() const { | |||
| 640 | return impl->hid_core; | 677 | return impl->hid_core; |
| 641 | } | 678 | } |
| 642 | 679 | ||
| 680 | AudioCore::AudioCore& System::AudioCore() { | ||
| 681 | return *impl->audio_core; | ||
| 682 | } | ||
| 683 | |||
| 684 | const AudioCore::AudioCore& System::AudioCore() const { | ||
| 685 | return *impl->audio_core; | ||
| 686 | } | ||
| 687 | |||
| 643 | Timing::CoreTiming& System::CoreTiming() { | 688 | Timing::CoreTiming& System::CoreTiming() { |
| 644 | return impl->core_timing; | 689 | return impl->core_timing; |
| 645 | } | 690 | } |