early-access version 1693
This commit is contained in:
@@ -169,10 +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},
|
||||
buffer_event{system.Kernel()}, audio_input_device_switch_event{system.Kernel()},
|
||||
audio_output_device_switch_event{system.Kernel()} {
|
||||
explicit IAudioDevice(Core::System& system_, Kernel::KEvent& buffer_event_, u32_le revision_)
|
||||
: ServiceFramework{system_, "IAudioDevice"}, buffer_event{buffer_event_}, revision{
|
||||
revision_} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"},
|
||||
{1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"},
|
||||
@@ -189,18 +188,6 @@ public:
|
||||
{13, nullptr, "GetAudioSystemMasterVolumeSetting"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
Kernel::KAutoObject::Create(std::addressof(buffer_event));
|
||||
buffer_event.Initialize("IAudioOutBufferReleasedEvent");
|
||||
|
||||
// Should be similar to audio_output_device_switch_event
|
||||
Kernel::KAutoObject::Create(std::addressof(audio_input_device_switch_event));
|
||||
audio_input_device_switch_event.Initialize("IAudioDevice:AudioInputDeviceSwitchedEvent");
|
||||
|
||||
// Should only be signalled when an audio output device has been changed, example: speaker
|
||||
// to headset
|
||||
Kernel::KAutoObject::Create(std::addressof(audio_output_device_switch_event));
|
||||
audio_output_device_switch_event.Initialize("IAudioDevice:AudioOutputDeviceSwitchedEvent");
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -310,7 +297,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(audio_input_device_switch_event.GetReadableEvent());
|
||||
rb.PushCopyObjects(buffer_event.GetReadableEvent());
|
||||
}
|
||||
|
||||
void QueryAudioDeviceOutputEvent(Kernel::HLERequestContext& ctx) {
|
||||
@@ -318,17 +305,16 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushCopyObjects(audio_output_device_switch_event.GetReadableEvent());
|
||||
rb.PushCopyObjects(buffer_event.GetReadableEvent());
|
||||
}
|
||||
|
||||
Kernel::KEvent& buffer_event;
|
||||
u32_le revision = 0;
|
||||
Kernel::KEvent buffer_event;
|
||||
Kernel::KEvent audio_input_device_switch_event;
|
||||
Kernel::KEvent audio_output_device_switch_event;
|
||||
};
|
||||
|
||||
}; // namespace Audio
|
||||
AudRenU::AudRenU(Core::System& system_)
|
||||
: ServiceFramework{system_, "audren:u"}, buffer_event{system.Kernel()} {
|
||||
|
||||
AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"},
|
||||
@@ -340,6 +326,9 @@ AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"}
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
Kernel::KAutoObject::Create(std::addressof(buffer_event));
|
||||
buffer_event.Initialize("IAudioOutBufferReleasedEvent");
|
||||
}
|
||||
|
||||
AudRenU::~AudRenU() = default;
|
||||
@@ -663,7 +652,7 @@ void AudRenU::GetAudioDeviceService(Kernel::HLERequestContext& ctx) {
|
||||
// always assumes the initial release revision (REV1).
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IAudioDevice>(system, Common::MakeMagic('R', 'E', 'V', '1'));
|
||||
rb.PushIpcInterface<IAudioDevice>(system, buffer_event, Common::MakeMagic('R', 'E', 'V', '1'));
|
||||
}
|
||||
|
||||
void AudRenU::OpenAudioRendererForManualExecution(Kernel::HLERequestContext& ctx) {
|
||||
@@ -685,7 +674,7 @@ void AudRenU::GetAudioDeviceServiceWithRevisionInfo(Kernel::HLERequestContext& c
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IAudioDevice>(system, revision);
|
||||
rb.PushIpcInterface<IAudioDevice>(system, buffer_event, revision);
|
||||
}
|
||||
|
||||
void AudRenU::OpenAudioRendererImpl(Kernel::HLERequestContext& ctx) {
|
||||
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
@@ -31,6 +32,7 @@ private:
|
||||
void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx);
|
||||
|
||||
std::size_t audren_instance_count = 0;
|
||||
Kernel::KEvent buffer_event;
|
||||
};
|
||||
|
||||
// Describes a particular audio feature that may be supported in a particular revision.
|
||||
|
@@ -107,7 +107,7 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager)
|
||||
ASSERT(!port_installed);
|
||||
|
||||
auto port = service_manager.RegisterService(service_name, max_sessions).Unwrap();
|
||||
port->SetSessionHandler(shared_from_this());
|
||||
port->SetHleHandler(shared_from_this());
|
||||
port_installed = true;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ Kernel::KClientPort& ServiceFrameworkBase::CreatePort(Kernel::KernelCore& kernel
|
||||
|
||||
auto* port = Kernel::KPort::Create(kernel);
|
||||
port->Initialize(max_sessions, false, service_name);
|
||||
port->GetServerPort().SetSessionHandler(shared_from_this());
|
||||
port->GetServerPort().SetHleHandler(shared_from_this());
|
||||
|
||||
port_installed = true;
|
||||
|
||||
|
@@ -4,13 +4,8 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/k_client_port.h"
|
||||
#include "core/hle/kernel/k_client_session.h"
|
||||
#include "core/hle/kernel/k_port.h"
|
||||
#include "core/hle/kernel/k_scoped_resource_reservation.h"
|
||||
#include "core/hle/kernel/k_server_port.h"
|
||||
#include "core/hle/kernel/k_server_session.h"
|
||||
#include "core/hle/kernel/k_session.h"
|
||||
#include "core/hle/service/sm/controller.h"
|
||||
@@ -18,7 +13,7 @@
|
||||
namespace Service::SM {
|
||||
|
||||
void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) {
|
||||
ASSERT_MSG(!ctx.Session()->IsDomain(), "Session is already a domain");
|
||||
ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain");
|
||||
LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetId());
|
||||
ctx.Session()->ConvertToDomain();
|
||||
|
||||
@@ -34,36 +29,16 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
LOG_DEBUG(Service, "called");
|
||||
|
||||
auto& kernel = system.Kernel();
|
||||
auto* session = ctx.Session()->GetParent();
|
||||
auto* port = session->GetParent()->GetParent();
|
||||
auto session = ctx.Session()->GetParent();
|
||||
|
||||
// Reserve a new session from the process resource limit.
|
||||
Kernel::KScopedResourceReservation session_reservation(
|
||||
kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
|
||||
if (!session_reservation.Succeeded()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(Kernel::ResultLimitReached);
|
||||
}
|
||||
// Open a reference to the session to simulate a new one being created.
|
||||
session->Open();
|
||||
session->GetClientSession().Open();
|
||||
session->GetServerSession().Open();
|
||||
|
||||
// Create a new session.
|
||||
auto* clone = Kernel::KSession::Create(kernel);
|
||||
clone->Initialize(&port->GetClientPort(), session->GetName());
|
||||
|
||||
// Commit the session reservation.
|
||||
session_reservation.Commit();
|
||||
|
||||
// Enqueue the session with the named port.
|
||||
port->EnqueueSession(&clone->GetServerSession());
|
||||
|
||||
// Set the session request manager.
|
||||
clone->GetServerSession().SetSessionRequestManager(
|
||||
session->GetServerSession().GetSessionRequestManager());
|
||||
|
||||
// We succeeded.
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushMoveObjects(clone->GetClientSession());
|
||||
rb.PushMoveObjects(session->GetClientSession());
|
||||
}
|
||||
|
||||
void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) {
|
||||
|
@@ -150,31 +150,31 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext&
|
||||
IPC::RequestParser rp{ctx};
|
||||
std::string name(PopServiceName(rp));
|
||||
|
||||
// Find the named port.
|
||||
auto result = service_manager.GetServicePort(name);
|
||||
if (result.Failed()) {
|
||||
LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.Code().raw);
|
||||
return result.Code();
|
||||
}
|
||||
|
||||
auto* port = result.Unwrap();
|
||||
|
||||
// Reserve a new session from the process resource limit.
|
||||
Kernel::KScopedResourceReservation session_reservation(
|
||||
kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
|
||||
R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached);
|
||||
// Kernel::KScopedResourceReservation session_reservation(
|
||||
// kernel.CurrentProcess()->GetResourceLimit(), Kernel::LimitableResource::Sessions);
|
||||
// R_UNLESS(session_reservation.Succeeded(), Kernel::ResultLimitReached);
|
||||
|
||||
// Create a new session.
|
||||
auto* session = Kernel::KSession::Create(kernel);
|
||||
session->Initialize(&port->GetClientPort(), std::move(name));
|
||||
|
||||
// Commit the session reservation.
|
||||
session_reservation.Commit();
|
||||
// session_reservation.Commit();
|
||||
|
||||
// Enqueue the session with the named port.
|
||||
port->EnqueueSession(&session->GetServerSession());
|
||||
if (port->GetServerPort().GetHLEHandler()) {
|
||||
port->GetServerPort().GetHLEHandler()->ClientConnected(&session->GetServerSession());
|
||||
} else {
|
||||
port->EnqueueSession(&session->GetServerSession());
|
||||
}
|
||||
|
||||
LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId());
|
||||
|
||||
return MakeResult(&session->GetClientSession());
|
||||
}
|
||||
|
||||
|
@@ -73,7 +73,7 @@ public:
|
||||
if (port == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::static_pointer_cast<T>(port->GetServerPort().GetSessionRequestHandler());
|
||||
return std::static_pointer_cast<T>(port->GetServerPort().GetHLEHandler());
|
||||
}
|
||||
|
||||
void InvokeControlRequest(Kernel::HLERequestContext& context);
|
||||
|
Reference in New Issue
Block a user