From 2056cad0ab7b805f0ed5629b100b50f8ea9e127e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 12 Jan 2023 14:28:52 +1100 Subject: WIP --- src/audio/include/audio_element.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/audio/include/audio_element.hpp') 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 #include -#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 = 0; + virtual auto PrepareForPause() -> void{}; + protected: StreamBuffer* input_buffer_; StreamBuffer* output_buffer_; + std::atomic state_; }; } // namespace audio -- cgit v1.2.3