]> git.sesse.net Git - nageru/blobdiff - player.h
Some refactoring of the player code, and begin working on the playlist.
[nageru] / player.h
index 960bc22fcd713f2f7a58d4a9e168f78958206c0e..debf9194474baacacefdc448b14e5bbce6caecfa 100644 (file)
--- a/player.h
+++ b/player.h
@@ -3,7 +3,29 @@
 
 #include "clip_list.h"
 
-void start_player_thread();
-void play_clip(const Clip &clip, unsigned stream_idx);
+#include <condition_variable>
+#include <mutex>
+
+class JPEGFrameView;
+
+class Player {
+public:
+       Player(JPEGFrameView *destination);
+
+       void play_clip(const Clip &clip, unsigned stream_idx);
+
+private:
+       void thread_func();
+
+       JPEGFrameView *destination;
+
+       std::mutex mu;
+       Clip current_clip;  // Under mu.
+       unsigned current_stream_idx;  // Under mu.
+
+       enum { PAUSED, PLAYING } cue_state = PAUSED;  // Under cue_state_mu.
+       std::mutex cue_state_mu;
+       std::condition_variable cue_is_playing;
+};
 
 #endif  // !defined(_PLAYER_H)