diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2023-08-31 16:09:15 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-09-16 17:56:25 +0200 |
commit | 67e2d5c28b8423c4f3f1d5b00f87325684158a6f (patch) | |
tree | e419a2bb6c064ddc69a49046705b6187772fee48 /src/audio_core/adsp/mailbox.h | |
parent | Merge pull request #11519 from german77/system-policy (diff) | |
download | yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar.gz yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar.bz2 yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar.lz yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar.xz yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.tar.zst yuzu-67e2d5c28b8423c4f3f1d5b00f87325684158a6f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/adsp/mailbox.h | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/audio_core/adsp/mailbox.h b/src/audio_core/adsp/mailbox.h index c31b73717..1dd40ebfa 100644 --- a/src/audio_core/adsp/mailbox.h +++ b/src/audio_core/adsp/mailbox.h @@ -3,6 +3,8 @@ #pragma once +#include <span> + #include "common/bounded_threadsafe_queue.h" #include "common/common_types.h" @@ -19,11 +21,6 @@ enum class Direction : u32 { DSP, }; -struct MailboxMessage { - u32 msg; - std::span<u8> data; -}; - class Mailbox { public: void Initialize(AppMailboxId id_) { @@ -35,25 +32,19 @@ public: return id; } - void Send(Direction dir, MailboxMessage&& message) { + void Send(Direction dir, u32 message) { auto& queue = dir == Direction::Host ? host_queue : adsp_queue; - queue.EmplaceWait(std::move(message)); + queue.EmplaceWait(message); } - MailboxMessage Receive(Direction dir, bool block = true) { + u32 Receive(Direction dir, std::stop_token stop_token = {}) { auto& queue = dir == Direction::Host ? host_queue : adsp_queue; - MailboxMessage t; - if (block) { - queue.PopWait(t); - } else { - queue.TryPop(t); - } - return t; + return queue.PopWait(stop_token); } void Reset() { id = AppMailboxId::Invalid; - MailboxMessage t; + u32 t{}; while (host_queue.TryPop(t)) { } while (adsp_queue.TryPop(t)) { @@ -62,8 +53,8 @@ public: private: AppMailboxId id{0}; - Common::SPSCQueue<MailboxMessage> host_queue; - Common::SPSCQueue<MailboxMessage> adsp_queue; + Common::SPSCQueue<u32> host_queue; + Common::SPSCQueue<u32> adsp_queue; }; } // namespace AudioCore::ADSP |