Add configure option to raise a FP exception when a denormal
authorCarl Hetherington <carl@carlh.net>
Tue, 27 Dec 2011 00:48:31 +0000 (00:48 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 27 Dec 2011 00:48:31 +0000 (00:48 +0000)
is detected.

git-svn-id: svn://localhost/ardour2/branches/3.0@11086 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/session.h
libs/ardour/audioengine.cc
libs/ardour/globals.cc
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/ardour/test/playlist_layering_test.cc
wscript

index 675950d986c4cc0192b9b8fac40236af809ef742..4587c8fc68a9af1cfff5f1693f9c5b628e7905be 100644 (file)
@@ -149,7 +149,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
                 const std::string& fullpath,
                 const std::string& snapshot_name,
                 BusProfile* bus_profile = 0,
-                std::string mix_template = "");
+                std::string mix_template = "",
+                bool with_midi_ui = true);
 
        virtual ~Session ();
 
@@ -1076,7 +1077,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        void             auto_loop_changed (Location *);
 
        void first_stage_init (std::string path, std::string snapshot_name);
-       int  second_stage_init ();
+       int  second_stage_init (bool with_midi_ui = true);
        void remove_empty_sounds ();
 
        void setup_midi_control ();
index fa1d6fe175da0c224df7d6bd17d083462d82f83c..a538ffcae71c62e665e6b5b0ece53c623e1b33e1 100644 (file)
@@ -91,6 +91,7 @@ AudioEngine::AudioEngine (string client_name, string session_uuid)
        g_atomic_int_set (&m_meter_exit, 0);
 
        if (connect_to_jack (client_name, session_uuid)) {
+               _instance = 0;
                throw NoBackendAvailable ();
        }
 
index 5a2a2addd65b2318e6893594ba3a007a08beb7ee..e9383295e7ff4aaa900c0646c5a034a0dcd4a532 100644 (file)
@@ -454,6 +454,11 @@ ARDOUR::setup_fpu ()
 
        MXCSR  = _mm_getcsr();
 
+#ifdef DEBUG_DENORMAL_EXCEPTION
+       /* This will raise a FP exception if a denormal is detected */
+       MXCSR &= ~_MM_MASK_DENORM;
+#endif 
+
        switch (Config->get_denormal_model()) {
        case DenormalNone:
                MXCSR &= ~(_MM_FLUSH_ZERO_ON|0x8000);
index 37349cc5fb0cc2671f2697d2d94ca6c6c3e95807..1c9676e578edc0cb949fd942cd00112a28934853 100644 (file)
@@ -140,7 +140,8 @@ Session::Session (AudioEngine &eng,
                   const string& fullpath,
                   const string& snapshot_name,
                   BusProfile* bus_profile,
-                  string mix_template)
+                  string mix_template,
+                 bool with_midi_ui)
        : _engine (eng)
        , _target_transport_speed (0.0)
        , _requested_return_frame (-1)
@@ -191,7 +192,7 @@ Session::Session (AudioEngine &eng,
                }
        }
 
-       if (second_stage_init ()) {
+       if (second_stage_init (with_midi_ui)) {
                destroy ();
                throw failed_constructor ();
        }
index 7d6f44b7861d2566c1974b48c7e4cc76ca5ad7f0..aa117f00aa6990b8a6025016252f086b0b227f98 100644 (file)
@@ -293,7 +293,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
 }
 
 int
-Session::second_stage_init ()
+Session::second_stage_init (bool with_midi_ui)
 {
        AudioFileSource::set_peak_dir (_session_dir->peak_path().to_string());
 
@@ -307,8 +307,10 @@ Session::second_stage_init ()
                return -1;
        }
 
