summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-08 16:03:03 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-08 16:03:03 +1000
commit265049c5192cf0ce862c7db7b4745636afb6c17b (patch)
tree6729bc947c6c2d2d196c9e7baa994a35aeea76ee /src/drivers/include
parentb242ba998699208c87dc066158964de0866b61e2 (diff)
downloadtangara-fw-265049c5192cf0ce862c7db7b4745636afb6c17b.tar.gz
Count samples going in and out of the drain buffer
This is a more accurate way of knowing which track is playing when, and also simplifies a lot of fragile logic in audio_fsm
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/drivers/bluetooth.hpp3
-rw-r--r--src/drivers/include/drivers/i2s_dac.hpp4
2 files changed, 5 insertions, 2 deletions
diff --git a/src/drivers/include/drivers/bluetooth.hpp b/src/drivers/include/drivers/bluetooth.hpp
index 5960de7e..ad61fcc1 100644
--- a/src/drivers/include/drivers/bluetooth.hpp
+++ b/src/drivers/include/drivers/bluetooth.hpp
@@ -13,10 +13,10 @@
#include <freertos/stream_buffer.h>
#include <stdint.h>
#include "drivers/bluetooth_types.hpp"
+#include "drivers/nvs.hpp"
#include "esp_a2dp_api.h"
#include "esp_avrc_api.h"
#include "esp_gap_bt_api.h"
-#include "drivers/nvs.hpp"
#include "tasks.hpp"
#include "tinyfsm.hpp"
#include "tinyfsm/include/tinyfsm.hpp"
@@ -44,6 +44,7 @@ class Bluetooth {
auto SetSource(StreamBufferHandle_t) -> void;
auto SetVolumeFactor(float) -> void;
+ auto SamplesUsed() -> uint32_t;
auto SetEventHandler(std::function<void(bluetooth::Event)> cb) -> void;
};
diff --git a/src/drivers/include/drivers/i2s_dac.hpp b/src/drivers/include/drivers/i2s_dac.hpp
index 5e81f875..0776dbab 100644
--- a/src/drivers/include/drivers/i2s_dac.hpp
+++ b/src/drivers/include/drivers/i2s_dac.hpp
@@ -11,8 +11,8 @@
#include <functional>
#include <memory>
#include <optional>
-#include <utility>
#include <span>
+#include <utility>
#include "driver/i2s_std.h"
#include "driver/i2s_types.h"
@@ -71,6 +71,8 @@ class I2SDac {
auto WriteData(const std::span<const std::byte>& data) -> void;
auto SetSource(StreamBufferHandle_t buffer) -> void;
+ auto SamplesUsed() -> uint32_t;
+
// Not copyable or movable.
I2SDac(const I2SDac&) = delete;
I2SDac& operator=(const I2SDac&) = delete;