Add shutdown path for audio layer. Add basic event loop after setting up groove objects. Fix race condition bug by not setting path first.
This commit is contained in:
@@ -157,12 +157,34 @@ void GroovePlayerMgr::grooveEventLoop()
|
|||||||
struct GroovePlayer* player = groove_player_create();
|
struct GroovePlayer* player = groove_player_create();
|
||||||
if(!player) {return;}
|
if(!player) {return;}
|
||||||
|
|
||||||
|
groove_playlist_insert(playlist, groove_file_open(selectedTrack->trackPath.c_str()),1.0,1.0,nullptr);
|
||||||
|
|
||||||
|
//Now start loop
|
||||||
|
groove_player_attach(player, playlist);
|
||||||
|
|
||||||
|
while(getInstance()->continueEventLoop)
|
||||||
|
{
|
||||||
|
PlayerEvents event = getInstance()->getNextPlayerEvent();
|
||||||
|
if(event == NOTHING)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//TODO
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
groove_player_detach(player);
|
||||||
|
groove_player_destroy(player);
|
||||||
|
groove_playlist_destroy(playlist);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroovePlayerMgr::shutdown()
|
||||||
|
{
|
||||||
|
continueEventLoop = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GroovePlayerMgr::PlayerEvents GroovePlayerMgr::getNextPlayerEvent()
|
GroovePlayerMgr::PlayerEvents GroovePlayerMgr::getNextPlayerEvent()
|
||||||
{
|
{
|
||||||
|
return NOTHING;
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,18 +37,20 @@ class GroovePlayerMgr
|
|||||||
public:
|
public:
|
||||||
static std::filesystem::path musicScanDir;
|
static std::filesystem::path musicScanDir;
|
||||||
static GroovePlayerMgr* getInstance() {
|
static GroovePlayerMgr* getInstance() {
|
||||||
|
musicScanDir = std::filesystem::current_path()/"music";
|
||||||
static GroovePlayerMgr instance("music.db");
|
static GroovePlayerMgr instance("music.db");
|
||||||
musicScanDir = std::filesystem::path("music");
|
|
||||||
return &instance;
|
return &instance;
|
||||||
};
|
};
|
||||||
GroovePlayerMgr ( GroovePlayerMgr const&) = delete;
|
GroovePlayerMgr ( GroovePlayerMgr const&) = delete;
|
||||||
void operator=( GroovePlayerMgr const&) = delete;
|
void operator=( GroovePlayerMgr const&) = delete;
|
||||||
|
void shutdown();
|
||||||
private:
|
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};
|
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);
|
GroovePlayerMgr (std::string dbFile);
|
||||||
Wt::Dbo::backend::Sqlite3 sqliteConnection;
|
Wt::Dbo::backend::Sqlite3 sqliteConnection;
|
||||||
Wt::Dbo::Session sqlSession;
|
Wt::Dbo::Session sqlSession;
|
||||||
|
bool continueEventLoop = true;
|
||||||
|
|
||||||
std::list<const AudioTrack*> requestQueue;
|
std::list<const AudioTrack*> requestQueue;
|
||||||
std::list<PlayerEvents> lastInternalEvents;
|
std::list<PlayerEvents> lastInternalEvents;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ int main ( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
GroovePlayerMgr::getInstance();
|
GroovePlayerMgr::getInstance();
|
||||||
int sig = Wt::WServer::waitForShutdown(argv[0]);
|
int sig = Wt::WServer::waitForShutdown(argv[0]);
|
||||||
|
GroovePlayerMgr::getInstance()->shutdown();
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user