summaryrefslogtreecommitdiffstats
path: root/src/audio_core/adsp/mailbox.h
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-09-17 16:42:44 +0200
committerGitHub <noreply@github.com>2023-09-17 16:42:44 +0200
commit474739a37920ff8e8a2f5d6f480a9116fdfba825 (patch)
tree8331fac91e1e96ddd379917ad51167cef48868f3 /src/audio_core/adsp/mailbox.h
parentMerge pull request #11523 from t895/shader-workers (diff)
parentReimplement HardwareOpus (diff)
downloadyuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar.gz
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar.bz2
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar.lz
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar.xz
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.tar.zst
yuzu-474739a37920ff8e8a2f5d6f480a9116fdfba825.zip
Diffstat (limited to 'src/audio_core/adsp/mailbox.h')
-rw-r--r--src/audio_core/adsp/mailbox.h27
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