2020-07-09 15:48:14 +02:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
|
|
|
|
|
|
|
|
#include <kernel/types/KProcess.h>
|
|
|
|
#include <audio/common.h>
|
|
|
|
#include "IAudioDevice.h"
|
|
|
|
|
|
|
|
namespace skyline::service::audio {
|
2020-09-21 12:04:26 +02:00
|
|
|
IAudioDevice::IAudioDevice(const DeviceState &state, ServiceManager &manager) : systemEvent(std::make_shared<type::KEvent>(state)), BaseService(state, manager) {}
|
2020-07-09 15:48:14 +02:00
|
|
|
|
2020-09-03 20:43:52 +02:00
|
|
|
Result IAudioDevice::ListAudioDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
2020-07-09 15:48:14 +02:00
|
|
|
u64 offset{};
|
|
|
|
for (std::string deviceName : {"AudioTvOutput", "AudioStereoJackOutput", "AudioBuiltInSpeakerOutput"}) {
|
|
|
|
if (offset + deviceName.size() + 1 > request.outputBuf.at(0).size)
|
|
|
|
throw exception("Too small a buffer supplied to ListAudioDeviceName");
|
|
|
|
|
|
|
|
state.process->WriteMemory(deviceName.c_str(), request.outputBuf.at(0).address + offset, deviceName.size() + 1);
|
|
|
|
offset += deviceName.size() + 1;
|
|
|
|
}
|
2020-09-03 20:43:52 +02:00
|
|
|
return {};
|
2020-07-09 15:48:14 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 20:43:52 +02:00
|
|
|
Result IAudioDevice::SetAudioDeviceOutputVolume(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
|
|
|
return {};
|
|
|
|
}
|
2020-07-09 15:48:14 +02:00
|
|
|
|
2020-09-03 20:43:52 +02:00
|
|
|
Result IAudioDevice::GetActiveAudioDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
2020-07-09 15:48:14 +02:00
|
|
|
std::string deviceName("AudioStereoJackOutput");
|
|
|
|
|
|
|
|
if (deviceName.size() > request.outputBuf.at(0).size)
|
|
|
|
throw exception("Too small a buffer supplied to GetActiveAudioDeviceName");
|
|
|
|
|
|
|
|
state.process->WriteMemory(deviceName.c_str(), request.outputBuf.at(0).address, deviceName.size() + 1);
|
2020-09-03 20:43:52 +02:00
|
|
|
return {};
|
2020-07-09 15:48:14 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 20:43:52 +02:00
|
|
|
Result IAudioDevice::QueryAudioDeviceSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
2020-08-21 15:28:47 +02:00
|
|
|
auto handle{state.process->InsertItem(systemEvent)};
|
2020-07-09 15:48:14 +02:00
|
|
|
state.logger->Debug("Audio Device System Event Handle: 0x{:X}", handle);
|
|
|
|
response.copyHandles.push_back(handle);
|
2020-09-03 20:43:52 +02:00
|
|
|
return {};
|
2020-07-09 15:48:14 +02:00
|
|
|
}
|
|
|
|
|
2020-09-03 20:43:52 +02:00
|
|
|
Result IAudioDevice::GetActiveChannelCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
2020-07-09 15:48:14 +02:00
|
|
|
response.Push<u32>(constant::ChannelCount);
|
2020-09-03 20:43:52 +02:00
|
|
|
return {};
|
2020-07-09 15:48:14 +02:00
|
|
|
}
|
|
|
|
}
|