From d85ab8af89b1efd47622fb04a5d8407416c9db19 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sat, 26 Sep 2015 17:14:43 +1000 Subject: [PATCH] Reinterpret the return value of AudioBackend::start as AudioBackend::ErrorCode This will allow backends to return a more meaningful error message. Eventually an error code could be returned by AudioEngine::start and the GUI can then use AudioBackend::get_error_string to convert the error into a translated error message directly, or it may be desirable to define its own error messages. The reasons for not doing that right now is that this is a workable solution with the least change required. --- libs/ardour/ardour/audioengine.h | 4 ++++ libs/ardour/audioengine.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index d1e3f8a7ef..fcb1226e1a 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -99,6 +99,8 @@ class LIBARDOUR_API AudioEngine : public SessionHandlePtr, public PortManager pframes_t samples_since_cycle_start (); bool get_sync_offset (pframes_t& offset) const; + std::string get_last_backend_error () const { return _last_backend_error_string; } + int create_process_thread (boost::function func); int join_process_threads (); bool in_process_thread (); @@ -280,6 +282,8 @@ class LIBARDOUR_API AudioEngine : public SessionHandlePtr, public PortManager bool _started_for_latency; bool _in_destructor; + std::string _last_backend_error_string; + Glib::Threads::Thread* _hw_reset_event_thread; gint _hw_reset_request_count; Glib::Threads::Cond _hw_reset_condition; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 8091e2516c..c5e2f17d47 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -835,8 +835,12 @@ AudioEngine::start (bool for_latency) _processed_frames = 0; last_monitor_check = 0; - - if (_backend->start (for_latency)) { + + int error_code = _backend->start (for_latency); + + if (error_code != 0) { + _last_backend_error_string = + AudioBackend::get_error_string((AudioBackend::ErrorCode)error_code); return -1; }