summaryrefslogtreecommitdiff
path: root/src/tangara/audio
diff options
context:
space:
mode:
authorayumi <ayumi@noreply.codeberg.org>2025-02-15 02:25:27 +0100
committerayumi <ayumi@noreply.codeberg.org>2025-03-05 08:57:46 +0100
commit9fdf94e9cee5a5180ffefc2b8314f7a9879ebbc6 (patch)
tree80c2ca8003fe32e59eccf2e208a53e1e87c66790 /src/tangara/audio
parent42c2a4f2445ff56a2a0a78c4ef265e5be346d40d (diff)
downloadtangara-fw-9fdf94e9cee5a5180ffefc2b8314f7a9879ebbc6.tar.gz
Allow manually unmounting the SD card
Diffstat (limited to 'src/tangara/audio')
-rw-r--r--src/tangara/audio/audio_events.hpp4
-rw-r--r--src/tangara/audio/audio_fsm.cpp7
-rw-r--r--src/tangara/audio/audio_fsm.hpp4
3 files changed, 9 insertions, 6 deletions
diff --git a/src/tangara/audio/audio_events.hpp b/src/tangara/audio/audio_events.hpp
index 89dc28ff..24a5cf83 100644
--- a/src/tangara/audio/audio_events.hpp
+++ b/src/tangara/audio/audio_events.hpp
@@ -150,6 +150,10 @@ struct TtsPlaybackChanged : tinyfsm::Event {
bool is_playing;
};
+struct UnmountReady : tinyfsm::Event {
+ bool idle;
+};
+
namespace internal {
struct DecodingStarted : tinyfsm::Event {
std::shared_ptr<TrackInfo> track;
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp
index 7854818d..27c29eee 100644
--- a/src/tangara/audio/audio_fsm.cpp
+++ b/src/tangara/audio/audio_fsm.cpp
@@ -534,10 +534,7 @@ auto Standby::entry() -> void {
updateOutputMode();
}
-void Standby::react(const system_fsm::KeyLockChanged& ev) {
- if (!ev.locking) {
- return;
- }
+void Standby::react(const system_fsm::UnmountRequest& ev) {
auto current = sStreamCues.current();
sServices->bg_worker().Dispatch<void>([=]() {
auto db = sServices->database().lock();
@@ -548,6 +545,7 @@ void Standby::react(const system_fsm::KeyLockChanged& ev) {
if (queue.totalSize() <= queue.currentPosition()) {
// Nothing is playing, so don't bother saving the queue.
db->put(kQueueKey, "");
+ events::System().Dispatch(UnmountReady{.idle = ev.idle});
return;
}
db->put(kQueueKey, queue.serialise());
@@ -562,6 +560,7 @@ void Standby::react(const system_fsm::KeyLockChanged& ev) {
};
db->put(kCurrentFileKey, current_track.toString());
}
+ events::System().Dispatch(UnmountReady{.idle = ev.idle});
});
}
diff --git a/src/tangara/audio/audio_fsm.hpp b/src/tangara/audio/audio_fsm.hpp
index fb42e387..c30012d9 100644
--- a/src/tangara/audio/audio_fsm.hpp
+++ b/src/tangara/audio/audio_fsm.hpp
@@ -65,7 +65,7 @@ class AudioState : public tinyfsm::Fsm<AudioState> {
void react(const OutputModeChanged&);
virtual void react(const system_fsm::BootComplete&) {}
- virtual void react(const system_fsm::KeyLockChanged&){};
+ virtual void react(const system_fsm::UnmountRequest&) {}
virtual void react(const system_fsm::SdStateChanged&) {}
virtual void react(const system_fsm::BluetoothEvent&);
virtual void react(const system_fsm::HasPhonesChanged&);
@@ -114,7 +114,7 @@ class Uninitialised : public AudioState {
class Standby : public AudioState {
public:
void entry() override;
- void react(const system_fsm::KeyLockChanged&) override;
+ void react(const system_fsm::UnmountRequest&) override;
void react(const system_fsm::SdStateChanged&) override;
using AudioState::react;