Fixed MIDI crash bug.
Added some asserts to gtkmm2ext that hopefully may catch a bug I might have possibly seen once or twice, probably. Fixed uninitialized value in time_axis_view.cc. git-svn-id: svn://localhost/ardour2/trunk@1958 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ca40990444
commit
9091ba932d
@ -91,8 +91,8 @@ MidiRegionView::init (Gdk::Color& basic_color, bool wfd)
|
||||
midi_region()->midi_source(0)->load_model();
|
||||
|
||||
begin_write();
|
||||
for (size_t i=0; i < midi_region()->midi_source(0)->model().n_events(); ++i)
|
||||
add_event(midi_region()->midi_source(0)->model().event_at(i));
|
||||
for (size_t i=0; i < midi_region()->midi_source(0)->model()->n_events(); ++i)
|
||||
add_event(midi_region()->midi_source(0)->model()->event_at(i));
|
||||
end_write();
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ MidiStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait
|
||||
|
||||
/* display events */
|
||||
region_view->begin_write();
|
||||
for (size_t i=0; i < region->midi_source(0)->model().n_events(); ++i)
|
||||
region_view->add_event(region->midi_source(0)->model().event_at(i));
|
||||
for (size_t i=0; i < region->midi_source(0)->model()->n_events(); ++i)
|
||||
region_view->add_event(region->midi_source(0)->model()->event_at(i));
|
||||
region_view->end_write();
|
||||
|
||||
/* catch regionview going away */
|
||||
|
@ -71,6 +71,7 @@ bool TimeAxisView::need_size_info = true;
|
||||
TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas)
|
||||
: AxisView (sess),
|
||||
editor (ed),
|
||||
height_style(Small),
|
||||
y_position(0),
|
||||
order(0),
|
||||
controls_table (2, 8)
|
||||
|
@ -72,7 +72,7 @@ class MidiSource : public Source
|
||||
virtual void load_model(bool lock=true) = 0;
|
||||
virtual void destroy_model() = 0;
|
||||
|
||||
MidiModel& model() { return _model; }
|
||||
MidiModel* model() { return _model; }
|
||||
|
||||
protected:
|
||||
virtual nframes_t read_unlocked (MidiRingBuffer& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset) const = 0;
|
||||
@ -83,7 +83,7 @@ class MidiSource : public Source
|
||||
mutable uint32_t _read_data_count; ///< modified in read()
|
||||
mutable uint32_t _write_data_count; ///< modified in write()
|
||||
|
||||
MidiModel _model;
|
||||
MidiModel* _model;
|
||||
|
||||
private:
|
||||
bool file_changed (string path);
|
||||
|
@ -59,8 +59,11 @@ namespace ARDOUR {
|
||||
typedef uint64_t microseconds_t;
|
||||
typedef uint32_t nframes_t;
|
||||
|
||||
typedef jack_midi_event_t MidiEvent;
|
||||
typedef unsigned char Byte;
|
||||
typedef unsigned char Byte;
|
||||
|
||||
struct MidiEvent : public jack_midi_event_t {
|
||||
MidiEvent() { time = 0; size = 0; buffer = NULL; }
|
||||
};
|
||||
|
||||
enum IOChange {
|
||||
NoChange = 0,
|
||||
|
@ -44,6 +44,7 @@ sigc::signal<void,MidiSource *> MidiSource::MidiSourceCreated;
|
||||
|
||||
MidiSource::MidiSource (Session& s, string name)
|
||||
: Source (s, name, DataType::MIDI)
|
||||
, _model(new MidiModel())
|
||||
{
|
||||
_read_data_count = 0;
|
||||
_write_data_count = 0;
|
||||
@ -51,6 +52,7 @@ MidiSource::MidiSource (Session& s, string name)
|
||||
|
||||
MidiSource::MidiSource (Session& s, const XMLNode& node)
|
||||
: Source (s, node)
|
||||
, _model(new MidiModel())
|
||||
{
|
||||
_read_data_count = 0;
|
||||
_write_data_count = 0;
|
||||
@ -62,6 +64,7 @@ MidiSource::MidiSource (Session& s, const XMLNode& node)
|
||||
|
||||
MidiSource::~MidiSource ()
|
||||
{
|
||||
delete _model;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
|
@ -259,6 +259,7 @@ SMFSource::read_event(MidiEvent& ev) const
|
||||
}
|
||||
|
||||
uint32_t delta_time = read_var_len();
|
||||
assert(!feof(_fd));
|
||||
int status = fgetc(_fd);
|
||||
assert(status != EOF); // FIXME die gracefully
|
||||
if (status == 0xFF) {
|
||||
@ -273,11 +274,15 @@ SMFSource::read_event(MidiEvent& ev) const
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ev.time = delta_time;
|
||||
ev.size = midi_event_size((unsigned char)status) + 1;
|
||||
|
||||
if (ev.buffer == NULL)
|
||||
ev.buffer = (Byte*)malloc(sizeof(Byte) * ev.size);
|
||||
|
||||
ev.buffer[0] = (unsigned char)status;
|
||||
ev.size = midi_event_size(ev.buffer[0]) + 1;
|
||||
fread(ev.buffer+1, 1, ev.size - 1, _fd);
|
||||
ev.time = delta_time;
|
||||
|
||||
/*printf("SMF - read event, delta = %u, size = %zu, data = ",
|
||||
delta_time, ev.size);
|
||||
@ -393,7 +398,7 @@ SMFSource::write_unlocked (MidiRingBuffer& src, nframes_t cnt)
|
||||
const nframes_t oldlen = _length;
|
||||
update_length(oldlen, cnt);
|
||||
|
||||
_model.append(buf);
|
||||
_model->append(buf);
|
||||
|
||||
ViewDataRangeReady (buf_ptr, oldlen, cnt); /* EMIT SIGNAL */
|
||||
|
||||
@ -777,8 +782,9 @@ SMFSource::load_model(bool lock)
|
||||
if (lock)
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
_model.clear();
|
||||
|
||||
destroy_model();
|
||||
_model = new MidiModel();
|
||||
|
||||
fseek(_fd, _header_size, 0);
|
||||
|
||||
nframes_t time = 0;
|
||||
@ -789,14 +795,17 @@ SMFSource::load_model(bool lock)
|
||||
time += ev.time;
|
||||
ev.time = time;
|
||||
if (ret > 0) { // didn't skip (meta) event
|
||||
_model.append(ev);
|
||||
cerr << "ADDING EVENT TO MODEL: " << ev.time << endl;
|
||||
_model->append(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SMFSource::destroy_model()
|
||||
{
|
||||
_model.clear();
|
||||
delete _model;
|
||||
_model = NULL;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@ -429,6 +430,9 @@ UI::toggle_errors ()
|
||||
void
|
||||
UI::display_message (const char *prefix, gint prefix_len, RefPtr<TextBuffer::Tag> ptag, RefPtr<TextBuffer::Tag> mtag, const char *msg)
|
||||
{
|
||||
assert(ptag);
|
||||
assert(mtag);
|
||||
|
||||
RefPtr<TextBuffer> buffer (errors->text().get_buffer());
|
||||
|
||||
buffer->insert_with_tag(buffer->end(), prefix, ptag);
|
||||
|
Loading…
Reference in New Issue
Block a user