Hot reload fix

This commit is contained in:
faumaray committed 2026-02-03 04:48:29 +03:00
1 parent 8b8a7f4f9a
commit 0fa9db4691
6 files changed
+677 -178

No files matched your search

+18
View File
@@ -11,6 +11,7 @@
#include <thread>
#include <condition_variable>
#include <queue>
#include <functional>
namespace Echoion::Plugin {
@@ -32,6 +33,10 @@ public:
void enableAutoReload();
void disableAutoReload();
[[nodiscard]] bool isAutoReloadEnabled() const noexcept;
// Callback for hot reload completion (called after auto-reload finishes)
using HotReloadCallback = std::function<void()>;
void setHotReloadCallback(HotReloadCallback callback) { hotReloadCallback_ = std::move(callback); }
private:
Api::Result<void> loadLibraryInternal(const std::filesystem::path& path);
@@ -54,7 +59,20 @@ private:
FileWatcher fileWatcher_;
std::atomic<bool> autoReloadEnabled_{false};
// Deferred reload - waits for current track to finish
std::thread deferredReloadThread_;
std::atomic<bool> hasPendingReload_{false};
std::filesystem::path pendingReloadPath_;
std::string pendingTrackId_; // Track ID that was playing when reload scheduled
mutable std::mutex pendingReloadMutex_;
// Hot reload completion callback
HotReloadCallback hotReloadCallback_;
void onCoreFileChanged();
void waitForTrackAndReload(const std::filesystem::path& targetPath, const std::string& trackId);
[[nodiscard]] bool isPlaybackActive() const;
[[nodiscard]] bool isSameTrackPlaying(const std::string& trackId) const;
};
} // namespace Echoion::Plugin