summaryrefslogtreecommitdiff
path: root/src/audio/include/audio_element.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-01-12 14:28:52 +1100
committerjacqueline <me@jacqueline.id.au>2023-01-12 14:28:52 +1100
commit2056cad0ab7b805f0ed5629b100b50f8ea9e127e (patch)
tree1e8385d48e18551240e9ef9683b8696292f8d760 /src/audio/include/audio_element.hpp
parent01be69eca1fa89c047fc29f5cb0ea8ba0898dad1 (diff)
downloadtangara-fw-2056cad0ab7b805f0ed5629b100b50f8ea9e127e.tar.gz
WIP
Diffstat (limited to 'src/audio/include/audio_element.hpp')
-rw-r--r--src/audio/include/audio_element.hpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/audio/include/audio_element.hpp b/src/audio/include/audio_element.hpp
index 590889bd..ec6d6e80 100644
--- a/src/audio/include/audio_element.hpp
+++ b/src/audio/include/audio_element.hpp
@@ -1,10 +1,11 @@
#pragma once
+#include <atomic>
#include <cstdint>
-#include "chunk.hpp"
#include "freertos/FreeRTOS.h"
+#include "chunk.hpp"
#include "freertos/message_buffer.h"
#include "freertos/portmacro.h"
#include "result.hpp"
@@ -16,6 +17,12 @@
namespace audio {
+enum ElementState {
+ STATE_RUN,
+ STATE_PAUSE,
+ STATE_QUIT,
+};
+
/*
* Errors that may be returned by any of the Process* methods of an audio
* element.
@@ -42,7 +49,8 @@ enum AudioProcessingError {
*/
class IAudioElement {
public:
- IAudioElement() : input_buffer_(nullptr), output_buffer_(nullptr) {}
+ IAudioElement()
+ : input_buffer_(nullptr), output_buffer_(nullptr), state_(STATE_RUN) {}
virtual ~IAudioElement() {}
/*
@@ -71,6 +79,9 @@ class IAudioElement {
auto OutputBuffer(StreamBuffer* b) -> void { output_buffer_ = b; }
+ auto ElementState() const -> ElementState { return state_; }
+ auto ElementState(enum ElementState e) -> void { state_ = e; }
+
/*
* Called when a StreamInfo message is received. Used to configure this
* element in preperation for incoming chunks.
@@ -94,9 +105,12 @@ class IAudioElement {
*/
virtual auto ProcessIdle() -> cpp::result<void, AudioProcessingError> = 0;
+ virtual auto PrepareForPause() -> void{};
+
protected:
StreamBuffer* input_buffer_;
StreamBuffer* output_buffer_;
+ std::atomic<enum ElementState> state_;
};
} // namespace audio