summaryrefslogtreecommitdiff
path: root/src/audio/audio_task.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2022-11-17 17:36:37 +1100
committerjacqueline <me@jacqueline.id.au>2022-11-17 17:36:37 +1100
commitacd6d7890051b9253007941733ea37e4011b1b5e (patch)
tree5a542b3c98fe2a37dd9c10d9093a6e46b2267875 /src/audio/audio_task.cpp
parentddcbcad6d4771e0ec8228dc1848ebd1dfe303a0b (diff)
downloadtangara-fw-acd6d7890051b9253007941733ea37e4011b1b5e.tar.gz
Progress on own pipeline. Still very WIP
Diffstat (limited to 'src/audio/audio_task.cpp')
-rw-r--r--src/audio/audio_task.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/audio/audio_task.cpp b/src/audio/audio_task.cpp
index 1853431a..86eb4f4a 100644
--- a/src/audio/audio_task.cpp
+++ b/src/audio/audio_task.cpp
@@ -10,10 +10,12 @@
#include "freertos/stream_buffer.h"
#include "audio_element.hpp"
+#include "include/audio_element.hpp"
namespace audio {
static const TickType_t kCommandWaitTicks = 1;
+static const TickType_t kIdleTaskDelay = 1;
void audio_task(void* args) {
AudioTaskArgs* real_args = reinterpret_cast<AudioTaskArgs*>(args);
@@ -30,8 +32,16 @@ void audio_task(void* args) {
while (1) {
IAudioElement::Command command;
+ ProcessResult result;
+
if (!xQueueReceive(commands, &command, kCommandWaitTicks)) {
- element->ProcessIdle();
+ result = element->ProcessIdle();
+ if (result == IAudioElement::ERROR) {
+ break;
+ }
+ if (result == IAudioElement::OUTPUT_FULL) {
+ vTaskDelay(kIdleTaskDelay);
+ }
continue;
};
@@ -39,7 +49,6 @@ void audio_task(void* args) {
if (command.sequence_number > current_sequence_number) {
current_sequence_number = command.sequence_number;
}
-
continue;
}
@@ -49,7 +58,13 @@ void audio_task(void* args) {
xStreamBufferReceive(stream, &frame_buffer, command.read_size, 0);
if (command.sequence_number == current_sequence_number) {
- element->ProcessData(frame_buffer, command.read_size);
+ result = element->ProcessData(frame_buffer, command.read_size);
+ if (result == IAudioElement::ERROR) {
+ break;
+ }
+ if (result == IAudioElement::OUTPUT_FULL) {
+ // TODO: Do we care about this? could just park indefinitely.
+ }
}
continue;
@@ -58,7 +73,13 @@ void audio_task(void* args) {
if (command.type == IAudioElement::ELEMENT) {
assert(command.data != NULL);
if (command.sequence_number == current_sequence_number) {
- element->ProcessElementCommand(command.data);
+ result = element->ProcessElementCommand(command.data);
+ if (result == IAudioElement::ERROR) {
+ break;
+ }
+ if (result == IAudioElement::OUTPUT_FULL) {
+ // TODO: what does this mean lol
+ }
} else {
element->SkipElementCommand(command.data);
}