Fixed incomplete merge for audioengine.cc
[ardour.git] / libs / ardour / audioengine.cc
index 02c4d1b5536a268a30fca6b7b06df54adc82a033..16283d92320a145ae360dbc1a548f12790c86709 100644 (file)
@@ -468,25 +468,28 @@ AudioEngine::do_reset_backend()
                        Glib::Threads::RecMutex::Lock pl (_state_lock);
                        g_atomic_int_dec_and_test (&_hw_reset_request_count);
                
-                       std::cout << "AudioEngine::RESET::Reset request processing. Requests left: " << _hw_reset_request_count << std::endl;
-                       DeviceResetStarted(); // notify about device reset to be started
-               
-                       // backup the device name
-                       std::string name = _backend->device_name ();
-               
-                       std::cout << "AudioEngine::RESET::Stoping engine..." << std::endl;
-                       stop();
-               
-                       std::cout << "AudioEngine::RESET::Reseting device..." << std::endl;
-                       if ( 0 == _backend->reset_device () ) {
-                       
-                               std::cout << "AudioEngine::RESET::Starting engine..." << std::endl;
-                               start ();
-                       
+            std::cout << "AudioEngine::RESET::Reset request processing. Requests left: " << _hw_reset_request_count << std::endl;
+                        DeviceResetStarted(); // notify about device reset to be started
+            
+                        // backup the device name
+                        std::string name = _backend->device_name ();
+
+            std::cout << "AudioEngine::RESET::Reseting device..." << std::endl;
+                       if ( ( 0 == stop () ) &&
+                 ( 0 == _backend->reset_device () ) &&
+                 ( 0 == start () ) ) {
+                               
+                               std::cout << "AudioEngine::RESET::Engine started..." << std::endl;
+                               
                                // inform about possible changes
                                BufferSizeChanged (_backend->buffer_size() );
-                       } else {
-                               DeviceError();
+                DeviceResetFinished(); // notify about device reset finish
+            
+            } else {
+            
+                DeviceResetFinished(); // notify about device reset finish
+                               // we've got an error
+                DeviceError();
                        }
                        
                        std::cout << "AudioEngine::RESET::Done." << std::endl;
@@ -522,6 +525,8 @@ AudioEngine::do_devicelist_update()
 
             _devicelist_update_lock.unlock();
             
+            Glib::Threads::RecMutex::Lock pl (_state_lock);
+            
             g_atomic_int_dec_and_test (&_hw_devicelist_update_count);
             DeviceListChanged (); /* EMIT SIGNAL */
         
@@ -858,8 +863,6 @@ AudioEngine::stop (bool for_latency)
                return 0;
        }
 
-       Glib::Threads::Mutex::Lock lm (_process_lock);
-
        if (_backend->stop ()) {
                return -1;
        }