summaryrefslogtreecommitdiff
path: root/src/core/hle/service/audio
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-28 12:30:33 -0400
committerGravatar Lioncash2018-08-28 22:31:51 -0400
commit0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5 (patch)
tree2d7bb143d490c3984bff6deda426b818bf27d552 /src/core/hle/service/audio
parentMerge pull request #1193 from lioncash/priv (diff)
downloadyuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.gz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.xz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.zip
kernel: Eliminate kernel global state
As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
Diffstat (limited to 'src/core/hle/service/audio')
-rw-r--r--src/core/hle/service/audio/audout_u.cpp4
-rw-r--r--src/core/hle/service/audio/audren_u.cpp8
2 files changed, 8 insertions, 4 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index ce709ccf4..5f370bbdf 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -47,7 +47,9 @@ public:
47 RegisterHandlers(functions); 47 RegisterHandlers(functions);
48 48
49 // This is the event handle used to check if the audio buffer was released 49 // This is the event handle used to check if the audio buffer was released
50 buffer_event = Kernel::Event::Create(Kernel::ResetType::Sticky, "IAudioOutBufferReleased"); 50 auto& kernel = Core::System::GetInstance().Kernel();
51 buffer_event =
52 Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "IAudioOutBufferReleased");
51 53
52 stream = audio_core.OpenStream(audio_params.sample_rate, audio_params.channel_count, 54 stream = audio_core.OpenStream(audio_params.sample_rate, audio_params.channel_count,
53 "IAudioOut", [=]() { buffer_event->Signal(); }); 55 "IAudioOut", [=]() { buffer_event->Signal(); });
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 9e75eb3a6..016db7c82 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -35,8 +35,9 @@ public:
35 }; 35 };
36 RegisterHandlers(functions); 36 RegisterHandlers(functions);
37 37
38 auto& kernel = Core::System::GetInstance().Kernel();
38 system_event = 39 system_event =
39 Kernel::Event::Create(Kernel::ResetType::Sticky, "IAudioRenderer:SystemEvent"); 40 Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "IAudioRenderer:SystemEvent");
40 renderer = std::make_unique<AudioCore::AudioRenderer>(audren_params, system_event); 41 renderer = std::make_unique<AudioCore::AudioRenderer>(audren_params, system_event);
41 } 42 }
42 43
@@ -121,8 +122,9 @@ public:
121 }; 122 };
122 RegisterHandlers(functions); 123 RegisterHandlers(functions);
123 124
124 buffer_event = 125 auto& kernel = Core::System::GetInstance().Kernel();
125 Kernel::Event::Create(Kernel::ResetType::OneShot, "IAudioOutBufferReleasedEvent"); 126 buffer_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot,
127 "IAudioOutBufferReleasedEvent");
126 } 128 }
127 129
128private: 130private: