diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-10-04 14:41:05 +1000 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-10-04 14:41:05 +1000 |
| commit | 7cc6f198cf437ae60185b65bfa556341be8ec63f (patch) | |
| tree | 5fc3e23a1041ba952fd2298b5d886fe03564890d /src/tangara/audio/playlist.cpp | |
| parent | 39a5d062fc13ad81e91968e1c30b729ec606d934 (diff) | |
| download | tangara-fw-7cc6f198cf437ae60185b65bfa556341be8ec63f.tar.gz | |
Explicitly close the playlist files in the queue on storage unmount
Diffstat (limited to 'src/tangara/audio/playlist.cpp')
| -rw-r--r-- | src/tangara/audio/playlist.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tangara/audio/playlist.cpp b/src/tangara/audio/playlist.cpp index db712252..f57f078d 100644 --- a/src/tangara/audio/playlist.cpp +++ b/src/tangara/audio/playlist.cpp @@ -33,6 +33,10 @@ Playlist::Playlist(const std::string& playlistFilepath) auto Playlist::open() -> bool { std::unique_lock<std::mutex> lock(mutex_); + if (file_open_) { + return true; + } + FRESULT res = f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); if (res != FR_OK) { @@ -194,6 +198,14 @@ auto Playlist::deserialiseCache() -> bool { return true; } +auto Playlist::close() -> void { + if (file_open_) { + f_close(&file_); + file_open_ = false; + file_error_ = false; + } +} + auto Playlist::skipToLocked(size_t position) -> void { if (!file_open_ || file_error_) { return; @@ -306,6 +318,10 @@ MutablePlaylist::MutablePlaylist(const std::string& playlistFilepath) auto MutablePlaylist::open() -> bool { std::unique_lock<std::mutex> lock(mutex_); + + if (file_open_) { + return true; + } FRESULT res = f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); |
