13
0

use new macros to cleanup #ifndef NDEBUG as much as possible (libs edition)

This commit is contained in:
Paul Davis 2022-06-21 21:46:54 -06:00
parent 0004ca2c41
commit 0d9656ef82
14 changed files with 49 additions and 91 deletions

View File

@ -1506,10 +1506,7 @@ DiskReader::get_midi_playback (MidiBuffer& dst, samplepos_t start_sample, sample
} else {
DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("playback buffer read, from %1 to %2 (%3)\n", start_sample, end_sample, nframes));
#ifndef NDEBUG
size_t events_read =
#endif
rtmb->read (*target, start_sample, end_sample, _tracker);
DEBUG_RESULT (size_t, events_read, rtmb->read (*target, start_sample, end_sample, _tracker));
DEBUG_TRACE (DEBUG::MidiDiskIO, string_compose ("%1 MDS events read %2 range %3 .. %4\n", _name, events_read, playback_sample, playback_sample + nframes));
}
}

View File

@ -533,7 +533,7 @@ void
Graph::process_one_route (Route* route)
{
bool need_butler = false;
int retval = 0;
int retval;
assert (route);

View File

@ -199,7 +199,7 @@ void
MIDIClock_TransportMaster::update_midi_clock (Parser& /*parser*/, samplepos_t timestamp)
{
#ifndef NDEBUG
samplepos_t elapsed_since_start = timestamp - first_timestamp;
samplepos_t elapsed_since_start = timestamp - first_timestamp;
#endif
calculate_one_ppqn_in_samples_at (current.position);

View File

@ -20,6 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "pbd/assert.h"
#include "pbd/compose.h"
#include "pbd/enumwriter.h"
#include "pbd/error.h"
@ -226,15 +227,11 @@ MidiRingBuffer<T>::flush (samplepos_t /*start*/, samplepos_t end)
uint32_t ev_size;
T ev_time;
#ifndef NDEBUG
bool success =
#endif
this->peek (peekbuf, prefix_size);
bool success = this->peek (peekbuf, prefix_size);
/* this cannot fail, because we've already verified that there
is prefix_space to read
*/
assert (success);
x_assert (success, success);
ev_time = *(reinterpret_cast<T*>((uintptr_t)peekbuf));

View File

@ -28,6 +28,7 @@
#include <string>
#include "pbd/assert.h"
#include "pbd/failed_constructor.h"
#include "pbd/xml++.h"
#include "pbd/types_convert.h"
@ -912,10 +913,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e
for (uint32_t i = 1; i < natural_input_streams ().get (*t); ++i) {
uint32_t idx = in_map.p(0).get (*t, i, &valid);
if (valid) {
#ifdef NDEBUG
(void) idx;
#endif
assert (idx == 0);
x_assert (idx, idx == 0);
bufs.get_available (*t, i).read_from (bufs.get_available (*t, first_idx), nframes, offset, offset);
}
}
@ -1225,10 +1223,7 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
for (uint32_t i = 1; i < natural_input_streams ().get (*t); ++i) {
uint32_t idx = in_map.get (*t, i, &valid);
if (valid) {
#ifdef NDEBUG
(void) idx;
#endif
assert (idx == 0);
x_assert (idx, idx == 0);
bufs.get_available (*t, i).read_from (bufs.get_available (*t, first_idx), nframes, 0, 0);
}
}
@ -2031,11 +2026,8 @@ PluginInsert::configure_io (ChanCount in, ChanCount out)
}
//if (dout.n_audio () == 0) { dout.set (DataType::AUDIO, 1); } // XXX why?
DEBUG_TRACE (DEBUG::ChanMapping, string_compose ("%1: Delegate lookup: %2 %3 %4\n", name(), din, daux, dout));
bool const r = _plugins.front()->match_variable_io (din, daux, dout);
#ifdef NDEBUG
(void) r;
#endif
assert (r);
bool const r = _plugins.front()->match_variable_io (din, daux, dout);
x_assert (r, r);
DEBUG_TRACE (DEBUG::ChanMapping, string_compose ("%1: Delegate configuration: %2 %3 %4\n", name(), din, daux, dout));
if (_plugins.front()->reconfigure_io (din, daux, dout) == false) {
PluginIoReConfigure (); /* EMIT SIGNAL */

View File

@ -724,9 +724,7 @@ TransportFSM::defer (Event& ev)
void
TransportFSM::transition (MotionState ms)
{
#ifndef NDEBUG
const MotionState old = _motion_state;
#endif
DEBUG_RESULT (const MotionState, old, _motion_state);
_motion_state = ms;
_transport_speed = compute_transport_speed ();
DEBUG_TRACE (DEBUG::TFSMState, string_compose ("Leave %1, enter %2\n", enum_2_string (old), current_state()));
@ -735,9 +733,7 @@ TransportFSM::transition (MotionState ms)
void
TransportFSM::transition (ButlerState bs)
{
#ifndef NDEBUG
const ButlerState old = _butler_state;
#endif
DEBUG_RESULT (const ButlerState, old, _butler_state);
_butler_state = bs;
_transport_speed = compute_transport_speed ();
DEBUG_TRACE (DEBUG::TFSMState, string_compose ("Leave %1, enter %2\n", enum_2_string (old), current_state()));
@ -746,9 +742,7 @@ TransportFSM::transition (ButlerState bs)
void
TransportFSM::transition (DirectionState ds)
{
#ifndef NDEBUG
const DirectionState old = _direction_state;
#endif
DEBUG_RESULT (const DirectionState, old, _direction_state);
_direction_state = ds;
_transport_speed = compute_transport_speed ();
DEBUG_TRACE (DEBUG::TFSMState, string_compose ("Leave %1, enter %2\n", enum_2_string (old), current_state()));

View File

@ -1652,9 +1652,7 @@ AudioTrigger::estimate_tempo ()
beatcount = round(barcount * 4);
}
#ifndef NDEBUG
double est = _estimated_tempo;
#endif
DEBUG_RESULT (double, est, _estimated_tempo);
_estimated_tempo = beatcount / (seconds/60.);
DEBUG_TRACE (DEBUG::Triggers, string_compose ("given original estimated tempo %1, rounded beatcnt is %2 : resulting in working bpm = %3\n", est, _beatcnt, _estimated_tempo));
@ -2625,9 +2623,7 @@ MIDITrigger::midi_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en
const timepos_t region_start_time = _region->start();
const Temporal::Beats region_start = region_start_time.beats();
Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use());
#ifndef NDEBUG
samplepos_t last_event_samples = max_samplepos;
#endif
DEBUG_RESULT (samplepos_t, last_event_samples, max_samplepos);
/* see if we're going to start or stop or retrigger in this run() call */
pframes_t ignore_computed_dest_offset = 0;
@ -2731,9 +2727,7 @@ MIDITrigger::midi_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en
last_event_beats = event.time();
last_event_timeline_beats = maybe_last_event_timeline_beats;
#ifndef NDEBUG
last_event_samples = timeline_samples;
#endif
DEBUG_ASSIGN (last_event_samples, timeline_samples);
++iter;
}

View File

@ -44,6 +44,9 @@
#else
#include <arpa/inet.h>
#endif
#include "pbd/assert.h"
#include "smf.h"
#include "smf_private.h"
@ -182,12 +185,7 @@ smf_add_track(smf_t *smf, smf_track_t *track)
if (smf->number_of_tracks > 1) {
cantfail = smf_set_format(smf, 1);
#ifndef NDEBUG
assert(!cantfail);
#else
(void) cantfail;
#endif
x_assert (cantfail, !cantfail);
}
}

View File

@ -39,6 +39,9 @@
#include <assert.h>
#include <math.h>
#include <errno.h>
#include "pbd/assert.h"
#include "smf.h"
#include "smf_private.h"
@ -212,12 +215,9 @@ smf_event_new_textual(int type, const char *text)
event->midi_buffer[1] = type;
vlq_length = smf_format_vlq(event->midi_buffer + 2, MAX_VLQ_LENGTH - 2, text_length);
#ifndef NDEBUG
int copied_length =
#endif
snprintf((char *)event->midi_buffer + vlq_length + 2, event->midi_buffer_length - vlq_length - 2, "%s", text);
assert(copied_length == text_length);
int copied_length;
copied_length = snprintf((char *)event->midi_buffer + vlq_length + 2, event->midi_buffer_length - vlq_length - 2, "%s", text);
x_assert (copied_length, copied_length == text_length);
event->midi_buffer_length = 2 + vlq_length + text_length;

View File

@ -135,12 +135,9 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::
}
for (map<Button::ID,StripButtonInfo>::const_iterator b = strip_buttons.begin(); b != strip_buttons.end(); ++b) {
#ifndef NDEBUG
Button* bb = dynamic_cast<Button*>
#endif
(Button::factory (*_surface, b->first, b->second.base_id + index, b->second.name, *this));
DEBUG_RESULT_CAST (Button*, bb, dynamic_cast<Button*> (Button::factory (*_surface, b->first, b->second.base_id + index, b->second.name, *this)));
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 strip %2 new button BID %3 id %4 from base %5\n",
_surface->number(), index, Button::id_to_name (bb->bid()),
_surface->number(), index, Button::id_to_name (bb->bid()),
bb->id(), b->second.base_id));
}
}

