13
0

Move request pipe setup into separate function

This commit is contained in:
Paul Davis 2013-07-11 14:35:26 -04:00
parent 6a8901eb8d
commit 0f1ed673d0
2 changed files with 26 additions and 17 deletions

View File

@ -80,6 +80,8 @@ class Butler : public SessionHandleRef
private:
void empty_pool_trash ();
void config_changed (std::string);
int setup_request_pipe ();
};
} // namespace ARDOUR

View File

@ -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;