BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bsesequencer.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __BSE_SSEQUENCER_HH__
00003 #define __BSE_SSEQUENCER_HH__
00004 #include <bse/bsesong.hh>
00005 
00006 namespace Bse {
00007 
00011 class Sequencer {
00012   static Sequencer *singleton_;
00013   static Mutex      sequencer_mutex_;
00014   struct PollPool;
00015   uint64     stamp_;            // sequencer time (ahead of real time)
00016   SfiRing   *songs_;
00017   Cond       watch_cond_;
00018   PollPool  *poll_pool_;
00019   EventFd    event_fd_;
00020   std::thread thread_;
00021 private:
00022   void          sequencer_thread ();
00023   bool          pool_poll_Lm     (int timeout_ms);
00024   void          process_part_SL  (BsePart *part, double start_stamp, uint start_tick,
00025                                   uint tick_bound, /* start_tick + n_ticks */
00026                                   double stamps_per_tick, BseMidiReceiver *midi_receiver, uint midi_channel);
00027   void          process_track_SL (BseTrack *track, double start_stamp, uint start_tick,
00028                                   uint bound, /* start_tick + n_ticks */
00029                                   double stamps_per_tick, BseMidiReceiver *midi_receiver);
00030   void          process_song_SL  (BseSong *song, uint n_ticks);
00031   bool          process_song_unlooped_SL (BseSong *song, uint n_ticks, bool force_active_tracks);
00032   explicit      Sequencer       ();
00033 protected:
00034   static void   _init_threaded  ();
00035 public:
00036   void          add_io_watch    (uint n_pfds, const GPollFD *pfds, BseIOWatch watch_func, void *watch_data);
00037   void          remove_io_watch (BseIOWatch watch_func, void *watch_data);
00038   void          start_song      (BseSong *song, uint64 start_stamp);
00039   void          remove_song     (BseSong *song);
00040   bool          thread_lagging  (uint n_blocks);
00041   void          wakeup          ()      { event_fd_.wakeup(); }
00042   static Mutex& sequencer_mutex ()      { return sequencer_mutex_; }
00043   static Sequencer& instance    ()      { return *singleton_; }
00044 };
00045 
00046 #define BSE_SEQUENCER_LOCK()    (Bse::Sequencer::sequencer_mutex().lock())
00047 #define BSE_SEQUENCER_UNLOCK()  (Bse::Sequencer::sequencer_mutex().unlock())
00048 
00049 } // Bse
00050 
00051 #endif // __BSE_SSEQUENCER_HH__
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines