diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-23 12:39:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-23 12:39:27 +0100 |
| commit | c2709fbe5438da124b2d493cb714a6c58720cf5b (patch) | |
| tree | 015607895cba76f9b8bcddf6fae72cb7c62e3cb3 /src | |
| parent | 365f830b4c65b2d872106a14f57d28cef4a179cd (diff) | |
Command-line option to specify servomatic_cli threads.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/server.cc | 4 | ||||
| -rw-r--r-- | src/lib/server.h | 2 | ||||
| -rw-r--r-- | src/lib/util.cc | 8 | ||||
| -rw-r--r-- | src/tools/servomatic_cli.cc | 47 | ||||
| -rw-r--r-- | src/tools/servomatic_gui.cc | 3 |
5 files changed, 56 insertions, 8 deletions
diff --git a/src/lib/server.cc b/src/lib/server.cc index ff784db5a..a62763447 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -181,9 +181,9 @@ Server::worker_thread () } void -Server::run () +Server::run (int num_threads) { - int const num_threads = Config::instance()->num_local_encoding_threads (); + cout << "Server starting with " << num_threads << " threads.\n"; for (int i = 0; i < num_threads; ++i) { _worker_threads.push_back (new thread (bind (&Server::worker_thread, this))); diff --git a/src/lib/server.h b/src/lib/server.h index 58cfe0b3f..fac440a76 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -76,7 +76,7 @@ class Server public: Server (Log* log); - void run (); + void run (int num_threads); private: void worker_thread (); diff --git a/src/lib/util.cc b/src/lib/util.cc index 1478bab2e..e79c7cd1c 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -518,5 +518,9 @@ colour_lut_index_to_name (int index) return ""; } - - +int +read_with_timeout (boost::asio::ip::tcp::socket* socket, uint8_t* data, int size) +{ + + return asio::read (socket, asio::buffer (data, size)); +} diff --git a/src/tools/servomatic_cli.cc b/src/tools/servomatic_cli.cc index 3ad73faf9..f8e713193 100644 --- a/src/tools/servomatic_cli.cc +++ b/src/tools/servomatic_cli.cc @@ -25,6 +25,7 @@ #include <vector> #include <unistd.h> #include <errno.h> +#include <getopt.h> #include <boost/array.hpp> #include <boost/asio.hpp> #include <boost/algorithm/string.hpp> @@ -39,13 +40,55 @@ #include "scaler.h" #include "image.h" #include "log.h" +#include "version.h" + +using namespace std; + +static void +help (string n) +{ + cerr << "Syntax: " << n << " [OPTION]\n" + << " -v, --version show DVD-o-matic version\n" + << " -h, --help show this help\n" + << " -t, --threads number of parallel encoding threads to use\n"; +} int -main () +main (int argc, char* argv[]) { + int num_threads = Config::instance()->num_local_encoding_threads (); + + int option_index = 0; + while (1) { + static struct option long_options[] = { + { "version", no_argument, 0, 'v'}, + { "help", no_argument, 0, 'h'}, + { "threads", required_argument, 0, 't'}, + { 0, 0, 0, 0 } + }; + + int c = getopt_long (argc, argv, "vht:", long_options, &option_index); + + if (c == -1) { + break; + } + + switch (c) { + case 'v': + cout << "dvdomatic version " << dvdomatic_version << " " << dvdomatic_git_commit << "\n"; + exit (EXIT_SUCCESS); + case 'h': + help (argv[0]); + exit (EXIT_SUCCESS); + case 't': + num_threads = atoi (optarg); + break; + } + } + Scaler::setup_scalers (); FileLog log ("servomatic.log"); Server server (&log); - server.run (); + server.run (num_threads); return 0; } diff --git a/src/tools/servomatic_gui.cc b/src/tools/servomatic_gui.cc index a151658f5..610ba8005 100644 --- a/src/tools/servomatic_gui.cc +++ b/src/tools/servomatic_gui.cc @@ -23,6 +23,7 @@ #include "wx_util.h" #include "lib/util.h" #include "lib/server.h" +#include "lib/config.h" using namespace std; using namespace boost; @@ -141,7 +142,7 @@ private: void main_thread () { Server server (&memory_log); - server.run (); + server.run (Config::instance()->num_local_encoding_threads ()); } boost::thread* _thread; |
