diff options
-rw-r--r-- | gtk2_ardour/automation_streamview.cc | 6 | ||||
-rw-r--r-- | gtk2_ardour/automation_time_axis.cc | 9 | ||||
-rw-r--r-- | gtk2_ardour/midi_channel_selector.cc | 10 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 52 | ||||
-rw-r--r-- | gtk2_ardour/midi_streamview.cc | 43 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 3 | ||||
-rw-r--r-- | libs/ardour/midi_diskstream.cc | 43 | ||||
-rw-r--r-- | libs/ardour/midi_port.cc | 4 | ||||
-rw-r--r-- | libs/ardour/midi_ring_buffer.cc | 2 | ||||
-rw-r--r-- | libs/ardour/midi_stretch.cc | 11 | ||||
-rw-r--r-- | libs/evoral/evoral/EventRingBuffer.hpp | 2 |
11 files changed, 75 insertions, 110 deletions
diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index 65df722e3c..7b2c1ab751 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -249,9 +249,9 @@ AutomationStreamView::interpolation () const } AutomationRegionView* v = dynamic_cast<AutomationRegionView*> (region_views.front()); - assert (v); - - return v->line()->the_list()->interpolation (); + if (v) { + return v->line()->the_list()->interpolation (); + } } /** Clear all automation displayed in this view */ diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 8b090cf001..9fa412652d 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -192,8 +192,9 @@ AutomationTimeAxisView::AutomationTimeAxisView ( /* ask for notifications of any new RegionViews */ if (show_regions) { - assert(_view); - _view->attach (); + if (_view) { + _view->attach (); + } } else { /* no regions, just a single line for the entire track (e.g. bus gain) */ @@ -706,9 +707,7 @@ AutomationTimeAxisView::clear_lines () void AutomationTimeAxisView::add_line (boost::shared_ptr<AutomationLine> line) { - assert(line); - assert(!_line); - if (_control) { + if (_control && line) { assert(line->the_list() == _control->list()); _control->alist()->automation_state_changed.connect ( diff --git a/gtk2_ardour/midi_channel_selector.cc b/gtk2_ardour/midi_channel_selector.cc index cdaf42e51f..6770f0e60d 100644 --- a/gtk2_ardour/midi_channel_selector.cc +++ b/gtk2_ardour/midi_channel_selector.cc @@ -17,7 +17,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <algorithm> #include <sstream> + #include "midi_channel_selector.h" #include "gtkmm/separator.h" #include "i18n.h" @@ -31,10 +33,10 @@ MidiChannelSelector::MidiChannelSelector(int n_rows, int n_columns, int start_ro : Table(n_rows, n_columns, true) , _recursion_counter(0) { - assert(n_rows >= 4); - assert(n_rows >= start_row + 4); - assert(n_columns >=4); - assert(n_columns >= start_column + 4); + n_rows = std::max(4, n_rows); + n_rows = std::max(4, start_row + 4); + n_columns = std::max(4, n_columns); + n_columns = std::max(4, start_column + 4); property_column_spacing() = 0; property_row_spacing() = 0; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 54a0bc4f2d..48f942f2b5 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -18,7 +18,6 @@ */ #include <cmath> -#include <cassert> #include <algorithm> #include <ostream> @@ -915,13 +914,14 @@ MidiRegionView::show_list_editor () void MidiRegionView::create_note_at (framepos_t t, double y, double length, bool snap_t) { + if (length < 2 * DBL_EPSILON) { + return; + } + MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview); MidiStreamView* const view = mtv->midi_view(); - double note = view->y_to_note(y); - - assert(note >= 0.0); - assert(note <= 127.0); + const double note = view->y_to_note(y); // Start of note in frames relative to region start if (snap_t) { @@ -929,13 +929,11 @@ MidiRegionView::create_note_at (framepos_t t, double y, double length, bool snap t = snap_frame_to_grid_underneath (t, grid_frames); } - assert (t >= 0); - assert (length != 0); - - const boost::shared_ptr<NoteType> new_note (new NoteType (mtv->get_channel_for_add (), - region_frames_to_region_beats(t + _region->start()), - length, - (uint8_t)note, 0x40)); + const boost::shared_ptr<NoteType> new_note ( + new NoteType (mtv->get_channel_for_add (), + region_frames_to_region_beats(t + _region->start()), + length, + (uint8_t)note, 0x40)); if (_model->contains (new_note)) { return; @@ -1285,7 +1283,6 @@ MidiRegionView::display_sysexes() boost::static_pointer_cast<const Evoral::MIDIEvent<Evoral::MusicalTime> > (*i); Evoral::MusicalTime time = (*i)->time(); - assert (time >= 0); if (mev) { if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { @@ -1367,7 +1364,6 @@ void MidiRegionView::reset_width_dependent_items (double pixel_width) { RegionView::reset_width_dependent_items(pixel_width); - assert(_pixel_width == pixel_width); if (_enable_display) { redisplay_model(); @@ -1495,9 +1491,11 @@ MidiRegionView::add_ghost (TimeAxisView& tv) void MidiRegionView::begin_write() { - assert(!_active_notes); + if (_active_notes) { + delete[] _active_notes; + } _active_notes = new CanvasNote*[128]; - for (unsigned i=0; i < 128; ++i) { + for (unsigned i = 0; i < 128; ++i) { _active_notes[i] = 0; } } @@ -1657,8 +1655,7 @@ MidiRegionView::update_note (CanvasNote* ev, bool update_ghost_regions) ev->property_y2() = y1 + floor(midi_stream_view()->note_height()); if (note->length() == 0) { - if (_active_notes) { - assert(note->note() < 128); + if (_active_notes && note->note() < 128) { // If this note is already active there's a stuck note, // finish the old note rectangle if (_active_notes[note->note()]) { @@ -1712,9 +1709,6 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible) { CanvasNoteEvent* event = 0; - assert(note->time() >= 0); - assert(midi_view()->note_mode() == Sustained || midi_view()->note_mode() == Percussive); - //ArdourCanvas::Group* const group = (ArdourCanvas::Group*) get_canvas_group(); if (midi_view()->note_mode() == Sustained) { @@ -1816,8 +1810,6 @@ MidiRegionView::step_sustain (Evoral::MusicalTime beats) void MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const string& displaytext, bool active_channel) { - assert (patch->time() >= 0); - framecnt_t region_frames = source_beats_to_region_frames (patch->time()); const double x = trackview.editor().frame_to_pixel (region_frames); @@ -1868,7 +1860,10 @@ MidiRegionView::get_patch_key_at (double time, uint8_t channel, MIDI::Name::Patc key.bank_number = key.program_number = 0; } - assert (key.is_sane()); + if (!key.is_sane()) { + error << string_compose(_("insane MIDI patch key %1:%2"), + key.bank_number, key.program_number) << endmsg; + } } void @@ -2436,11 +2431,9 @@ MidiRegionView::move_selection(double dx, double dy, double cumulative_dy) void MidiRegionView::note_dropped(CanvasNoteEvent *, frameoffset_t dt, int8_t dnote) { - assert (!_selection.empty()); - uint8_t lowest_note_in_selection = 127; uint8_t highest_note_in_selection = 0; - uint8_t highest_note_difference = 0; + uint8_t highest_note_difference = 0; // find highest and lowest notes first @@ -3714,11 +3707,10 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w) for (MidiBuffer::iterator i = buf->begin(); i != buf->end(); ++i) { Evoral::MIDIEvent<MidiBuffer::TimeType> const ev (*i, false); - assert (ev.buffer ()); - if(ev.is_channel_event()) { + if (ev.is_channel_event()) { if (_last_channel_mode == FilterChannels) { - if(((uint16_t(1) << ev.channel()) & _last_channel_selection) == 0) { + if (((uint16_t(1) << ev.channel()) & _last_channel_selection) == 0) { continue; } } diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 843ca1bfc2..90e6147763 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -17,7 +17,6 @@ */ #include <cmath> -#include <cassert> #include <utility> #include <gtkmm.h> @@ -49,6 +48,8 @@ #include "simplerect.h" #include "utils.h" +#include "i18n.h" + using namespace std; using namespace ARDOUR; using namespace PBD; @@ -400,7 +401,6 @@ MidiStreamView::apply_note_range_to_regions () void MidiStreamView::update_note_range(uint8_t note_num) { - assert(note_num <= 127); _data_note_min = min(_data_note_min, note_num); _data_note_max = max(_data_note_max, note_num); } @@ -461,21 +461,23 @@ MidiStreamView::setup_rec_box () boost::shared_ptr<MidiRegion> region (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (sources, plist, false))); - - assert(region); - region->set_start (_trackview.track()->current_capture_start() - _trackview.track()->get_capture_start_frame (0)); - region->set_position (_trackview.track()->current_capture_start()); - RegionView* rv = add_region_view_internal (region, false); - MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv); - mrv->begin_write (); - - rec_regions.push_back (make_pair (region, rv)); - - // rec regions are destroyed in setup_rec_box - - /* we add the region later */ - - setup_new_rec_layer_time (region); + if (region) { + region->set_start (_trackview.track()->current_capture_start() + - _trackview.track()->get_capture_start_frame (0)); + region->set_position (_trackview.track()->current_capture_start()); + RegionView* rv = add_region_view_internal (region, false); + MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv); + mrv->begin_write (); + + + /* rec region will be destroyed in setup_rec_box */ + rec_regions.push_back (make_pair (region, rv)); + + /* we add the region later */ + setup_new_rec_layer_time (region); + } else { + error << _("failed to create MIDI region") << endmsg; + } } /* start a new rec box */ @@ -486,8 +488,6 @@ MidiStreamView::setup_rec_box () gdouble const xend = xstart; uint32_t fill_color; - assert(_trackview.midi_track()->mode() == Normal); - fill_color = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); ArdourCanvas::SimpleRect * rec_rect = new Gnome::Canvas::SimpleRect (*_canvas_group); @@ -661,7 +661,8 @@ MidiStreamView::leave_internal_edit_mode () StreamView::leave_internal_edit_mode (); for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) { MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (*i); - assert (mrv); - mrv->clear_selection (); + if (mrv) { + mrv->clear_selection (); + } } } diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index c654c9cb84..82faf1890c 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -1078,9 +1078,6 @@ MidiTimeAxisView::route_active_changed () controls_base_unselected_name = "MidiTrackControlsBaseInactiveUnselected"; } } else { - - throw; // wha? - if (_route->active()) { controls_ebox.set_name ("BusControlsBaseUnselected"); controls_base_selected_name = "BusControlsBaseSelected"; diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index eb4aed91c6..63d70f707c 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -83,7 +83,9 @@ MidiDiskstream::MidiDiskstream (Session &sess, const string &name, Diskstream::F in_set_state = false; - assert(!destructive()); + if (destructive()) { + throw failed_constructor(); + } } MidiDiskstream::MidiDiskstream (Session& sess, const XMLNode& node) @@ -125,8 +127,6 @@ MidiDiskstream::init () _capture_buf = new MidiRingBuffer<framepos_t>(size); _n_channels = ChanCount(DataType::MIDI, 1); - - assert(recordable()); } MidiDiskstream::~MidiDiskstream () @@ -222,9 +222,9 @@ MidiDiskstream::find_and_use_playlist (const string& name) int MidiDiskstream::use_playlist (boost::shared_ptr<Playlist> playlist) { - assert(boost::dynamic_pointer_cast<MidiPlaylist>(playlist)); - - Diskstream::use_playlist(playlist); + if (boost::dynamic_pointer_cast<MidiPlaylist>(playlist)) { + Diskstream::use_playlist(playlist); + } return 0; } @@ -258,8 +258,6 @@ MidiDiskstream::use_new_playlist () int MidiDiskstream::use_copy_playlist () { - assert(midi_playlist()); - if (destructive()) { return 0; } @@ -286,10 +284,7 @@ MidiDiskstream::use_copy_playlist () int MidiDiskstream::set_destructive (bool yn) { - yn = 0; // stop pedantic gcc complaints about unused parameter - assert( ! destructive()); - assert( ! yn); - return -1; + return yn ? -1 : 0; } void @@ -356,7 +351,6 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, framecnt MidiBuffer& buf = sp->get_midi_buffer(nframes); for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) { const Evoral::MIDIEvent<MidiBuffer::TimeType> ev(*i, false); - assert(ev.buffer()); #ifndef NDEBUG if (DEBUG::MidiIO & PBD::debug_bits) { const uint8_t* __data = ev.buffer(); @@ -667,12 +661,11 @@ MidiDiskstream::do_refill () return 0; } - // At this point we... - assert(_playback_buf->write_space() > 0); // ... have something to write to, and - assert(file_frame <= max_framepos); // ... something to write + /* no space to write */ + if (_playback_buf->write_space() == 0) { + return 0; + } - // now calculate how much time is in the ringbuffer. - // and lets write as much as we need to get this to be midi_readahead; uint32_t frames_read = g_atomic_int_get(&_frames_read_from_ringbuffer); uint32_t frames_written = g_atomic_int_get(&_frames_written_to_ringbuffer); if ((frames_written - frames_read) >= midi_readahead) { @@ -714,8 +707,6 @@ MidiDiskstream::do_flush (RunContext /*context*/, bool force_flush) return 0; } - assert (!destructive()); - total = _session.transport_frame() - _write_source->last_write_end(); if (total == 0 || @@ -805,8 +796,6 @@ MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen } else { - assert(_write_source); - framecnt_t total_capture = 0; for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) { total_capture += (*ci)->frames; @@ -993,9 +982,6 @@ MidiDiskstream::finish_capture () return; } - // Why must we destroy? - assert(!destructive()); - CaptureInfo* ci = new CaptureInfo; ci->start = capture_start_frame; @@ -1023,8 +1009,6 @@ MidiDiskstream::set_record_enabled (bool yn) return; } - assert(!destructive()); - /* yes, i know that this not proof against race conditions, but its good enough. i think. */ @@ -1116,8 +1100,6 @@ MidiDiskstream::set_state (const XMLNode& node, int version) in_set_state = true; for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - assert ((*niter)->name() != IO::state_node_name); - if ((*niter)->name() == X_("CapturingSources")) { capture_pending_node = *niter; } @@ -1159,8 +1141,6 @@ MidiDiskstream::use_new_write_source (uint32_t n) return 1; } - assert(n == 0); - _write_source.reset(); try { @@ -1293,7 +1273,6 @@ void MidiDiskstream::get_playback (MidiBuffer& dst, framecnt_t nframes) { dst.clear(); - assert(dst.size() == 0); Location* loc = loop_location; diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 0856666159..cc72eabba4 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -47,8 +47,6 @@ MidiPort::cycle_start (pframes_t nframes) _buffer->clear (); - assert (_buffer->size () == 0); - if (sends_output ()) { jack_midi_clear_buffer (jack_port_get_buffer (_jack_port, nframes)); } @@ -68,8 +66,6 @@ MidiPort::get_midi_buffer (pframes_t nframes) void* jack_buffer = jack_port_get_buffer (_jack_port, nframes); const pframes_t event_count = jack_midi_get_event_count (jack_buffer); - assert (event_count < _buffer->capacity()); - /* suck all relevant MIDI events from the JACK MIDI port buffer into our MidiBuffer */ diff --git a/libs/ardour/midi_ring_buffer.cc b/libs/ardour/midi_ring_buffer.cc index 0f08247cb9..21f840af10 100644 --- a/libs/ardour/midi_ring_buffer.cc +++ b/libs/ardour/midi_ring_buffer.cc @@ -43,7 +43,6 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame } T ev_time; - Evoral::EventType ev_type; uint32_t ev_size; size_t count = 0; const size_t prefix_size = sizeof(T) + sizeof(Evoral::EventType) + sizeof(uint32_t); @@ -58,7 +57,6 @@ MidiRingBuffer<T>::read(MidiBuffer& dst, framepos_t start, framepos_t end, frame assert (this->peek (peekbuf, prefix_size)); ev_time = *((T*) peekbuf); - ev_type = *((Evoral::EventType*)(peekbuf + sizeof (T))); ev_size = *((uint32_t*)(peekbuf + sizeof(T) + sizeof (Evoral::EventType))); if (ev_time >= end) { diff --git a/libs/ardour/midi_stretch.cc b/libs/ardour/midi_stretch.cc index 1794d5ff93..38cab08ace 100644 --- a/libs/ardour/midi_stretch.cc +++ b/libs/ardour/midi_stretch.cc @@ -49,8 +49,9 @@ MidiStretch::run (boost::shared_ptr<Region> r, Progress*) char suffix[32]; boost::shared_ptr<MidiRegion> region = boost::dynamic_pointer_cast<MidiRegion>(r); - if (!region) + if (!region) { return -1; + } /* the name doesn't need to be super-precise, but allow for 2 fractional digits just to disambiguate close but not identical stretches. @@ -74,16 +75,16 @@ MidiStretch::run (boost::shared_ptr<Region> r, Progress*) if (make_new_sources (region, nsrcs, suffix)) return -1; - // FIXME: how to make a whole file region if it isn't? - //assert(region->whole_file()); - boost::shared_ptr<MidiSource> src = region->midi_source(0); src->load_model(); boost::shared_ptr<MidiModel> old_model = src->model(); boost::shared_ptr<MidiSource> new_src = boost::dynamic_pointer_cast<MidiSource>(nsrcs[0]); - assert(new_src); + if (!new_src) { + error << _("MIDI stretch created non-MIDI source") << endmsg; + return -1; + } Glib::Threads::Mutex::Lock sl (new_src->mutex ()); diff --git a/libs/evoral/evoral/EventRingBuffer.hpp b/libs/evoral/evoral/EventRingBuffer.hpp index 8fec622243..419f427f33 100644 --- a/libs/evoral/evoral/EventRingBuffer.hpp +++ b/libs/evoral/evoral/EventRingBuffer.hpp @@ -116,7 +116,7 @@ template<typename Time> inline uint32_t EventRingBuffer<Time>::write(Time time, EventType type, uint32_t size, const uint8_t* buf) { - if (write_space() < (sizeof(Time) + sizeof(EventType) + sizeof(uint32_t) + size)) { + if (!buf || write_space() < (sizeof(Time) + sizeof(EventType) + sizeof(uint32_t) + size)) { return 0; } else { PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&time, sizeof(Time)); |