29 return g_atomic_int_get (&_event_id_counter);
35 g_atomic_int_set (&_event_id_counter, n);
41 return g_atomic_int_add (&_event_id_counter, 1);
44 #ifdef EVORAL_EVENT_ALLOC
46 template<
typename Timestamp>
49 , _original_time(time)
57 _buf = (uint8_t*)malloc(_size);
59 memcpy(_buf, buf, _size);
61 memset(_buf, 0, _size);
66 template<
typename Timestamp>
72 , _original_time(time)
75 , _buf((uint8_t*)malloc(size))
79 memcpy(_buf, buf, _size);
82 template<
typename Timestamp>
83 Event<Timestamp>::Event(
const Event& copy,
bool owns_buf)
85 , _original_time(copy._original_time)
86 , _nominal_time(copy._nominal_time)
93 _buf = (uint8_t*)malloc(_size);
95 memcpy(_buf, copy._buf, _size);
97 memset(_buf, 0, _size);
102 template<
typename Timestamp>
103 Event<Timestamp>::~Event() {
109 template<
typename Timestamp>
110 const Event<Timestamp>&
111 Event<Timestamp>::operator=(
const Event& copy)
115 _original_time = copy._original_time;
116 _nominal_time = copy._nominal_time;
117 _owns_buf = copy._owns_buf;
120 if (copy._size > _size) {
121 _buf = (uint8_t*)::realloc(_buf, copy._size);
123 memcpy(_buf, copy._buf, copy._size);
136 template<
typename Timestamp>
138 Event<Timestamp>::set (
const uint8_t* buf, uint32_t size, Timestamp t)
142 _buf = (uint8_t*) ::realloc(_buf, size);
144 memcpy (_buf, buf, size);
150 _buf =
const_cast<uint8_t*
> (buf);
158 template<
typename Timestamp>
160 Event<Timestamp>::set_time (Timestamp t)
165 template<
typename Timestamp>
167 Event<Timestamp>::set_original_time (Timestamp t)
172 #endif // EVORAL_EVENT_ALLOC
174 template class Event<Evoral::Beats>;
175 template class Event<double>;
176 template class Event<int64_t>;
LIBEVORAL_API event_id_t event_id_counter()
LIBEVORAL_API void init_event_id_counter(event_id_t n)
LIBEVORAL_API event_id_t next_event_id()
Event(EventType type=0, Time time=Time(), uint32_t size=0, uint8_t *buf=NULL, bool alloc=false)
static event_id_t _event_id_counter