2008-09-19 00:47:49 +00:00
|
|
|
/* This file is part of Evoral.
|
|
|
|
|
* Copyright (C) 2008 Dave Robillard <http://drobilla.net>
|
|
|
|
|
* Copyright (C) 2000-2008 Paul Davis
|
|
|
|
|
*
|
|
|
|
|
* Evoral is free software; you can redistribute it and/or modify it under the
|
|
|
|
|
* terms of the GNU General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
|
* version.
|
|
|
|
|
*
|
|
|
|
|
* Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
*/
|
|
|
|
|
|
2008-12-21 20:36:15 +00:00
|
|
|
#include "evoral/Event.hpp"
|
2008-09-19 00:47:49 +00:00
|
|
|
|
|
|
|
|
namespace Evoral {
|
|
|
|
|
|
2008-09-22 16:28:02 +00:00
|
|
|
#ifdef EVORAL_EVENT_ALLOC
|
|
|
|
|
|
2009-02-02 02:36:05 +00:00
|
|
|
template<typename T>
|
|
|
|
|
Event<T>::Event(uint32_t tid, T t, uint32_t s, uint8_t* b, bool owns_buf)
|
2008-09-22 16:28:02 +00:00
|
|
|
: _type(tid)
|
|
|
|
|
, _time(t)
|
2008-09-19 00:47:49 +00:00
|
|
|
, _size(s)
|
2009-02-02 02:36:05 +00:00
|
|
|
, _buf(b)
|
|
|
|
|
, _owns_buf(owns_buf)
|
2008-09-19 00:47:49 +00:00
|
|
|
{
|
2009-02-02 02:36:05 +00:00
|
|
|
if (owns_buf) {
|
|
|
|
|
_buf = (uint8_t*)malloc(_size);
|
2008-09-19 00:47:49 +00:00
|
|
|
if (b) {
|
2009-02-02 02:36:05 +00:00
|
|
|
memcpy(_buf, b, _size);
|
2008-09-19 00:47:49 +00:00
|
|
|
} else {
|
2009-02-02 02:36:05 +00:00
|
|
|
memset(_buf, 0, _size);
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-02 02:36:05 +00:00
|
|
|
template<typename T>
|
|
|
|
|
Event<T>::Event(const Event& copy, bool owns_buf)
|
2008-09-22 16:28:02 +00:00
|
|
|
: _type(copy._type)
|
|
|
|
|
, _time(copy._time)
|
2008-09-19 00:47:49 +00:00
|
|
|
, _size(copy._size)
|
2009-02-02 02:36:05 +00:00
|
|
|
, _buf(copy._buf)
|
|
|
|
|
, _owns_buf(owns_buf)
|
2008-09-19 00:47:49 +00:00
|
|
|
{
|
2009-02-02 02:36:05 +00:00
|
|
|
if (owns_buf) {
|
|
|
|
|
_buf = (uint8_t*)malloc(_size);
|
|
|
|
|
if (copy._buf) {
|
|
|
|
|
memcpy(_buf, copy._buf, _size);
|
2008-09-19 00:47:49 +00:00
|
|
|
} else {
|
2009-02-02 02:36:05 +00:00
|
|
|
memset(_buf, 0, _size);
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-02 02:36:05 +00:00
|
|
|
template<typename T>
|
|
|
|
|
Event<T>::~Event() {
|
|
|
|
|
if (_owns_buf) {
|
|
|
|
|
free(_buf);
|
2008-09-19 00:47:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-22 16:28:02 +00:00
|
|
|
#endif // EVORAL_EVENT_ALLOC
|
2008-09-19 00:47:49 +00:00
|
|
|
|
2009-02-02 02:36:05 +00:00
|
|
|
template class Event<double>;
|
|
|
|
|
|
|
|
|
|
} // namespace Evoral
|
2008-09-19 00:47:49 +00:00
|
|
|
|