From 0f1ed673d055205569513d372f9ae35a447a485f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 14:35:26 -0400 Subject: [PATCH] Move request pipe setup into separate function --- libs/ardour/ardour/butler.h | 2 ++ libs/ardour/butler.cc | 41 ++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index cdd48c3e3a..321755197c 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -80,6 +80,8 @@ class Butler : public SessionHandleRef private: void empty_pool_trash (); void config_changed (std::string); + + int setup_request_pipe (); }; } // namespace ARDOUR diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index db1b316368..38ffef6fbc 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -68,6 +68,29 @@ Butler::config_changed (std::string p) } } +int +Butler::setup_request_pipe () +{ + if (pipe (request_pipe)) { + error << string_compose(_("Cannot create transport request signal pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + + if (fcntl (request_pipe[0], F_SETFL, O_NONBLOCK)) { + error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + + if (fcntl (request_pipe[1], F_SETFL, O_NONBLOCK)) { + error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), + strerror (errno)) << endmsg; + return -1; + } + return 0; +} + int Butler::start_thread() { @@ -87,23 +110,7 @@ Butler::start_thread() should_run = false; - if (pipe (request_pipe)) { - error << string_compose(_("Cannot create transport request signal pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } - - if (fcntl (request_pipe[0], F_SETFL, O_NONBLOCK)) { - error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } - - if (fcntl (request_pipe[1], F_SETFL, O_NONBLOCK)) { - error << string_compose(_("UI: cannot set O_NONBLOCK on butler request pipe (%1)"), - strerror (errno)) << endmsg; - return -1; - } + if (setup_request_pipe() != 0) return -1; if (pthread_create_and_store ("disk butler", &thread, _thread_work, this)) { error << _("Session: could not create butler thread") << endmsg;