+ Glib::Threads::Mutex::Lock guard (_reset_request_lock);
+ g_atomic_int_inc (&_hw_reset_request_count);
+ _hw_reset_condition.signal ();
+}
+
+int
+AudioEngine::backend_reset_requested()
+{
+ return g_atomic_int_get (&_hw_reset_request_count);
+}
+
+void
+AudioEngine::do_reset_backend()
+{
+ SessionEvent::create_per_thread_pool (X_("Backend reset processing thread"), 1024);
+
+ Glib::Threads::Mutex::Lock guard (_reset_request_lock);
+
+ while (!_stop_hw_reset_processing) {
+
+ if (g_atomic_int_get (&_hw_reset_request_count) != 0 && _backend) {
+
+ _reset_request_lock.unlock();
+
+ 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::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() );
+ 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;
+
+ _reset_request_lock.lock();
+
+ } else {
+
+ _hw_reset_condition.wait (_reset_request_lock);
+
+ }