-       if (start_midi_thread ()) {
-               return -1;
+       if (with_midi_ui) {
+               if (start_midi_thread ()) {
+                       return -1;
+               }
        }
 
        setup_midi_machine_control ();
index 1371b0cfaecdae9bda5b52639a0f9b48ac9cc8ed..05c44f5625d35a82aa2ed694cd25884683e2368d 100644 (file)
@@ -68,11 +68,17 @@ PlaylistLayeringTest::setUp ()
        test_receiver.listen_to (fatal);
        test_receiver.listen_to (warning);
 
-       AudioEngine* engine = new AudioEngine ("test", "");
+       AudioEngine* engine = 0;
+       try {
+               engine = new AudioEngine ("test", "");
+       } catch (...) {
+               CPPUNIT_ASSERT (false);
+       }
+       
        MIDI::Manager::create (engine->jack ());
        CPPUNIT_ASSERT (engine->start () == 0);
 
-       _session = new Session (*engine, test_session_path, "playlist_layering_test");
+       _session = new Session (*engine, test_session_path, "playlist_layering_test", 0, "", false);
        engine->set_session (_session);
 
        _playlist = PlaylistFactory::create (DataType::AUDIO, *_session, "test");
diff --git a/wscript b/wscript
index 05620d375aae2be9144ba4e88284626c7df1d0e3..f8e3edccb0e3c631230eedc2e7c408a4227c4791 100644 (file)
--- a/wscript
+++ b/wscript
@@ -310,6 +310,12 @@ def set_compiler_flags (conf,opt):
         conf.env.append_value('CXXFLAGS', '-DDEBUG_RT_ALLOC')
         conf.env.append_value('LINKFLAGS', '-ldl')
 
+    print 'bar'
+    if conf.env['DEBUG_DENORMAL_EXCEPTION']:
+        print 'foo'
+        conf.env.append_value('CFLAGS', '-DDEBUG_DENORMAL_EXCEPTION')
+        conf.env.append_value('CXXFLAGS', '-DDEBUG_DENORMAL_EXCEPTION')
+
     if opt.universal:
         if not Options.options.nocarbon:
             conf.env.append_value('CFLAGS', ["-arch", "i386", "-arch", "ppc"])
@@ -387,6 +393,8 @@ def options(opt):
                     help='Build with debugging for the STL')
     opt.add_option('--rt-alloc-debug', action='store_true', default=False, dest='rt_alloc_debug',
                     help='Build with debugging for memory allocation in the real-time thread')
+    opt.add_option('--denormal-exception', action='store_true', default=False, dest='denormal_exception',
+                    help='Raise a floating point exception if a denormal is detected')
     opt.add_option('--test', action='store_true', default=False, dest='build_tests',
                     help="Build unit tests")
     opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
@@ -582,6 +590,10 @@ def configure(conf):
     conf.env['PROGRAM_NAME'] = opts.program_name
     if opts.rt_alloc_debug:
         conf.define('DEBUG_RT_ALLOC', 1)
+        conf.env['DEBUG_RT_ALLOC'] = True
+    if opts.denormal_exception:
+        conf.define('DEBUG_DENORMAL_EXCEPTION', 1)
+        conf.env['DEBUG_DENORMAL_EXCEPTION'] = True
     if not conf.is_defined('HAVE_CPPUNIT'):
         conf.env['BUILD_TESTS'] = False
 
@@ -610,6 +622,8 @@ const char* const ardour_config_info = "\\n\\
     write_config_text('AU state support',      conf.is_defined('AU_STATE_SUPPORT'))
     write_config_text('Build target',          conf.env['build_target'])
     write_config_text('CoreAudio',             conf.is_defined('HAVE_COREAUDIO'))
+    write_config_text('Debug RT allocations',  conf.is_defined('DEBUG_RT_ALLOC'))
+    write_config_text('Denormal exceptions',   conf.is_defined('DEBUG_DENORMAL_EXCEPTION'))
     write_config_text('FLAC',                  conf.is_defined('HAVE_FLAC'))
     write_config_text('FPU optimization',      opts.fpu_optimization)
     write_config_text('Freedesktop files',     opts.freedesktop)