From 31fbf351a818ed860e82280467a23b7d9f59c107 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 14:37:15 +0200 Subject: [PATCH 1/6] vtl: round fractional framerates to 1/100 to compare for identity --- gtk2_ardour/video_timeline.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index d8913f27aa..743bc3216c 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -507,7 +507,7 @@ VideoTimeLine::video_file_info (std::string filename, bool local) } _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/ } - if (video_file_fps != _session->timecode_frames_per_second()) { + if (floor(video_file_fps*100) != floor(_session->timecode_frames_per_second()*100)) { warning << _("Video file's framerate is not equal to Ardour session timecode's framerate: ") << video_file_fps << _(" vs ") << _session->timecode_frames_per_second() << endmsg; } From b13c5bff54799374ddeced0325f641e5ce449165 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 15:35:49 +0200 Subject: [PATCH 2/6] vtl: NOOP - clean up code. --- gtk2_ardour/video_timeline.cc | 59 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index 743bc3216c..d8e129a2de 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -150,44 +150,41 @@ VideoTimeLine::set_session (ARDOUR::Session *s) return; } - if (node) { - ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false); + ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false); - set_id(*node); + set_id(*node); - const XMLProperty* proph = node->property (X_("Height")); - if (proph) { - editor->set_video_timeline_height(atoi(proph->value().c_str())); - } + const XMLProperty* proph = node->property (X_("Height")); + if (proph) { + editor->set_video_timeline_height(atoi(proph->value().c_str())); + } #if 0 /* TODO THINK: set FPS first time only ?! */ - const XMLProperty* propasfps = node->property (X_("AutoFPS")); - if (propasfps) { - auto_set_session_fps = atoi(propasfps->value().c_str())?true:false; - } + const XMLProperty* propasfps = node->property (X_("AutoFPS")); + if (propasfps) { + auto_set_session_fps = atoi(propasfps->value().c_str())?true:false; + } #endif - const XMLProperty* propoffset = node->property (X_("VideoOffset")); - if (propoffset) { - video_offset = atoll(propoffset->value().c_str()); - video_offset_p = video_offset; - } - - const XMLProperty* proplock = node->property (X_("VideoOffsetLock")); - if (proplock) { - video_offset_lock = atoi(proplock->value().c_str())?true:false; - } - - const XMLProperty* localfile = node->property (X_("LocalFile")); - if (localfile) { - local_file = atoi(localfile->value().c_str())?true:false; - } - - const XMLProperty* propf = node->property (X_("Filename")); - video_file_info(propf->value(), local_file); + const XMLProperty* propoffset = node->property (X_("VideoOffset")); + if (propoffset) { + video_offset = atoll(propoffset->value().c_str()); + video_offset_p = video_offset; } - node = _session->extra_xml (X_("Videomonitor")); - if (node) { + const XMLProperty* proplock = node->property (X_("VideoOffsetLock")); + if (proplock) { + video_offset_lock = atoi(proplock->value().c_str())?true:false; + } + + const XMLProperty* localfile = node->property (X_("LocalFile")); + if (localfile) { + local_file = atoi(localfile->value().c_str())?true:false; + } + + const XMLProperty* propf = node->property (X_("Filename")); + video_file_info(propf->value(), local_file); + + if ((node = _session->extra_xml (X_("Videomonitor")))) { const XMLProperty* prop = node->property (X_("active")); if (prop && prop->value() == "yes" && found_xjadeo() && !video_filename.empty() && local_file) { open_video_monitor(); From 1053529e4fddcd00891cbbc08cf4107e8335f873 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 16:43:41 +0200 Subject: [PATCH 3/6] possible fix for no-shutdown of external app (ie harvid) --- gtk2_ardour/system_exec.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/system_exec.cc b/gtk2_ardour/system_exec.cc index 566c87dfbb..eb81c5fcb2 100644 --- a/gtk2_ardour/system_exec.cc +++ b/gtk2_ardour/system_exec.cc @@ -444,10 +444,13 @@ SystemExec::wait (int options) int status=0; if (pid==0) return -1; if (pid==::waitpid(pid, &status, options)) { - pid=0; - } - if (errno == ECHILD) { - pid=0; + if (WEXITSTATUS(status) || WIFSIGNALED(status)) { + pid=0; + } + } else { + if (errno == ECHILD) { + pid=0; + } } return status; } From 024e556cb2c3fb95721aaa83954aed373d2c7d0f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 16:54:47 +0200 Subject: [PATCH 4/6] close network sockets on fork fixes problem with external apps (ie. video-server) inheriting them. --- libs/midi++2/ipmidi_port.cc | 4 ++++ libs/surfaces/osc/osc.cc | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/midi++2/ipmidi_port.cc b/libs/midi++2/ipmidi_port.cc index c90a3dbe6f..543c63e343 100644 --- a/libs/midi++2/ipmidi_port.cc +++ b/libs/midi++2/ipmidi_port.cc @@ -160,6 +160,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) return false; } + fcntl(sockin, F_SETFD, fcntl(sockin, F_GETFD) | FD_CLOEXEC); + struct sockaddr_in addrin; ::memset(&addrin, 0, sizeof(addrin)); addrin.sin_family = AF_INET; @@ -206,6 +208,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) ::perror("socket(out)"); return false; } + + fcntl(sockout, F_SETFD, fcntl(sockout, F_GETFD) | FD_CLOEXEC); // Will Hall, Oct 2007 if (!ifname.empty()) { diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 009587ce85..9e80554f0b 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -166,6 +166,9 @@ OSC::start () _port++; continue; } + + int fd = lo_server_get_socket_fd (_osc_server); + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #ifdef ARDOUR_OSC_UNIX_SERVER @@ -174,7 +177,7 @@ OSC::start () // attempt to create unix socket server too snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX"); - int fd = mkstemp(tmpstr); + fd = mkstemp(tmpstr); if (fd >= 0 ) { unlink (tmpstr); @@ -185,6 +188,8 @@ OSC::start () if (_osc_unix_server) { _osc_unix_socket_path = tmpstr; } + fd = lo_server_get_socket_fd (_osc_unix_server) + fcntl(fdx, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } #endif From df99859ad2478700267a21f993eb421e555ae960 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 17:12:25 +0200 Subject: [PATCH 5/6] more sockets to close on fork() --- libs/ardour/butler.cc | 3 +++ libs/ardour/rdff.c | 2 ++ libs/pbd/crossthread.cc | 2 ++ 3 files changed, 7 insertions(+) diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index db1b316368..119f01fc6b 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -110,6 +110,9 @@ Butler::start_thread() return -1; } + fcntl(request_pipe[0], F_SETFD, fcntl(request_pipe[0], F_GETFD) | FD_CLOEXEC); + fcntl(request_pipe[1], F_SETFD, fcntl(request_pipe[1], F_GETFD) | FD_CLOEXEC); + //pthread_detach (thread); return 0; diff --git a/libs/ardour/rdff.c b/libs/ardour/rdff.c index ca8e1abf1f..9dbb6ddae1 100644 --- a/libs/ardour/rdff.c +++ b/libs/ardour/rdff.c @@ -74,6 +74,8 @@ rdff_open(const char* path, bool write) } } + fcntl(fileno(fd), F_SETFD, fcntl(fileno(fd), F_GETFD) | FD_CLOEXEC); + RDFF ret = (RDFF)malloc(sizeof(struct _RDFF)); ret->fd = fd; ret->size = size; diff --git a/libs/pbd/crossthread.cc b/libs/pbd/crossthread.cc index 2ffede5163..aa9d2edcd2 100644 --- a/libs/pbd/crossthread.cc +++ b/libs/pbd/crossthread.cc @@ -52,6 +52,8 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking) return; } } + fcntl(fds[0], F_SETFD, fcntl(fds[0], F_GETFD) | FD_CLOEXEC); + fcntl(fds[1], F_SETFD, fcntl(fds[1], F_GETFD) | FD_CLOEXEC); } CrossThreadChannel::~CrossThreadChannel () From 92161b57ad8eb65c5f3e265388c353d36ce20c8d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 17:43:06 +0200 Subject: [PATCH 6/6] mark more filedes as close-on-exec. - here audio+midi files! --- libs/pbd/file_manager.cc | 3 +++ libs/pbd/sndfile_manager.cc | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc index a71ffca190..fb3227a922 100644 --- a/libs/pbd/file_manager.cc +++ b/libs/pbd/file_manager.cc @@ -289,6 +289,9 @@ StdioFileDescriptor::open () /* we must have a lock on the FileManager's mutex */ _file = fopen (_path.c_str(), _mode.c_str()); + if (_file) { + fcntl(fileno(_file), F_SETFD, fcntl(fileno(_file), F_GETFD) | FD_CLOEXEC); + } return (_file == 0); } diff --git a/libs/pbd/sndfile_manager.cc b/libs/pbd/sndfile_manager.cc index d1dcd05256..4977f21dfd 100644 --- a/libs/pbd/sndfile_manager.cc +++ b/libs/pbd/sndfile_manager.cc @@ -90,7 +90,12 @@ SndFileDescriptor::open () { /* we must have a lock on the FileManager's mutex */ - _sndfile = sf_open (_path.c_str(), _writeable ? SFM_RDWR : SFM_READ, _info); + int fd = ::open(_path.c_str(), O_LARGEFILE | (_writeable ? (O_RDWR) : O_RDONLY)); + if (fd == -1) return false; + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); + + _sndfile = sf_open_fd (fd, _writeable ? SFM_RDWR : SFM_READ, _info, 1); + return (_sndfile == 0); }