Stop using pointers from DB as storage mechanism. Start storing copies of the object itself. Use commits after methods are done with transaction to hopefully help with DB issues. Don't use map because it requires too much about the key object I don't need. Add boolean that prevents vote end from being called constantly during it's 3 second window.
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include <Wt/Dbo/backend/Sqlite3>
|
||||
#include <Wt/Dbo/FixedSqlConnectionPool>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include "db/User.h"
|
||||
#include "db/AudioTrack.h"
|
||||
@@ -48,8 +47,9 @@ public:
|
||||
|
||||
struct GroovePlaylist* currentPlaylist;
|
||||
struct GroovePlayer* currentPlayer;
|
||||
std::list<const AudioTrack*> currentVoteBatch;
|
||||
std::map<const AudioTrack*, int> currentVoteStatus;
|
||||
std::list<AudioTrack> currentVoteBatch;
|
||||
std::list<std::pair<AudioTrack, int>> currentVoteStatus;
|
||||
bool voteEndedButNotNextTrackYet = false;
|
||||
private:
|
||||
enum PlayerEvents {NOTHING, GROOVE_NOWPLAYING, VOTING_ENDED, VOTE_CAST, PLAYING_PAUSED, PLAYING_RESUMED, SKIP_REQUESTED, SKIP_VOTE_CAST, SKIP_VOTING_ENDED, ADMIN_FORCE_SKIP};
|
||||
|
||||
@@ -59,19 +59,19 @@ private:
|
||||
bool continueEventLoop = true;
|
||||
bool finishedLaunchScan = false;
|
||||
|
||||
std::list<const AudioTrack*> requestQueue;
|
||||
std::list<AudioTrack> requestQueue;
|
||||
std::list<PlayerEvents> lastInternalEvents;
|
||||
|
||||
std::thread* grooveEvents;
|
||||
void grooveEventLoop();
|
||||
std::list<const AudioTrack*> getNextVoteBatch(Wt::Dbo::Session* session);
|
||||
std::list<AudioTrack> getNextVoteBatch(Wt::Dbo::Session* session);
|
||||
std::thread* grooveAudioScanner;
|
||||
void grooveAudioScannerLoop();
|
||||
PlayerEvents getNextPlayerEvent(Wt::Dbo::Session* session);
|
||||
bool addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::filesystem::path file);
|
||||
void removeOrphanedTracks(Wt::Dbo::Session* session);
|
||||
|
||||
Wt::Dbo::ptr<AudioTrack> getCurrentTrack(Wt::Dbo::Session* session);
|
||||
AudioTrack getCurrentTrack(Wt::Dbo::Session* session);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user