Write out event loop buckets. Implement nowplaying and voting to put in enough to be mostly self-running. Remove as much static as possible from groovemgr class to make less of a mess around how things are accessed. Try to solve concurrency issues in DB.
This commit is contained in:
@@ -22,7 +22,9 @@
|
||||
|
||||
#include <Wt/Dbo/Session>
|
||||
#include <Wt/Dbo/backend/Sqlite3>
|
||||
#include <Wt/Dbo/FixedSqlConnectionPool>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include "db/User.h"
|
||||
#include "db/AudioTrack.h"
|
||||
@@ -35,7 +37,7 @@ namespace std {
|
||||
class GroovePlayerMgr
|
||||
{
|
||||
public:
|
||||
static std::filesystem::path musicScanDir;
|
||||
std::filesystem::path musicScanDir;
|
||||
static GroovePlayerMgr* getInstance() {
|
||||
static GroovePlayerMgr instance("music.db");
|
||||
return &instance;
|
||||
@@ -47,28 +49,29 @@ public:
|
||||
struct GroovePlaylist* currentPlaylist;
|
||||
struct GroovePlayer* currentPlayer;
|
||||
std::list<const AudioTrack*> currentVoteBatch;
|
||||
std::map<const AudioTrack*, int> currentVoteStatus;
|
||||
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};
|
||||
|
||||
GroovePlayerMgr (std::string dbFile);
|
||||
Wt::Dbo::backend::Sqlite3 sqliteConnection;
|
||||
Wt::Dbo::Session sqlSession;
|
||||
Wt::Dbo::FixedSqlConnectionPool connectionPool;
|
||||
bool continueEventLoop = true;
|
||||
bool finishedLaunchScan = false;
|
||||
|
||||
std::list<const AudioTrack*> requestQueue;
|
||||
std::list<PlayerEvents> lastInternalEvents;
|
||||
|
||||
|
||||
std::thread* grooveEvents;
|
||||
static void grooveEventLoop();
|
||||
std::list<const AudioTrack*> getNextVoteBatch();
|
||||
void grooveEventLoop();
|
||||
std::list<const AudioTrack*> getNextVoteBatch(Wt::Dbo::Session* session);
|
||||
std::thread* grooveAudioScanner;
|
||||
static void grooveAudioScannerLoop();
|
||||
PlayerEvents getNextPlayerEvent();
|
||||
static bool addFileToTrackDBIfTagged(std::filesystem::path file);
|
||||
static void removeOrphanedTracks();
|
||||
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::ptr<AudioTrack> getCurrentTrack(Wt::Dbo::Session* session);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user