Fix issues with deserialising queue when queue exists already

custom
ailurux 7 months ago
parent 6318b27284
commit 39a5d062fc
  1. 11
      src/tangara/audio/playlist.cpp

@ -32,9 +32,6 @@ Playlist::Playlist(const std::string& playlistFilepath)
auto Playlist::open() -> bool { auto Playlist::open() -> bool {
std::unique_lock<std::mutex> lock(mutex_); std::unique_lock<std::mutex> lock(mutex_);
if (file_open_) {
return true;
}
FRESULT res = FRESULT res =
f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
@ -185,6 +182,9 @@ auto Playlist::deserialiseCache() -> bool {
total_size_ = entries->get(1)->asUint()->unsignedValue(); total_size_ = entries->get(1)->asUint()->unsignedValue();
// In case we have existing entries
offset_cache_.clear();
// Read in the cache // Read in the cache
for (size_t i = 2; i < entries->size(); i++) { for (size_t i = 2; i < entries->size(); i++) {
offset_cache_.push_back(entries->get(i)->asUint()->unsignedValue()); offset_cache_.push_back(entries->get(i)->asUint()->unsignedValue());
@ -306,10 +306,7 @@ MutablePlaylist::MutablePlaylist(const std::string& playlistFilepath)
auto MutablePlaylist::open() -> bool { auto MutablePlaylist::open() -> bool {
std::unique_lock<std::mutex> lock(mutex_); std::unique_lock<std::mutex> lock(mutex_);
if (file_open_) {
return true;
}
FRESULT res = FRESULT res =
f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if (res != FR_OK) { if (res != FR_OK) {

Loading…
Cancel
Save