BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __GSL_COMMON_H__ 00003 #define __GSL_COMMON_H__ 00004 #include <bse/gsldefs.hh> 00005 #include <bse/bseenums.hh> 00006 G_BEGIN_DECLS 00007 /* --- initialization --- */ 00008 void gsl_init (void); 00009 00010 /* --- misc --- */ 00011 const gchar* gsl_byte_order_to_string (guint byte_order); 00012 guint gsl_byte_order_from_string (const gchar *string); 00013 BseErrorType gsl_error_from_errno (gint sys_errno, 00014 BseErrorType fallback); 00015 BseErrorType gsl_error_select (guint n_errors, 00016 BseErrorType first_error, 00017 ...); 00018 BseErrorType gsl_file_check (const gchar *file_name, 00019 const gchar *mode); 00020 00021 00022 /* --- progress notification --- */ 00023 typedef struct _GslProgressState GslProgressState; 00024 typedef guint (*GslProgressFunc) (gpointer data, 00025 gfloat pval, /* -1, 0..100 */ 00026 const gchar *detail, 00027 GslProgressState *pstate); 00028 struct _GslProgressState 00029 { 00030 uint wipe_length; 00031 int precision; 00032 gfloat pval, epsilon; 00033 gpointer pdata; 00034 GslProgressFunc pfunc; 00035 }; 00036 GslProgressState gsl_progress_state (gpointer data, 00037 GslProgressFunc pfunc, 00038 guint precision); 00039 void gsl_progress_notify (GslProgressState *pstate, 00040 gfloat pval, 00041 const gchar *detail_format, 00042 ...); 00043 void gsl_progress_wipe (GslProgressState *pstate); 00044 guint gsl_progress_printerr (gpointer message, 00045 gfloat pval, 00046 const gchar *detail, 00047 GslProgressState *pstate); 00048 00049 00050 /* --- implementation details --- */ 00051 void _gsl_init_fd_pool (void); 00052 void _gsl_init_data_caches (void); 00053 void _gsl_init_loader_gslwave (void); 00054 void _gsl_init_loader_aiff (void); 00055 void _gsl_init_loader_wav (void); 00056 void _gsl_init_loader_oggvorbis (void); 00057 void _gsl_init_loader_mad (void); 00058 void bse_init_loader_gus_patch (void); 00059 void bse_init_loader_flac (void); 00060 #define GSL_N_IO_RETRIES (5) 00061 G_END_DECLS 00062 00063 00064 namespace Bse { 00065 00066 // == TickStamp == 00067 class TickStamp { 00068 static Rapicorn::Atomic<uint64> global_tick_stamp; 00069 protected: 00070 static void _init_forgsl (); 00071 public: 00072 class Wakeup : public std::enable_shared_from_this<Wakeup> { 00073 std::function<void()> wakeup_; 00074 uint64 awake_stamp_; 00075 protected: 00076 explicit Wakeup (const std::function<void()> &wakeup); 00077 static void _emit_wakeups (uint64 wakeup_stamp); 00078 public: 00079 void awake_after (uint64 stamp); 00080 void awake_before (uint64 stamp); 00081 }; 00082 typedef std::shared_ptr<Wakeup> WakeupP; 00083 struct Update { 00084 uint64 tick_stamp; 00085 uint64 system_time; 00086 }; 00087 static Update get_last (); 00088 static WakeupP create_wakeup (const std::function<void()> &wakeup); 00089 static inline uint64 current () { return global_tick_stamp; } 00090 static inline uint64 max_stamp () { return 18446744073709551615LLU; } 00091 static void _increment (); 00092 static void _set_leap (uint64 ticks); 00093 }; 00094 typedef TickStamp::WakeupP TickStampWakeupP; 00095 00096 } // Bse 00097 00098 00099 #endif /* __GSL_COMMON_H__ */