forked from etc/pineapple-src
early-access version 2969
This commit is contained in:
parent
2d12f7fb50
commit
54a6248e07
8 changed files with 32 additions and 35 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 2968.
|
This is the source code for early-access 2969.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique<AudioManager>(system)} {
|
AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique<AudioManager>()} {
|
||||||
CreateSinks();
|
CreateSinks();
|
||||||
// Must be created after the sinks
|
// Must be created after the sinks
|
||||||
adsp = std::make_unique<AudioRenderer::ADSP::ADSP>(system, *output_sink);
|
adsp = std::make_unique<AudioRenderer::ADSP::ADSP>(system, *output_sink);
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "audio_core/audio_in_manager.h"
|
|
||||||
#include "audio_core/audio_manager.h"
|
#include "audio_core/audio_manager.h"
|
||||||
#include "audio_core/audio_out_manager.h"
|
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "core/hle/service/audio/errors.h"
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
AudioManager::AudioManager(Core::System& system_) : system{system_} {
|
AudioManager::AudioManager() {
|
||||||
thread = std::jthread([this]() { ThreadFunc(); });
|
thread = std::jthread([this]() { ThreadFunc(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) {
|
||||||
|
|
||||||
const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)};
|
const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)};
|
||||||
if (buffer_events[index] == nullptr) {
|
if (buffer_events[index] == nullptr) {
|
||||||
buffer_events[index] = buffer_func;
|
buffer_events[index] = std::move(buffer_func);
|
||||||
needs_update = true;
|
needs_update = true;
|
||||||
events.SetAudioEvent(Event::Type::AudioOutManager, true);
|
events.SetAudioEvent(Event::Type::AudioOutManager, true);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +42,7 @@ Result AudioManager::SetInManager(BufferEventFunc buffer_func) {
|
||||||
|
|
||||||
const auto index{events.GetManagerIndex(Event::Type::AudioInManager)};
|
const auto index{events.GetManagerIndex(Event::Type::AudioInManager)};
|
||||||
if (buffer_events[index] == nullptr) {
|
if (buffer_events[index] == nullptr) {
|
||||||
buffer_events[index] = buffer_func;
|
buffer_events[index] = std::move(buffer_func);
|
||||||
needs_update = true;
|
needs_update = true;
|
||||||
events.SetAudioEvent(Event::Type::AudioInManager, true);
|
events.SetAudioEvent(Event::Type::AudioInManager, true);
|
||||||
}
|
}
|
||||||
|
@ -60,19 +59,21 @@ void AudioManager::ThreadFunc() {
|
||||||
running = true;
|
running = true;
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
auto timed_out{events.Wait(l, std::chrono::seconds(2))};
|
const auto timed_out{events.Wait(l, std::chrono::seconds(2))};
|
||||||
|
|
||||||
if (events.CheckAudioEventSet(Event::Type::Max)) {
|
if (events.CheckAudioEventSet(Event::Type::Max)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < buffer_events.size(); i++) {
|
for (size_t i = 0; i < buffer_events.size(); i++) {
|
||||||
if (events.CheckAudioEventSet(Event::Type(i)) || timed_out) {
|
const auto event_type = static_cast<Event::Type>(i);
|
||||||
|
|
||||||
|
if (events.CheckAudioEventSet(event_type) || timed_out) {
|
||||||
if (buffer_events[i]) {
|
if (buffer_events[i]) {
|
||||||
buffer_events[i]();
|
buffer_events[i]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
events.SetAudioEvent(Event::Type(i), false);
|
events.SetAudioEvent(event_type, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,11 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "audio_core/audio_event.h"
|
#include "audio_core/audio_event.h"
|
||||||
#include "core/hle/service/audio/errors.h"
|
|
||||||
|
|
||||||
namespace Core {
|
union Result;
|
||||||
class System;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
namespace AudioOut {
|
|
||||||
class Manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace AudioIn {
|
|
||||||
class Manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AudioManager's main purpose is to wait for buffer events for the audio in and out managers,
|
* The AudioManager's main purpose is to wait for buffer events for the audio in and out managers,
|
||||||
* and call an associated callback to release buffers.
|
* and call an associated callback to release buffers.
|
||||||
|
@ -43,7 +32,7 @@ class AudioManager {
|
||||||
using BufferEventFunc = std::function<void()>;
|
using BufferEventFunc = std::function<void()>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AudioManager(Core::System& system);
|
explicit AudioManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown the audio manager.
|
* Shutdown the audio manager.
|
||||||
|
@ -80,10 +69,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void ThreadFunc();
|
void ThreadFunc();
|
||||||
|
|
||||||
/// Core system
|
|
||||||
Core::System& system;
|
|
||||||
/// Have sessions started palying?
|
|
||||||
bool sessions_started{};
|
|
||||||
/// Is the main thread running?
|
/// Is the main thread running?
|
||||||
std::atomic<bool> running{};
|
std::atomic<bool> running{};
|
||||||
/// Unused
|
/// Unused
|
||||||
|
|
|
@ -47,7 +47,7 @@ RenderMessage AudioRenderer_Mailbox::ADSPWaitMessage() {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandBuffer& AudioRenderer_Mailbox::GetCommandBuffer(const s32 session_id) {
|
CommandBuffer& AudioRenderer_Mailbox::GetCommandBuffer(const u32 session_id) {
|
||||||
return command_buffers[session_id];
|
return command_buffers[session_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
* @param session_id - The session id to get (0 or 1).
|
* @param session_id - The session id to get (0 or 1).
|
||||||
* @return The command buffer.
|
* @return The command buffer.
|
||||||
*/
|
*/
|
||||||
CommandBuffer& GetCommandBuffer(s32 session_id);
|
CommandBuffer& GetCommandBuffer(u32 session_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the command buffer with the given session id (0 or 1).
|
* Set the command buffer with the given session id (0 or 1).
|
||||||
|
|
|
@ -364,7 +364,7 @@ std::pair<s32, Errno> Poll(std::vector<PollFD>& pollfds, s32 timeout) {
|
||||||
std::vector<WSAPOLLFD> host_pollfds(pollfds.size());
|
std::vector<WSAPOLLFD> host_pollfds(pollfds.size());
|
||||||
std::transform(pollfds.begin(), pollfds.end(), host_pollfds.begin(), [](PollFD fd) {
|
std::transform(pollfds.begin(), pollfds.end(), host_pollfds.begin(), [](PollFD fd) {
|
||||||
WSAPOLLFD result;
|
WSAPOLLFD result;
|
||||||
result.fd = fd.socket->fd;
|
result.fd = fd.socket->GetFD();
|
||||||
result.events = TranslatePollEvents(fd.events);
|
result.events = TranslatePollEvents(fd.events);
|
||||||
result.revents = 0;
|
result.revents = 0;
|
||||||
return result;
|
return result;
|
||||||
|
@ -430,12 +430,12 @@ std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
||||||
return {AcceptResult{}, GetAndLogLastError()};
|
return {AcceptResult{}, GetAndLogLastError()};
|
||||||
}
|
}
|
||||||
|
|
||||||
AcceptResult result;
|
|
||||||
result.socket = std::make_unique<Socket>();
|
|
||||||
result.socket->fd = new_socket;
|
|
||||||
|
|
||||||
ASSERT(addrlen == sizeof(sockaddr_in));
|
ASSERT(addrlen == sizeof(sockaddr_in));
|
||||||
result.sockaddr_in = TranslateToSockAddrIn(addr);
|
|
||||||
|
AcceptResult result{
|
||||||
|
.socket = std::make_unique<Socket>(new_socket),
|
||||||
|
.sockaddr_in = TranslateToSockAddrIn(addr),
|
||||||
|
};
|
||||||
|
|
||||||
return {std::move(result), Errno::SUCCESS};
|
return {std::move(result), Errno::SUCCESS};
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@ public:
|
||||||
std::unique_ptr<SocketBase> socket;
|
std::unique_ptr<SocketBase> socket;
|
||||||
SockAddrIn sockaddr_in;
|
SockAddrIn sockaddr_in;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SocketBase() = default;
|
||||||
|
explicit SocketBase(SOCKET fd_) : fd{fd_} {}
|
||||||
|
|
||||||
virtual ~SocketBase() = default;
|
virtual ~SocketBase() = default;
|
||||||
|
|
||||||
virtual SocketBase& operator=(const SocketBase&) = delete;
|
virtual SocketBase& operator=(const SocketBase&) = delete;
|
||||||
|
@ -89,12 +93,19 @@ public:
|
||||||
|
|
||||||
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
|
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] SOCKET GetFD() const {
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
SOCKET fd = INVALID_SOCKET;
|
SOCKET fd = INVALID_SOCKET;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Socket : public SocketBase {
|
class Socket : public SocketBase {
|
||||||
public:
|
public:
|
||||||
Socket() = default;
|
Socket() = default;
|
||||||
|
explicit Socket(SOCKET fd_) : SocketBase{fd_} {}
|
||||||
|
|
||||||
~Socket() override;
|
~Socket() override;
|
||||||
|
|
||||||
Socket(const Socket&) = delete;
|
Socket(const Socket&) = delete;
|
||||||
|
|
Loading…
Reference in a new issue