summaryrefslogtreecommitdiff
path: root/src/lua/property.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-03-25 17:34:41 +1100
committerjacqueline <me@jacqueline.id.au>2024-03-25 17:34:41 +1100
commit175bfc4e3e9f7aa39e084d3f1625347f1d5711ec (patch)
treef71b458f19acca855815ab876944d48a3c5acbcb /src/lua/property.cpp
parent5c985afd258a96b68d6bd5a4fade17ed998d2c07 (diff)
downloadtangara-fw-175bfc4e3e9f7aa39e084d3f1625347f1d5711ec.tar.gz
WIP rewrie audio pipeline+fsm guts for more reliability
Diffstat (limited to 'src/lua/property.cpp')
-rw-r--r--src/lua/property.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lua/property.cpp b/src/lua/property.cpp
index f721f9ce..200f4d5c 100644
--- a/src/lua/property.cpp
+++ b/src/lua/property.cpp
@@ -221,7 +221,7 @@ static auto pushTagValue(lua_State* L, const database::TagValue& val) -> void {
val);
}
-static void pushTrack(lua_State* L, const audio::Track& track) {
+static void pushTrack(lua_State* L, const audio::TrackInfo& track) {
lua_newtable(L);
for (const auto& tag : track.tags->allPresent()) {
@@ -229,19 +229,18 @@ static void pushTrack(lua_State* L, const audio::Track& track) {
pushTagValue(L, track.tags->get(tag));
lua_settable(L, -3);
}
- if (track.db_info) {
- lua_pushliteral(L, "id");
- lua_pushinteger(L, track.db_info->id);
+
+ if (track.duration) {
+ lua_pushliteral(L, "duration");
+ lua_pushinteger(L, track.duration.value());
lua_settable(L, -3);
}
- lua_pushliteral(L, "duration");
- lua_pushinteger(L, track.duration);
- lua_settable(L, -3);
-
- lua_pushliteral(L, "bitrate_kbps");
- lua_pushinteger(L, track.bitrate_kbps);
- lua_settable(L, -3);
+ if (track.bitrate_kbps) {
+ lua_pushliteral(L, "bitrate_kbps");
+ lua_pushinteger(L, track.bitrate_kbps.value());
+ lua_settable(L, -3);
+ }
lua_pushliteral(L, "encoding");
lua_pushstring(L, codecs::StreamTypeToString(track.encoding).c_str());
@@ -289,7 +288,7 @@ auto Property::PushValue(lua_State& s) -> int {
lua_pushboolean(&s, arg);
} else if constexpr (std::is_same_v<T, std::string>) {
lua_pushstring(&s, arg.c_str());
- } else if constexpr (std::is_same_v<T, audio::Track>) {
+ } else if constexpr (std::is_same_v<T, audio::TrackInfo>) {
pushTrack(&s, arg);
} else if constexpr (std::is_same_v<T, drivers::bluetooth::Device>) {
pushDevice(&s, arg);