summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-05 09:51:10 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-05 09:51:10 +1000
commit0032896251d8ddc6c2775495445da8fceffba98e (patch)
tree5a7f981a832977c153bc9a292305b61605b8eb66 /src/audio
parent382d82a14b1427f18a05eae7fb7763d4fa5bc319 (diff)
downloadtangara-fw-0032896251d8ddc6c2775495445da8fceffba98e.tar.gz
Move UI task to priority 0 during playback
Also other misc task cleanup
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/audio_converter.cpp7
-rw-r--r--src/audio/audio_decoder.cpp5
-rw-r--r--src/audio/audio_fsm.cpp4
-rw-r--r--src/audio/include/audio_events.hpp4
4 files changed, 12 insertions, 8 deletions
diff --git a/src/audio/audio_converter.cpp b/src/audio/audio_converter.cpp
index 60d83648..474bbd9f 100644
--- a/src/audio/audio_converter.cpp
+++ b/src/audio/audio_converter.cpp
@@ -23,8 +23,9 @@
static constexpr char kTag[] = "mixer";
-static constexpr std::size_t kSourceBufferLength = 8 * 1024;
-static constexpr std::size_t kSampleBufferLength = 240 * 2 * 4;
+static constexpr std::size_t kSampleBufferLength = 240 * 2 * 8;
+static constexpr std::size_t kSourceBufferLength =
+ kSampleBufferLength * 2 * sizeof(sample::Sample);
namespace audio {
@@ -46,7 +47,7 @@ SampleConverter::SampleConverter()
kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)),
kSampleBufferLength};
- tasks::StartPersistent<tasks::Type::kMixer>([&]() { Main(); });
+ tasks::StartPersistent<tasks::Type::kAudioConverter>([&]() { Main(); });
}
SampleConverter::~SampleConverter() {
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp
index f9f76387..f4868daa 100644
--- a/src/audio/audio_decoder.cpp
+++ b/src/audio/audio_decoder.cpp
@@ -46,7 +46,7 @@ namespace audio {
static const char* kTag = "audio_dec";
-static constexpr std::size_t kCodecBufferLength = 240 * 4 * 4;
+static constexpr std::size_t kCodecBufferLength = 240 * 4 * 16;
Timer::Timer(const codecs::ICodec::OutputFormat& format)
: current_seconds_(0),
@@ -79,7 +79,8 @@ auto Timer::AddSamples(std::size_t samples) -> void {
auto Decoder::Start(std::shared_ptr<IAudioSource> source,
std::shared_ptr<SampleConverter> sink) -> Decoder* {
Decoder* task = new Decoder(source, sink);
- tasks::StartPersistent<tasks::Type::kAudio>(1, [=]() { task->Main(); });
+ tasks::StartPersistent<tasks::Type::kAudioDecoder>(1,
+ [=]() { task->Main(); });
return task;
}
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index f5ce2957..af43c9b9 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -143,6 +143,9 @@ void Standby::react(const TogglePlayPause& ev) {
void Playback::entry() {
ESP_LOGI(kTag, "beginning playback");
sOutput->SetInUse(true);
+
+ events::System().Dispatch(PlaybackStarted{});
+ events::Ui().Dispatch(PlaybackStarted{});
}
void Playback::exit() {
@@ -153,6 +156,7 @@ void Playback::exit() {
sOutput->SetInUse(false);
events::System().Dispatch(PlaybackFinished{});
+ events::Ui().Dispatch(PlaybackFinished{});
}
void Playback::react(const QueueUpdate& ev) {
diff --git a/src/audio/include/audio_events.hpp b/src/audio/include/audio_events.hpp
index 7433d159..db6a3297 100644
--- a/src/audio/include/audio_events.hpp
+++ b/src/audio/include/audio_events.hpp
@@ -17,9 +17,7 @@
namespace audio {
-struct PlaybackStarted : tinyfsm::Event {
- database::Track track;
-};
+struct PlaybackStarted : tinyfsm::Event {};
struct PlaybackUpdate : tinyfsm::Event {
uint32_t seconds_elapsed;