diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-03-25 17:34:41 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-03-25 17:34:41 +1100 |
| commit | 175bfc4e3e9f7aa39e084d3f1625347f1d5711ec (patch) | |
| tree | f71b458f19acca855815ab876944d48a3c5acbcb /src/lua | |
| parent | 5c985afd258a96b68d6bd5a4fade17ed998d2c07 (diff) | |
| download | tangara-fw-175bfc4e3e9f7aa39e084d3f1625347f1d5711ec.tar.gz | |
WIP rewrie audio pipeline+fsm guts for more reliability
Diffstat (limited to 'src/lua')
| -rw-r--r-- | src/lua/include/property.hpp | 2 | ||||
| -rw-r--r-- | src/lua/property.cpp | 23 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/lua/include/property.hpp b/src/lua/include/property.hpp index 7d160fba..f19fdeec 100644 --- a/src/lua/include/property.hpp +++ b/src/lua/include/property.hpp @@ -23,7 +23,7 @@ using LuaValue = std::variant<std::monostate, int, bool, std::string, - audio::Track, + audio::TrackInfo, drivers::bluetooth::Device, std::vector<drivers::bluetooth::Device>>; 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); |
