summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/audio
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-04 09:56:09 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:50 +0200
commitaddc0bf0379e075786048921bede6e089552a6db (patch)
tree7fa8819b52db29e1b354410441dd8f2438e2ed4a /src/core/hle/service/audio
parenthle: kernel: Migrate KSharedMemory to KAutoObject. (diff)
downloadyuzu-addc0bf0379e075786048921bede6e089552a6db.tar
yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.gz
yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.bz2
yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.lz
yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.xz
yuzu-addc0bf0379e075786048921bede6e089552a6db.tar.zst
yuzu-addc0bf0379e075786048921bede6e089552a6db.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/audio/audout_u.cpp15
-rw-r--r--src/core/hle/service/audio/audren_u.cpp41
2 files changed, 25 insertions, 31 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp
index 5f51fca9a..4052c8e60 100644
--- a/src/core/hle/service/audio/audout_u.cpp
+++ b/src/core/hle/service/audio/audout_u.cpp
@@ -43,9 +43,9 @@ class IAudioOut final : public ServiceFramework<IAudioOut> {
public:
IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_,
std::string&& device_name_, std::string&& unique_name)
- : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_},
- device_name{std::move(device_name_)}, audio_params{audio_params_}, main_memory{
- system.Memory()} {
+ : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, device_name{std::move(
+ device_name_)},
+ audio_params{audio_params_}, buffer_event{system.Kernel()}, main_memory{system.Memory()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IAudioOut::GetAudioOutState, "GetAudioOutState"},
@@ -67,13 +67,12 @@ public:
RegisterHandlers(functions);
// This is the event handle used to check if the audio buffer was released
- buffer_event = Kernel::KEvent::Create(system.Kernel(), "IAudioOutBufferReleased");
- buffer_event->Initialize();
+ buffer_event.Initialize("IAudioOutBufferReleased");
stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate,
audio_params.channel_count, std::move(unique_name), [this] {
const auto guard = LockService();
- buffer_event->GetWritableEvent()->Signal();
+ buffer_event.GetWritableEvent()->Signal();
});
}
@@ -126,7 +125,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(buffer_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) {
@@ -220,7 +219,7 @@ private:
[[maybe_unused]] AudoutParams audio_params{};
/// This is the event handle used to check if the audio buffer was released
- std::shared_ptr<Kernel::KEvent> buffer_event;
+ Kernel::KEvent buffer_event;
Core::Memory::Memory& main_memory;
};
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp
index 3a48342fd..d573530df 100644
--- a/src/core/hle/service/audio/audren_u.cpp
+++ b/src/core/hle/service/audio/audren_u.cpp
@@ -30,7 +30,7 @@ public:
explicit IAudioRenderer(Core::System& system_,
const AudioCommon::AudioRendererParameter& audren_params,
const std::size_t instance_number)
- : ServiceFramework{system_, "IAudioRenderer"} {
+ : ServiceFramework{system_, "IAudioRenderer"}, system_event{system.Kernel()} {
// clang-format off
static const FunctionInfo functions[] = {
{0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
@@ -49,13 +49,12 @@ public:
// clang-format on
RegisterHandlers(functions);
- system_event = Kernel::KEvent::Create(system.Kernel(), "IAudioRenderer:SystemEvent");
- system_event->Initialize();
+ system_event.Initialize("IAudioRenderer:SystemEvent");
renderer = std::make_unique<AudioCore::AudioRenderer>(
system.CoreTiming(), system.Memory(), audren_params,
[this]() {
const auto guard = LockService();
- system_event->GetWritableEvent()->Signal();
+ system_event.GetWritableEvent()->Signal();
},
instance_number);
}
@@ -128,7 +127,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(system_event->GetReadableEvent());
+ rb.PushCopyObjects(system_event.GetReadableEvent());
}
void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) {
@@ -162,7 +161,7 @@ private:
rb.Push(ERR_NOT_SUPPORTED);
}
- std::shared_ptr<Kernel::KEvent> system_event;
+ Kernel::KEvent system_event;
std::unique_ptr<AudioCore::AudioRenderer> renderer;
u32 rendering_time_limit_percent = 100;
};
@@ -170,7 +169,9 @@ private:
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
public:
explicit IAudioDevice(Core::System& system_, u32_le revision_num)
- : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} {
+ : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num},
+ buffer_event{system.Kernel()}, audio_input_device_switch_event{system.Kernel()},
+ audio_output_device_switch_event{system.Kernel()} {
static const FunctionInfo functions[] = {
{0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"},
{1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"},
@@ -188,20 +189,14 @@ public:
};
RegisterHandlers(functions);
- auto& kernel = system.Kernel();
- buffer_event = Kernel::KEvent::Create(kernel, "IAudioOutBufferReleasedEvent");
- buffer_event->Initialize();
+ buffer_event.Initialize("IAudioOutBufferReleasedEvent");
// Should be similar to audio_output_device_switch_event
- audio_input_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioInputDeviceSwitchedEvent");
- audio_input_device_switch_event->Initialize();
+ audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent");
// Should only be signalled when an audio output device has been changed, example: speaker
// to headset
- audio_output_device_switch_event =
- Kernel::KEvent::Create(kernel, "IAudioDevice:AudioOutputDeviceSwitchedEvent");
- audio_output_device_switch_event->Initialize();
+ audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent");
}
private:
@@ -290,11 +285,11 @@ private:
void QueryAudioDeviceSystemEvent(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_Audio, "(STUBBED) called");
- buffer_event->GetWritableEvent()->Signal();
+ buffer_event.GetWritableEvent()->Signal();
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(buffer_event->GetReadableEvent());
+ rb.PushCopyObjects(buffer_event.GetReadableEvent());
}
void GetActiveChannelCount(Kernel::HLERequestContext& ctx) {
@@ -311,7 +306,7 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_input_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(audio_input_device_switch_event.GetReadableEvent());
}
void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) {
@@ -319,13 +314,13 @@ private:
IPC::ResponseBuilder rb{ctx, 2, 1};
rb.Push(RESULT_SUCCESS);
- rb.PushCopyObjects(audio_output_device_switch_event->GetReadableEvent());
+ rb.PushCopyObjects(audio_output_device_switch_event.GetReadableEvent());
}
u32_le revision = 0;
- std::shared_ptr<Kernel::KEvent> buffer_event;
- std::shared_ptr<Kernel::KEvent> audio_input_device_switch_event;
- std::shared_ptr<Kernel::KEvent> audio_output_device_switch_event;
+ Kernel::KEvent buffer_event;
+ Kernel::KEvent audio_input_device_switch_event;
+ Kernel::KEvent audio_output_device_switch_event;
}; // namespace Audio