Extract QueueManager from MusicManager
Move the playback queue + shuffle state (the queue vector, shuffled-index list, shuffle cursor, next-queue-id counter, and RNG) into a QueueManager class. To preserve the real-time playback loop's exact behavior, the design is deliberately minimal: QueueManager is a non-thread-safe data holder that exposes its containers by reference, and MusicManager keeps its single playback mutex_/cv_ and drives QueueManager under it. Every former queue_/ shuffledIndices_/shuffleIndex_/nextQueueId_/rng_ site is a 1:1 rename to the accessor with identical semantics — no logic, locking, or ordering change. Build green. Runtime behavior in the live playback loop is unverified here (no audio/TeamSpeak); this is an isolated, revertible commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
622335260f
commit
1efdbe0771
3 files changed
+150
-100
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include "Database.hpp"
|
||||
#include "NetworkClient.hpp"
|
||||
#include "PlaylistLoader.hpp"
|
||||
#include "QueueManager.hpp"
|
||||
#include "RpcTypes.hpp"
|
||||
#include "SubscriptionManager.hpp"
|
||||
#include "YouTubeClient.hpp"
|
||||
@@ -238,7 +239,8 @@ namespace Echoion::Core
|
||||
std::unique_ptr<SubscriptionManager> subscriptionManager_;
|
||||
|
||||
Api::BotConfig config_;
|
||||
std::vector<Api::QueueEntry> queue_;
|
||||
// Playback queue + shuffle state (driven under mutex_).
|
||||
QueueManager queueMgr_;
|
||||
std::optional<Api::QueueEntry> currentTrack_;
|
||||
std::atomic<bool> isPlaying_{false};
|
||||
std::atomic<bool> isPaused_{false};
|
||||
@@ -254,11 +256,7 @@ namespace Echoion::Core
|
||||
std::atomic<float> volume_{0.5f};
|
||||
std::atomic<bool> shuffle_{false};
|
||||
std::atomic<bool> repeat_{false};
|
||||
uint64_t nextQueueId_ = 1;
|
||||
|
||||
// Shuffle state - maintains shuffled order of queue indices
|
||||
std::vector<size_t> shuffledIndices_;
|
||||
size_t shuffleIndex_ = 0;
|
||||
void rebuildShuffledIndices();
|
||||
void reshuffleRemaining();
|
||||
|
||||
@@ -279,7 +277,6 @@ namespace Echoion::Core
|
||||
ClientInfoCallback clientInfoCallback_;
|
||||
UidToClientIdCallback uidToClientIdCallback_;
|
||||
NicknameCallback nicknameCallback_;
|
||||
std::mt19937 rng_{std::random_device{}()};
|
||||
|
||||
// Position tracking for periodic event updates
|
||||
std::chrono::steady_clock::time_point lastPositionUpdate_{};
|
||||
|
||||
Reference in new issue
Block a user