View File

@ -30,6 +30,8 @@
#include <glibmm/convert.h>
#include "pbd/debug.h"
#include "midi++/port.h"
#include "ardour/audioengine.h"
@ -467,17 +469,13 @@ Surface::setup_master ()
_master_fader = dynamic_cast<Fader*> (Fader::factory (*this, device_info.strip_cnt(), "master", *master_group));
GlobalButtonInfo master_button = device_info.get_global_button(Button::MasterFaderTouch);
#ifndef NDEBUG
Button* bb =
#endif
dynamic_cast<Button*> (Button::factory (
*this,
Button::MasterFaderTouch,
master_button.id,
master_button.label,
*(group_it->second)
));
DEBUG_RESULT_CAST (Button*, bb, dynamic_cast<Button*>, (Button::factory (
*this,
Button::MasterFaderTouch,
master_button.id,
master_button.label,
*(group_it->second)
)));
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 Master Fader new button BID %2 id %3\n",
number(), Button::MasterFaderTouch, bb->id()));
} else {

View File

@ -112,10 +112,7 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::
}
for (map<Button::ID,StripButtonInfo>::const_iterator b = strip_buttons.begin(); b != strip_buttons.end(); ++b) {
#ifndef NDEBUG
Button* bb = dynamic_cast<Button*>
#endif
(Button::factory (*_surface, b->first, b->second.base_id + index, b->second.name, *this));
DEBUG_RESULT_CAST (Button*, bb, dynamic_cast<Button*>, (Button::factory (*_surface, b->first, b->second.base_id + index, b->second.name, *this)));
DEBUG_TRACE (DEBUG::US2400, string_compose ("surface %1 strip %2 new button BID %3 id %4 from base %5\n",
_surface->number(), index, Button::id_to_name (bb->bid()),
bb->id(), b->second.base_id));

View File

@ -398,16 +398,13 @@ Surface::setup_master ()
DeviceInfo device_info = _mcp.device_info();
GlobalButtonInfo master_button = device_info.get_global_button(Button::MasterFaderTouch);
#ifndef NDEBUG
Button* bb = dynamic_cast<Button*>
#endif
(Button::factory (
*this,
Button::MasterFaderTouch,
master_button.id,
master_button.label,
*(group_it->second)
));
DEBUG_RESULT (Button*, bb, dynamic_cast<Button*> (Button::factory (
*this,
Button::MasterFaderTouch,
master_button.id,
master_button.label,
*(group_it->second)
)));
DEBUG_TRACE (DEBUG::US2400, string_compose ("surface %1 Master Fader new button BID %2 id %3\n",
number(), Button::MasterFaderTouch, bb->id()));

View File

@ -20,6 +20,7 @@
#include <cmath>
#include "ardour/lmath.h"
#include "pbd/assert.h"
#include "pbd/cpus.h"
#include "pbd/pthread_utils.h"
@ -207,12 +208,8 @@ WaveViewCache::get_cache_group (boost::shared_ptr<ARDOUR::AudioSource> source)
boost::shared_ptr<WaveViewCacheGroup> new_group (new WaveViewCacheGroup (*this));
#ifndef NDEBUG
bool inserted =
#endif
cache_group_map.insert (std::make_pair (source, new_group)).second;
assert (inserted);
bool inserted = cache_group_map.insert (std::make_pair (source, new_group)).second;
x_assert (inserted, inserted);
return new_group;
}