summaryrefslogtreecommitdiff
path: root/src/audio/include/audio_element.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/include/audio_element.hpp')
-rw-r--r--src/audio/include/audio_element.hpp48
1 files changed, 5 insertions, 43 deletions
diff --git a/src/audio/include/audio_element.hpp b/src/audio/include/audio_element.hpp
index b881404c..91036348 100644
--- a/src/audio/include/audio_element.hpp
+++ b/src/audio/include/audio_element.hpp
@@ -20,25 +20,6 @@
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.
- */
-enum AudioProcessingError {
- // Indicates that this element is unable to handle the upcoming chunks.
- UNSUPPORTED_STREAM,
- // Indicates an error with reading or writing stream data.
- IO_ERROR,
- // Indicates that the element has run out of data to process.
- OUT_OF_DATA,
-};
-
static const size_t kEventQueueSize = 8;
/*
@@ -66,35 +47,24 @@ class IAudioElement {
*/
virtual auto StackSizeBytes() const -> std::size_t { return 4096; };
- virtual auto InputMinChunkSize() const -> std::size_t { return 0; }
-
/* Returns this element's input buffer. */
auto InputEventQueue() const -> QueueHandle_t { return input_events_; }
-
/* Returns this element's output buffer. */
auto OutputEventQueue() const -> QueueHandle_t { return output_events_; }
-
auto OutputEventQueue(const QueueHandle_t q) -> void { output_events_ = q; }
- auto HasUnflushedOutput() -> bool { return !buffered_output_.empty(); }
-
virtual auto HasUnprocessedInput() -> bool = 0;
- auto IsOverBuffered() -> bool { return unprocessed_output_chunks_ > 4; }
+ virtual auto IsOverBuffered() -> bool { return false; }
+ auto HasUnflushedOutput() -> bool { return !buffered_output_.empty(); }
auto FlushBufferedOutput() -> bool;
- auto ElementState() const -> ElementState { return current_state_; }
- auto ElementState(enum ElementState e) -> void { current_state_ = e; }
-
- virtual auto OnChunkProcessed() -> void { unprocessed_output_chunks_--; }
-
/*
* Called when a StreamInfo message is received. Used to configure this
* element in preperation for incoming chunks.
*/
- virtual auto ProcessStreamInfo(const StreamInfo& info)
- -> cpp::result<void, AudioProcessingError> = 0;
+ virtual auto ProcessStreamInfo(const StreamInfo& info) -> void = 0;
/*
* Called when a ChunkHeader message is received. Includes the data associated
@@ -102,8 +72,7 @@ class IAudioElement {
* bytes in this chunk that were actually used; leftover bytes will be
* prepended to the next call.
*/
- virtual auto ProcessChunk(const cpp::span<std::byte>& chunk)
- -> cpp::result<std::size_t, AudioProcessingError> = 0;
+ virtual auto ProcessChunk(const cpp::span<std::byte>& chunk) -> void = 0;
virtual auto ProcessEndOfStream() -> void = 0;
@@ -114,7 +83,7 @@ class IAudioElement {
* time. This could be used to synthesize output, or to save memory by
* releasing unused resources.
*/
- virtual auto Process() -> cpp::result<void, AudioProcessingError> = 0;
+ virtual auto Process() -> void = 0;
protected:
auto SendOrBufferEvent(std::unique_ptr<StreamEvent> event) -> bool;
@@ -125,15 +94,8 @@ class IAudioElement {
// if we're not yet in a pipeline.
// FIXME: it would be nicer if this was non-nullable.
QueueHandle_t output_events_;
-
- // The number of output chunks that we have generated, but have not yet been
- // processed by the next element in the pipeline. This includes any chunks
- // that are currently help in buffered_output_.
- int unprocessed_output_chunks_;
// Output events that have been generated, but are yet to be sent downstream.
std::deque<std::unique_ptr<StreamEvent>> buffered_output_;
-
- enum ElementState current_state_;
};
} // namespace audio