summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tangara/audio/audio_fsm.cpp12
-rw-r--r--src/tangara/audio/audio_fsm.hpp1
2 files changed, 11 insertions, 2 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp
index 131e0a06..210f9afd 100644
--- a/src/tangara/audio/audio_fsm.cpp
+++ b/src/tangara/audio/audio_fsm.cpp
@@ -70,6 +70,8 @@ StreamCues AudioState::sStreamCues;
bool AudioState::sIsPaused = true;
+uint8_t AudioState::sUpdateCounter = 0;
+
auto AudioState::emitPlaybackUpdate(bool paused) -> void {
std::optional<uint32_t> position;
auto current = sStreamCues.current();
@@ -80,8 +82,14 @@ auto AudioState::emitPlaybackUpdate(bool paused) -> void {
current.first->start_offset.value_or(0);
}
- if (position) {
- // Update position if the duration has been long enough
+ // If we've got an elapsed duration and it's more than 5 minutes
+ // increment a counter. Every 60 counts (ie, every minute) save the current elapsed position
+ if (position && *position > (5 * 60)) {
+ sUpdateCounter++;
+ if (sUpdateCounter > 60) {
+ sUpdateCounter = 0;
+ updateSavedPosition(current.first->uri, *position);
+ }
}
PlaybackUpdate event{
diff --git a/src/tangara/audio/audio_fsm.hpp b/src/tangara/audio/audio_fsm.hpp
index 0c8f4d26..99824b4c 100644
--- a/src/tangara/audio/audio_fsm.hpp
+++ b/src/tangara/audio/audio_fsm.hpp
@@ -90,6 +90,7 @@ class AudioState : public tinyfsm::Fsm<AudioState> {
static std::optional<IAudioOutput::Format> sDrainFormat;
static bool sIsPaused;
+ static uint8_t sUpdateCounter;
};
namespace states {