13
0

Merge branch 'master' of git.ardour.org:ardour/ardour

This commit is contained in:
Paul Davis 2013-06-07 17:52:12 -04:00
commit 0d31fc76d5
9 changed files with 123 additions and 62 deletions

View File

@ -3423,9 +3423,17 @@ ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg)
Config->set_video_advanced_setup(true);
}
if (video_server_process) {
delete video_server_process;
}
video_server_process = new SystemExec(icsd_exec, argp);
video_server_process->start();
sleep(1);
int timeout = 10;
while (!ARDOUR_UI::instance()->video_timeline->check_server()) {
sleep(1);
if (--timeout <= 0) break;
}
}
return true;
}

View File

@ -1,5 +1,6 @@
/*
Copyright (C) 2010 Paul Davis
Copyright 2005-2008 Lennart Poettering
Author: Robin Gareus <robin@gareus.org>
This program is free software; you can redistribute it and/or modify
@ -23,6 +24,9 @@
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <dirent.h>
#ifdef __WIN32__
#include <windows.h>
#else
@ -31,8 +35,11 @@
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include "system_exec.h"
using namespace std;
@ -40,6 +47,104 @@ void * interposer_thread (void *arg);
static void close_fd (int& fd) { if (fd >= 0) ::close (fd); fd = -1; }
#ifndef __WIN32__
/*
* This function was part of libasyncns.
* LGPL v2.1
* Copyright 2005-2008 Lennart Poettering
*/
static int close_allv(const int except_fds[]) {
struct rlimit rl;
int fd;
#ifdef __linux__
DIR *d;
assert(except_fds);
if ((d = opendir("/proc/self/fd"))) {
struct dirent *de;
while ((de = readdir(d))) {
int found;
long l;
char *e = NULL;
int i;
if (de->d_name[0] == '.')
continue;
errno = 0;
l = strtol(de->d_name, &e, 10);
if (errno != 0 || !e || *e) {
closedir(d);
errno = EINVAL;
return -1;
}
fd = (int) l;
if ((long) fd != l) {
closedir(d);
errno = EINVAL;
return -1;
}
if (fd < 3)
continue;
if (fd == dirfd(d))
continue;
found = 0;
for (i = 0; except_fds[i] >= 0; i++)
if (except_fds[i] == fd) {
found = 1;
break;
}
if (found) continue;
if (close(fd) < 0) {
int saved_errno;
saved_errno = errno;
closedir(d);
errno = saved_errno;
return -1;
}
}
closedir(d);
return 0;
}
#endif
if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
return -1;
for (fd = 0; fd < (int) rl.rlim_max; fd++) {
int i;
if (fd <= 3)
continue;
for (i = 0; except_fds[i] >= 0; i++)
if (except_fds[i] == fd)
continue;
if (close(fd) < 0 && errno != EBADF)
return -1;
}
return 0;
}
#endif /* not on windows */
SystemExec::SystemExec (std::string c, std::string a)
: cmd(c)
{
@ -619,6 +724,11 @@ SystemExec::start (int stderr_mode)
signal(SIGPIPE, SIG_DFL);
#endif
#ifndef __WIN32__
int good_fds[1] = { 0 };
close_allv(good_fds);
#endif
::execve(argp[0], argp, envp);
/* if we reach here something went wrong.. */
char buf = 0;

View File

@ -110,9 +110,6 @@ 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;

View File

@ -74,8 +74,6 @@ 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;

View File

@ -160,8 +160,6 @@ 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;
@ -208,8 +206,6 @@ 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()) {

View File

@ -52,8 +52,6 @@ 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 ()

View File

@ -289,9 +289,6 @@ 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);
}

View File

@ -31,16 +31,6 @@
#include "pbd/sndfile_manager.h"
#include "pbd/debug.h"
/*
* Neat solution to the Win32/OS2 binary file flage requirement.
* If O_BINARY isn't already defined by the inclusion of the system
* headers, set it to zero.
*/
#ifndef O_BINARY
#define O_BINARY 0
#endif
using namespace std;
using namespace PBD;
@ -99,32 +89,8 @@ bool
SndFileDescriptor::open ()
{
/* we must have a lock on the FileManager's mutex */
int fd, oflag, mode ;
if (_writeable) {
oflag = O_RDWR | O_CREAT | O_BINARY ;
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ;
} else {
oflag = O_RDONLY | O_BINARY ;
mode = 0 ;
}
if (mode == 0) {
fd = ::open (_path.c_str(), oflag) ;
} else {
fd = ::open (_path.c_str(), oflag, mode) ;
}
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);
if (sf_open_fd == 0) {
::close(fd);
}
_sndfile = sf_open (_path.c_str(), _writeable ? SFM_RDWR : SFM_READ, _info);
return (_sndfile == 0);
}

View File

@ -170,9 +170,6 @@ OSC::start ()
if (!_osc_server) {
return 1;
}
int fd = lo_server_get_socket_fd (_osc_server);
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
#ifdef ARDOUR_OSC_UNIX_SERVER
@ -181,7 +178,7 @@ OSC::start ()
// attempt to create unix socket server too
snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX");
fd = mkstemp(tmpstr);
int fd = mkstemp(tmpstr);
if (fd >= 0 ) {
unlink (tmpstr);
@ -191,8 +188,6 @@ 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
@ -232,23 +227,19 @@ OSC::thread_init ()
pthread_set_name (X_("OSC"));
if (_osc_unix_server) {
const int fd = lo_server_get_socket_fd (_osc_unix_server);
Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR);
src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server));
src->attach (_main_loop->get_context());
local_server = src->gobj();
g_source_ref (local_server);
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
}
if (_osc_server) {
const int fd = lo_server_get_socket_fd (_osc_server);
Glib::RefPtr<IOSource> src = IOSource::create (fd, IO_IN|IO_HUP|IO_ERR);
Glib::RefPtr<IOSource> src = IOSource::create (lo_server_get_socket_fd (_osc_server), IO_IN|IO_HUP|IO_ERR);
src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_server));
src->attach (_main_loop->get_context());
remote_server = src->gobj();
g_source_ref (remote_server);
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
}
PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self(), X_("OSC"), 2048);