2018-01-15 03:29:11 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
#include <vector>
|
2018-01-15 03:29:11 +01:00
|
|
|
#include "common/logging/log.h"
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
#include "core/core_timing.h"
|
2018-01-15 03:29:11 +01:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
#include "core/hle/kernel/event.h"
|
2018-01-22 04:03:36 +01:00
|
|
|
#include "core/hle/kernel/hle_ipc.h"
|
2018-01-15 03:29:11 +01:00
|
|
|
#include "core/hle/service/audio/audout_u.h"
|
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
namespace Service::Audio {
|
2018-01-15 03:29:11 +01:00
|
|
|
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
/// Switch sample rate frequency
|
|
|
|
constexpr u32 sample_rate{48000};
|
|
|
|
/// TODO(st4rk): dynamic number of channels, as I think Switch has support
|
|
|
|
/// to more audio channels (probably when Docked I guess)
|
|
|
|
constexpr u32 audio_channels{2};
|
|
|
|
/// TODO(st4rk): find a proper value for the audio_ticks
|
2018-04-30 09:24:27 +02:00
|
|
|
constexpr u64 audio_ticks{static_cast<u64>(CoreTiming::BASE_CLOCK_RATE / 500)};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-22 04:03:36 +01:00
|
|
|
class IAudioOut final : public ServiceFramework<IAudioOut> {
|
|
|
|
public:
|
2018-01-25 04:38:19 +01:00
|
|
|
IAudioOut() : ServiceFramework("IAudioOut"), audio_out_state(AudioState::Stopped) {
|
2018-01-22 04:03:36 +01:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 17:51:50 +02:00
|
|
|
{0, &IAudioOut::GetAudioOutState, "GetAudioOutState"},
|
|
|
|
{1, &IAudioOut::StartAudioOut, "StartAudioOut"},
|
|
|
|
{2, &IAudioOut::StopAudioOut, "StopAudioOut"},
|
|
|
|
{3, &IAudioOut::AppendAudioOutBuffer, "AppendAudioOutBuffer"},
|
|
|
|
{4, &IAudioOut::RegisterBufferEvent, "RegisterBufferEvent"},
|
|
|
|
{5, &IAudioOut::GetReleasedAudioOutBuffer, "GetReleasedAudioOutBuffer"},
|
|
|
|
{6, nullptr, "ContainsAudioOutBuffer"},
|
|
|
|
{7, nullptr, "AppendAudioOutBufferAuto"},
|
|
|
|
{8, nullptr, "GetReleasedAudioOutBufferAuto"},
|
|
|
|
{9, nullptr, "GetAudioOutBufferCount"},
|
|
|
|
{10, nullptr, "GetAudioOutPlayedSampleCount"},
|
|
|
|
{11, nullptr, "FlushAudioOutBuffers"},
|
2018-01-22 04:03:36 +01:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
|
|
|
// This is the event handle used to check if the audio buffer was released
|
|
|
|
buffer_event =
|
|
|
|
Kernel::Event::Create(Kernel::ResetType::OneShot, "IAudioOutBufferReleasedEvent");
|
|
|
|
|
|
|
|
// Register event callback to update the Audio Buffer
|
|
|
|
audio_event = CoreTiming::RegisterEvent(
|
|
|
|
"IAudioOut::UpdateAudioBuffersCallback", [this](u64 userdata, int cycles_late) {
|
|
|
|
UpdateAudioBuffersCallback();
|
|
|
|
CoreTiming::ScheduleEvent(audio_ticks - cycles_late, audio_event);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Start the audio event
|
|
|
|
CoreTiming::ScheduleEvent(audio_ticks, audio_event);
|
2018-01-22 04:03:36 +01:00
|
|
|
}
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-03-04 16:34:25 +01:00
|
|
|
~IAudioOut() {
|
|
|
|
CoreTiming::UnscheduleEvent(audio_event, 0);
|
|
|
|
}
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
|
|
|
private:
|
2018-04-03 05:31:29 +02:00
|
|
|
void GetAudioOutState(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_DEBUG(Service_Audio, "called");
|
2018-04-03 05:31:29 +02:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u32>(audio_out_state));
|
|
|
|
}
|
|
|
|
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
void StartAudioOut(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
// Start audio
|
|
|
|
audio_out_state = AudioState::Started;
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopAudioOut(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
// Stop audio
|
|
|
|
audio_out_state = AudioState::Stopped;
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
|
|
|
queue_keys.clear();
|
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegisterBufferEvent(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(buffer_event);
|
|
|
|
}
|
|
|
|
|
2018-04-10 17:51:50 +02:00
|
|
|
void AppendAudioOutBuffer(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
const u64 key{rp.Pop<u64>()};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
queue_keys.insert(queue_keys.begin(), key);
|
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-04-10 17:51:50 +02:00
|
|
|
void GetReleasedAudioOutBuffer(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
// TODO(st4rk): This is how libtransistor currently implements the
|
|
|
|
// GetReleasedAudioOutBuffer, it should return the key (a VAddr) to the app and this address
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
// is used to know which buffer should be filled with data and send again to the service
|
|
|
|
// through AppendAudioOutBuffer. Check if this is the proper way to do it.
|
|
|
|
u64 key{0};
|
|
|
|
|
|
|
|
if (queue_keys.size()) {
|
|
|
|
key = queue_keys.back();
|
|
|
|
queue_keys.pop_back();
|
|
|
|
}
|
|
|
|
|
2018-02-14 04:48:31 +01:00
|
|
|
ctx.WriteBuffer(&key, sizeof(u64));
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
// TODO(st4rk): This might be the total of released buffers, needs to be verified on
|
|
|
|
// hardware
|
|
|
|
rb.Push<u32>(static_cast<u32>(queue_keys.size()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAudioBuffersCallback() {
|
2018-01-25 04:38:19 +01:00
|
|
|
if (audio_out_state != AudioState::Started) {
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (queue_keys.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer_event->Signal();
|
|
|
|
}
|
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
enum class AudioState : u32 {
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
Started,
|
|
|
|
Stopped,
|
|
|
|
};
|
|
|
|
|
|
|
|
/// This is used to trigger the audio event callback that is going to read the samples from the
|
|
|
|
/// audio_buffer list and enqueue the samples using the sink (audio_core).
|
|
|
|
CoreTiming::EventType* audio_event;
|
|
|
|
|
|
|
|
/// This is the evend handle used to check if the audio buffer was released
|
|
|
|
Kernel::SharedPtr<Kernel::Event> buffer_event;
|
|
|
|
|
2018-01-25 04:38:19 +01:00
|
|
|
/// (st4rk): This is just a temporary workaround for the future implementation. Libtransistor
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
/// uses the key as an address in the App, so we need to return when the
|
|
|
|
/// GetReleasedAudioOutBuffer_1 is called, otherwise we'll run in problems, because
|
2018-01-25 04:38:19 +01:00
|
|
|
/// libtransistor uses the key returned as an pointer.
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
std::vector<u64> queue_keys;
|
|
|
|
|
|
|
|
AudioState audio_out_state;
|
2018-01-22 04:03:36 +01:00
|
|
|
};
|
|
|
|
|
2018-01-15 03:29:11 +01:00
|
|
|
void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
2018-01-22 04:03:36 +01:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
const std::string audio_interface = "AudioInterface";
|
2018-02-14 04:48:31 +01:00
|
|
|
ctx.WriteBuffer(audio_interface.c_str(), audio_interface.size());
|
2018-01-22 04:03:36 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb = rp.MakeBuilder(3, 0, 0);
|
2018-01-22 04:03:36 +01:00
|
|
|
|
2018-01-15 03:29:11 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-01-25 04:38:19 +01:00
|
|
|
// TODO(st4rk): We're currently returning only one audio interface (stringlist size). However,
|
|
|
|
// it's highly possible to have more than one interface (despite that libtransistor requires
|
|
|
|
// only one).
|
2018-01-22 04:03:36 +01:00
|
|
|
rb.Push<u32>(1);
|
2018-01-15 03:29:11 +01:00
|
|
|
}
|
|
|
|
|
2018-01-22 21:27:55 +01:00
|
|
|
void AudOutU::OpenAudioOut(Kernel::HLERequestContext& ctx) {
|
2018-07-02 18:13:26 +02:00
|
|
|
LOG_WARNING(Service_Audio, "(STUBBED) called");
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
|
|
|
|
if (!audio_out_interface) {
|
|
|
|
audio_out_interface = std::make_shared<IAudioOut>();
|
|
|
|
}
|
2018-01-22 21:27:55 +01:00
|
|
|
|
2018-01-24 01:52:18 +01:00
|
|
|
IPC::ResponseBuilder rb{ctx, 6, 0, 1};
|
2018-01-22 21:27:55 +01:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
audout:u OpenAudioOut and IAudioOut (#138)
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* Updated the audout:u and IAudioOut, now it might work with RetroArch without trigger an assert, however it's not the ideal implementation
* audout:u OpenAudioOut implementation and IAudioOut cmd 1,2,3,4,5 implementation
* using an enum for audio_out_state as well as changing its initialize to member initializer list
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* Minor fixes, added Service_Audio for LOG_*, changed PcmFormat enum to EnumClass
* added missing Audio loggin subclass, minor fixes, clang comment breakline
* Solving backend logging conflict
* minor fix
* Fixed duplicated Service NVDRV in backend.cpp, my bad
2018-01-25 04:17:54 +01:00
|
|
|
rb.Push<u32>(sample_rate);
|
|
|
|
rb.Push<u32>(audio_channels);
|
|
|
|
rb.Push<u32>(static_cast<u32>(PcmFormat::Int16));
|
2018-01-25 04:38:19 +01:00
|
|
|
rb.Push<u32>(0); // This field is unknown
|
|
|
|
rb.PushIpcInterface<Audio::IAudioOut>(audio_out_interface);
|
2018-01-22 21:27:55 +01:00
|
|
|
}
|
|
|
|
|
2018-01-15 03:29:11 +01:00
|
|
|
AudOutU::AudOutU() : ServiceFramework("audout:u") {
|
2018-05-21 05:48:44 +02:00
|
|
|
static const FunctionInfo functions[] = {{0, &AudOutU::ListAudioOuts, "ListAudioOuts"},
|
|
|
|
{1, &AudOutU::OpenAudioOut, "OpenAudioOut"},
|
|
|
|
{2, nullptr, "ListAudioOutsAuto"},
|
|
|
|
{3, nullptr, "OpenAudioOutAuto"}};
|
2018-01-15 03:29:11 +01:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2018-04-20 03:41:44 +02:00
|
|
|
} // namespace Service::Audio
|