summaryrefslogtreecommitdiff
path: root/src/audio/audio_element.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-04-01 13:22:21 +1100
committerjacqueline <me@jacqueline.id.au>2023-04-19 10:29:38 +1000
commit7c6fd654f50e6665efa4226c6b927f9762734182 (patch)
tree58ccb69068c550e9c2223c1b510cfa525690b731 /src/audio/audio_element.cpp
parent3817ec0c77b8d44e54b35ea9f76e7bb4666c6c08 (diff)
downloadtangara-fw-7c6fd654f50e6665efa4226c6b927f9762734182.tar.gz
New pipeline building, still needs proper control
Diffstat (limited to 'src/audio/audio_element.cpp')
-rw-r--r--src/audio/audio_element.cpp56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/audio/audio_element.cpp b/src/audio/audio_element.cpp
deleted file mode 100644
index cef54631..00000000
--- a/src/audio/audio_element.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "audio_element.hpp"
-#include <memory>
-
-namespace audio {
-
-IAudioElement::IAudioElement()
- : input_events_(xQueueCreate(kEventQueueSize, sizeof(void*))),
- output_events_(nullptr),
- buffered_output_() {}
-
-IAudioElement::~IAudioElement() {
- // Ensure we don't leak any memory from events leftover in the queue.
- while (uxQueueSpacesAvailable(input_events_) < kEventQueueSize) {
- StreamEvent* event;
- if (xQueueReceive(input_events_, &event, 0)) {
- free(event);
- } else {
- break;
- }
- }
- // Technically there's a race here if someone is still adding to the queue,
- // but hopefully the whole pipeline is stopped if an element is being
- // destroyed.
- vQueueDelete(input_events_);
-}
-
-auto IAudioElement::SendOrBufferEvent(std::unique_ptr<StreamEvent> event)
- -> bool {
- if (!buffered_output_.empty()) {
- // To ensure we send data in order, don't try to send if we've already
- // failed to send something.
- buffered_output_.push_back(std::move(event));
- return false;
- }
- StreamEvent* raw_event = event.release();
- if (!xQueueSend(output_events_, &raw_event, 0)) {
- event.reset(raw_event);
- buffered_output_.push_back(std::move(event));
- return false;
- }
- return true;
-}
-
-auto IAudioElement::FlushBufferedOutput() -> bool {
- while (!buffered_output_.empty()) {
- StreamEvent* raw_event = buffered_output_.front().release();
- buffered_output_.pop_front();
- if (!xQueueSend(output_events_, &raw_event, 0)) {
- buffered_output_.emplace_front(raw_event);
- return false;
- }
- }
- return true;
-}
-
-} // namespace audio