13
0

Fix pollution of global namespace by Evoral.

git-svn-id: svn://localhost/ardour2/branches/3.0@3947 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-10-13 02:43:14 +00:00
parent 8b951bb9ee
commit 1514039689
12 changed files with 64 additions and 63 deletions

View File

@ -47,7 +47,7 @@ public:
, _channel_mask(0x0000FFFF)
{}
inline bool read_prefix(EventTime* time, EventType* type, uint32_t* size);
inline bool read_prefix(Evoral::EventTime* time, Evoral::EventType* type, uint32_t* size);
inline bool read_contents(uint32_t size, uint8_t* buf);
size_t read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t offset=0);
@ -88,11 +88,11 @@ private:
* by a call to read_contents (or the read pointer will be garabage).
*/
inline bool
MidiRingBuffer::read_prefix(EventTime* time, EventType* type, uint32_t* size)
MidiRingBuffer::read_prefix(Evoral::EventTime* time, Evoral::EventType* type, uint32_t* size)
{
bool success = Evoral::EventRingBuffer::full_read(sizeof(EventTime), (uint8_t*)time);
bool success = Evoral::EventRingBuffer::full_read(sizeof(Evoral::EventTime), (uint8_t*)time);
if (success)
success = Evoral::EventRingBuffer::full_read(sizeof(EventType), (uint8_t*)type);
success = Evoral::EventRingBuffer::full_read(sizeof(Evoral::EventType), (uint8_t*)type);
if (success)
success = Evoral::EventRingBuffer::full_read(sizeof(uint32_t), (uint8_t*)size);
@ -123,17 +123,17 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t
return 0;
}
EventTime ev_time;
EventType ev_type;
uint32_t ev_size;
Evoral::EventTime ev_time;
Evoral::EventType ev_type;
uint32_t ev_size;
size_t count = 0;
//std::cerr << "MRB read " << start << " .. " << end << " + " << offset << std::endl;
while (read_space() >= sizeof(EventTime) + sizeof(EventType) + sizeof(uint32_t)) {
while (read_space() >= sizeof(Evoral::EventTime) + sizeof(Evoral::EventType) + sizeof(uint32_t)) {
full_peek(sizeof(EventTime), (uint8_t*)&ev_time);
full_peek(sizeof(Evoral::EventTime), (uint8_t*)&ev_time);
if (ev_time > end) {
//std::cerr << "MRB: PAST END (" << ev_time << " : " << end << ")" << std::endl;

View File

@ -197,9 +197,9 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
{
_write_data_count = 0;
EventTime time;
EventType type;
uint32_t size;
Evoral::EventTime time;
Evoral::EventType type;
uint32_t size;
size_t buf_capacity = 4;
uint8_t* buf = (uint8_t*)malloc(buf_capacity);
@ -643,7 +643,7 @@ SMFSource::load_model(bool lock, bool force_reload)
if (ret > 0) { // didn't skip (meta) event
// make ev.time absolute time in frames
ev.time() = time * frames_per_beat / (EventTime)ppqn();
ev.time() = time * frames_per_beat / (Evoral::EventTime)ppqn();
ev.set_event_type(EventTypeMap::instance().midi_event_type(buf[0]));
_model->append(ev);
}

View File

@ -36,8 +36,8 @@ public:
Control(const Parameter& parameter, boost::shared_ptr<ControlList>);
virtual ~Control() {}
virtual void set_float(float val, bool to_list=false, nframes_t frame=0);
virtual float get_float(bool from_list=false, nframes_t frame=0) const;
virtual void set_float(float val, bool to_list=false, FrameTime frame=0);
virtual float get_float(bool from_list=false, FrameTime frame=0) const;
virtual float user_float() const;
void set_list(boost::shared_ptr<ControlList>);

View File

@ -56,7 +56,7 @@ public:
virtual void add_control(boost::shared_ptr<Control>);
bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const;
bool find_next_event(FrameTime start, FrameTime end, ControlEvent& ev) const;
virtual bool empty() const { return _controls.size() == 0; }
virtual void clear();

View File

@ -43,7 +43,7 @@ public:
EventTime last_event_time() const { return _last_ev_time; }
void begin_write(nframes_t start_time);
void begin_write(FrameTime start_time);
void append_event_unlocked(uint32_t delta_t, const Evoral::Event& ev);
void end_write();

View File

@ -198,7 +198,7 @@ private:
ControlLists _dirty_controls;
const const_iterator _end_iter;
mutable nframes_t _next_read;
mutable FrameTime _next_read;
bool _percussive;
uint8_t _lowest_note;

View File

@ -21,8 +21,10 @@
#include <stdint.h>
namespace Evoral {
/** Frame count (i.e. length of time in audio frames) */
typedef uint32_t nframes_t;
typedef uint32_t FrameTime;
/** Time-stamp of an event */
typedef double timestamp_t;
@ -39,4 +41,6 @@ typedef double EventLength;
/** Type of an event (opaque, mapped by application) */
typedef uint32_t EventType;
} // namespace Evoral
#endif // EVORAL_TYPES_HPP

View File

@ -35,7 +35,7 @@ Control::Control(const Parameter& parameter, boost::shared_ptr<ControlList> list
/** Get the currently effective value (ie the one that corresponds to current output)
*/
float
Control::get_float(bool from_list, nframes_t frame) const
Control::get_float(bool from_list, FrameTime frame) const
{
if (from_list)
return _list->eval(frame);
@ -45,7 +45,7 @@ Control::get_float(bool from_list, nframes_t frame) const
void
Control::set_float(float value, bool to_list, nframes_t frame)
Control::set_float(float value, bool to_list, FrameTime frame)
{
_user_value = value;

View File

@ -70,11 +70,11 @@ ControlSet::control (const Parameter& parameter, bool create_if_missing)
}
bool
ControlSet::find_next_event (nframes_t now, nframes_t end, ControlEvent& next_event) const
ControlSet::find_next_event (FrameTime now, FrameTime end, ControlEvent& next_event) const
{
Controls::const_iterator li;
next_event.when = std::numeric_limits<nframes_t>::max();
next_event.when = std::numeric_limits<FrameTime>::max();
for (li = _controls.begin(); li != _controls.end(); ++li) {
ControlList::const_iterator i;
@ -95,7 +95,7 @@ ControlSet::find_next_event (nframes_t now, nframes_t end, ControlEvent& next_ev
}
}
return next_event.when != std::numeric_limits<nframes_t>::max();
return next_event.when != std::numeric_limits<FrameTime>::max();
}
void

View File

@ -181,29 +181,6 @@ SMF::write_footer()
fflush(_fd);
}
/** Returns the offset of the first event in the file with a time past @a start,
* relative to the start of the source.
*
* Returns -1 if not found.
*/
/*
long
SMF::find_first_event_after(nframes_t start)
{
// FIXME: obviously this is slooow
fseek(_fd, _header_size, 0);
while ( ! feof(_fd) ) {
const uint32_t delta_time = read_var_len();
if (delta_time > start)
return delta_time;
}
return -1;
}
*/
/** Read an event from the current position in file.
*
@ -303,7 +280,7 @@ SMF::append_event_unlocked(uint32_t delta_t, const Evoral::Event& ev)
}
void
SMF::begin_write(nframes_t start_frame)
SMF::begin_write(FrameTime start_frame)
{
_last_ev_time = 0;
fseek(_fd, _header_size, SEEK_SET);

View File

@ -342,7 +342,7 @@ Sequence::read(EventSink& dst, timestamp_t start, timedur_t nframes, timestamp_t
debugout << "Using cached iterator at " << _next_read << endl;
}
_next_read = (nframes_t) floor (start + nframes);
_next_read = (FrameTime) floor (start + nframes);
while (_read_iter != end() && _read_iter->time() < start + nframes) {
assert(_read_iter->size() > 0);

View File

@ -1,30 +1,46 @@
#!/usr/bin/env python
import Params
import autowaf
# Version of this package (even if built as a child)
EVORAL_VERSION = '0.0.0'
# Library version (UNIX style major, minor, micro)
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
# Version history:
# 0.0.0 = 0,0,0
EVORAL_LIB_VERSION = '0.0.0'
# Variables for 'waf dist'
VERSION = '0.0.1'
APPNAME = 'evoral'
VERSION = EVORAL_VERSION
# Mandatory variables
srcdir = '.'
blddir = 'build'
def set_options(opt):
autowaf.set_options(opt)
opt.tool_options('compiler_cc')
opt.tool_options('compiler_cxx')
def configure(conf):
if not conf.env['GLIBMM']:
conf.check_pkg('glibmm-2.4', destvar='GLIBMM', vnum='2.16.0', mandatory=True)
if not conf.env['GTHREAD']:
conf.check_pkg('gthread-2.0', destvar='GTHREAD', vnum='2.16.0', mandatory=True)
if not conf.env['CXX']:
conf.check_tool('compiler_cxx')
autowaf.configure(conf)
autowaf.check_tool(conf, 'compiler_cxx')
autowaf.check_pkg(conf, 'glibmm-2.4', destvar='GLIBMM', vnum='2.16.0', mandatory=True)
autowaf.check_pkg(conf, 'gthread-2.0', destvar='GTHREAD', vnum='2.16.0', mandatory=True)
def build(bld):
# Headers (evoral)
install_files('PREFIX', 'include/evoral', 'evoral/*.hpp')
# Headers
#install_files('PREFIX', 'include/evoral', 'evoral/*.h')
#install_files('PREFIX', 'include/evoral', 'evoral/*.hpp')
# Library (src)
# Pkgconfig file
#autowaf.build_pc(bld, 'EVORAL', EVORAL_VERSION, 'GLIBMM GTHREAD')
# Library
obj = bld.create_obj('cpp', 'shlib')
obj.source = '''
src/Control.cpp
@ -38,17 +54,21 @@ def build(bld):
src/SMFReader.cpp
src/Sequence.cpp
'''
obj.includes = '..'
obj.includes = ['.']
obj.name = 'libevoral'
obj.target = 'evoral'
obj.uselib = 'GLIBMM GTHREAD'
obj.vnum = '0.0.0'
obj.vnum = EVORAL_LIB_VERSION
obj.inst_var = 0
# Test (test)
obj = bld.create_obj('cpp', 'program')
# Unit tests
obj = bld.create_obj('cpp', 'program')
obj.source = 'test/sequence.cpp'
obj.includes = '..'
obj.uselib_local = 'libevoral'
obj.target = 'sequence'
obj.inst_var = 0
def shutdown():
autowaf.shutdown()