This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch bugfix/osx in repository x2goclient.
commit 52f559e75f1047e0a7b880cce2e1cc730e493269 Author: Mihai Moldovan <io...@ionic.de> Date: Thu Oct 29 04:56:33 2015 +0100 pulsemanager.{cpp,h}: add ESD support. --- debian/changelog | 1 + src/pulsemanager.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++------- src/pulsemanager.h | 5 ++++- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8fd7185..90a5cb9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -177,6 +177,7 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium - pulsemanager.{cpp,h}: switch port definitions to std::uint16_t. - pulsemanager.h: add std:: namespace selector for uint32_t version variables. + - pulsemanager.{cpp,h}: add ESD support. [ Bernard Cafarelli ] * New upstream version (4.0.5.3): diff --git a/src/pulsemanager.cpp b/src/pulsemanager.cpp index 33d77d6..c92d64f 100644 --- a/src/pulsemanager.cpp +++ b/src/pulsemanager.cpp @@ -25,8 +25,8 @@ #endif PulseManager::PulseManager () : pulse_X2Go_ ("/.x2go/pulse"), pulse_port_ (4713), - state_ (QProcess::NotRunning), pulse_server_ (NULL), - app_dir_ (QApplication::applicationDirPath ()), + esd_port_ (4714), state_ (QProcess::NotRunning), + pulse_server_ (NULL), app_dir_ (QApplication::applicationDirPath ()), pulse_version_major_ (0), pulse_version_minor_ (0) { pulse_dir_ = QDir (QDir::homePath ()); pulse_dir_.mkpath (pulse_dir_.absolutePath () + pulse_X2Go_ + "/tmp"); @@ -62,7 +62,15 @@ void PulseManager::start () { } void PulseManager::start_osx () { - find_port (); + // Search for a free Pulse and EsounD port. + // Note that there is no way we could find + // an esd port, if the pulse port detection + // failed. Better trust your compiler to + // optimize this statement and save some + // cycles. + if ((findPort (false)) && (findPort (true))) { + find_port (); + } if (generate_server_config () && generate_client_config ()) { cleanup_client_dir (); @@ -98,21 +106,45 @@ void PulseManager::start_osx () { } } -void PulseManager::find_port () { +void PulseManager::find_port (bool search_esd) { QTcpSocket tcpSocket (0); bool free = false; + std::uint16_t ret = pulse_port_; + std::uint16_t other_port = esd_port_; + + // If the search_esd parameter is true, find a free port + // for the PulseAudio emulation. + if (search_esd) { + ret = esd_port_; + other_port = pulse_port_; + } do { - tcpSocket.connectToHost ("127.0.0.1", pulse_port_); + // Skip this port, if it's reserved for the counterpart. + if (ret == other_port) { + ++ret; + continue; + } + + tcpSocket.connectToHost ("127.0.0.1", ret); if (tcpSocket.waitForConnected (1000)) { tcpSocket.close (); free = false; - ++pulse_port_; + ++ret; } else free = true; - } while (!free); + } while ((!free) && (port > 1023)); + + if (!search_esd) { + pulse_port_ = ret; + } + else { + esd_port_ = ret; + } + + return (free); } bool PulseManager::generate_server_config () { @@ -131,6 +163,7 @@ bool PulseManager::generate_server_config () { config_tmp_file_stream << "load-module module-native-protocol-tcp port=" + QString::number (pulse_port_) << endl; config_tmp_file_stream << "load-module module-native-protocol-unix" << endl; + config_tmp_file_stream << "load-module module-esound-protocol-unix" << endl; config_tmp_file_stream << "load-module module-coreaudio-detect"; if (disable_input) @@ -241,10 +274,18 @@ std::uint16_t PulseManager::get_pulse_port () { return (pulse_port_); } +std::uint16_t PulseManager::get_esd_port () { + return (esd_port_); +} + void PulseManager::set_pulse_port (std::uint16_t pulse_port) { pulse_port_ = pulse_port; } +void PulseManager::set_esd_port (std::uint16_t esd_port) { + esd_port_ = esd_port; +} + void PulseManager::relaunch () { if (pulse_server_ && is_server_running ()) shutdown (); diff --git a/src/pulsemanager.h b/src/pulsemanager.h index dbafa3f..22ab771 100644 --- a/src/pulsemanager.h +++ b/src/pulsemanager.h @@ -46,7 +46,9 @@ class PulseManager: public QObject { PulseManager (); ~PulseManager (); std::uint16_t get_pulse_port (); + std::uint16_t get_esd_port (); void set_pulse_port (std::uint16_t pulse_port); + void set_esd_port (std::uint16_t esd_port); QProcess::ProcessState state (); public slots: @@ -60,7 +62,7 @@ class PulseManager: public QObject { void start_win (); // FIXME void start_linux (); - void find_port (); + void find_port (bool search_esd = false); bool generate_server_config (); bool generate_client_config (); void cleanup_client_dir (); @@ -80,6 +82,7 @@ class PulseManager: public QObject { QProcessEnvironment env_; QProcess *pulse_server_; std::uint16_t pulse_port_; + std::uint16_t esd_port_; QProcess::ProcessState state_; QString app_dir_; std::uint32_t pulse_version_major_; -- Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org http://lists.x2go.org/listinfo/x2go-commits