[X2Go-Commits] [x2goclient] 32/217: pulsemanager.{cpp, h}: new class for PulseAudio management.

2016-09-20 Thread git-admin
This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 3bf98c25604a4776b69d166a0610a2cad27523dd
Author: Mihai Moldovan 
Date:   Wed Apr 29 02:34:13 2015 +0200

pulsemanager.{cpp,h}: new class for PulseAudio management.
---
 debian/changelog |1 +
 src/pulsemanager.cpp |  270 ++
 src/pulsemanager.h   |   92 +
 3 files changed, 363 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index bb8b6ef..4b8e52a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -64,6 +64,7 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
 - compat.{cpp,h}: remove inline keyword, because function is not defined
   in header file.
 - compat.h: include QtCore/qglobal.h for Q_OS_... macros.
+- pulsemanager.{cpp,h}: new class for PulseAudio management.
 
  -- X2Go Release Manager   Mon, 19 Sep 2016 09:07:07 +0200
 
diff --git a/src/pulsemanager.cpp b/src/pulsemanager.cpp
new file mode 100644
index 000..af1ba2b
--- /dev/null
+++ b/src/pulsemanager.cpp
@@ -0,0 +1,270 @@
+/***
+ *  Copyright (C) 2012-2015 by Mihai Moldovan  *
+ * *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or  *
+ *  (at your option) any later version.*
+ * *
+ *  This program is distributed in the hope that it will be useful,*
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  *
+ *  GNU General Public License for more details.   *
+ * *
+ *  You should have received a copy of the GNU General Public License  *
+ *  along with this program; if not, write to the  *
+ *  Free Software Foundation, Inc.,*
+ *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  *
+ ***/
+
+#include "pulsemanager.h"
+
+#ifndef DEBUG
+#define DEBUG_UNDEF
+#define DEBUG
+#endif
+
+PulseManager::PulseManager () {
+_pulse_X2Go = "/.x2go/pulse";
+
+_pulse_dir = QDir (QDir::homePath ());
+_pulse_dir.mkpath (_pulse_dir.absolutePath () + _pulse_X2Go + "/tmp");
+_pulse_dir.cd (_pulse_X2Go.mid (1));
+
+_env = QProcessEnvironment::systemEnvironment ();
+_env.insert ("HOME", _pulse_dir.absolutePath ());
+_env.insert ("TEMP", _pulse_dir.absolutePath () + "/tmp");
+
+_pulse_port = 4713;
+
+_state = QProcess::NotRunning;
+
+_pulse_server = 0;
+
+_app_dir = QApplication::applicationDirPath ();
+}
+
+PulseManager::~PulseManager () {
+if (_pulse_server && is_server_running ())
+shutdown ();
+
+delete (_pulse_server);
+}
+
+void PulseManager::start () {
+assert (!is_server_running ());
+
+delete (_pulse_server);
+
+_pulse_server = new QProcess (0);
+_state = QProcess::Starting;
+
+#ifdef Q_OS_DARWIN
+start_osx ();
+#elif defined (Q_OS_WIN)
+start_win ();
+#elif defined (Q_OS_LINUX)
+start_linux ();
+#endif
+}
+
+void PulseManager::start_osx () {
+find_port ();
+
+if (generate_server_config () && generate_client_config ()) {
+cleanup_client_dir ();
+
+_pulse_server->setProcessEnvironment (_env);
+
+QStringList args;
+args << "--exit-idle-time=-1" << "-n"
+ << "-F" << _pulse_dir.absolutePath () + "/config.pa"
+ << "-p"
+ << QDir (_app_dir
+  + "/../Frameworks/pulse-2.0/modules").absolutePath ()
+ << "--high-priority";
+#ifdef DEBUG
+args << "--log-level=debug";
+#endif
+
+_pulse_server->setWorkingDirectory (_app_dir + "/../exe/");
+_pulse_server->start (_app_dir + "/../exe/pulseaudio", args);
+
+if (_pulse_server->waitForStarted ()) {
+x2goDebug << "pulse started with" << args << "waiting for 
finish...";
+_state = QProcess::Running;
+
+connect (_pulse_server, SIGNAL (finished (int)),
+ this,  SLOT (on_pulse_finished (int)));
+
+#ifdef DEBUG
+// Give PA a little time to come up.
+QTimer::singleShot (5000, this, SLOT (slot_play_startup_sound ()));
+#endif
+}
+}
+}
+
+void PulseManager::find_port () {
+QTcpSocket tcpSocket (0);
+

[X2Go-Commits] [x2goclient] 32/217: pulsemanager.{cpp, h}: new class for PulseAudio management.

2016-08-27 Thread git-admin
This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit fc660d7257bc31e4dfdf5853a29e15dd7929a67f
Author: Mihai Moldovan 
Date:   Wed Apr 29 02:34:13 2015 +0200

pulsemanager.{cpp,h}: new class for PulseAudio management.
---
 debian/changelog |1 +
 src/pulsemanager.cpp |  270 ++
 src/pulsemanager.h   |   92 +
 3 files changed, 363 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 940fd17..eacc808 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -97,6 +97,7 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
 - compat.{cpp,h}: remove inline keyword, because function is not defined
   in header file.
 - compat.h: include QtCore/qglobal.h for Q_OS_... macros.
+- pulsemanager.{cpp,h}: new class for PulseAudio management.
   * debian/control:
 - Maintainer change in package: X2Go Developers .
 - Uploaders: add myself. Also, force a rebuild due to the changed
diff --git a/src/pulsemanager.cpp b/src/pulsemanager.cpp
new file mode 100644
index 000..af1ba2b
--- /dev/null
+++ b/src/pulsemanager.cpp
@@ -0,0 +1,270 @@
+/***
+ *  Copyright (C) 2012-2015 by Mihai Moldovan  *
+ * *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or  *
+ *  (at your option) any later version.*
+ * *
+ *  This program is distributed in the hope that it will be useful,*
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  *
+ *  GNU General Public License for more details.   *
+ * *
+ *  You should have received a copy of the GNU General Public License  *
+ *  along with this program; if not, write to the  *
+ *  Free Software Foundation, Inc.,*
+ *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  *
+ ***/
+
+#include "pulsemanager.h"
+
+#ifndef DEBUG
+#define DEBUG_UNDEF
+#define DEBUG
+#endif
+
+PulseManager::PulseManager () {
+_pulse_X2Go = "/.x2go/pulse";
+
+_pulse_dir = QDir (QDir::homePath ());
+_pulse_dir.mkpath (_pulse_dir.absolutePath () + _pulse_X2Go + "/tmp");
+_pulse_dir.cd (_pulse_X2Go.mid (1));
+
+_env = QProcessEnvironment::systemEnvironment ();
+_env.insert ("HOME", _pulse_dir.absolutePath ());
+_env.insert ("TEMP", _pulse_dir.absolutePath () + "/tmp");
+
+_pulse_port = 4713;
+
+_state = QProcess::NotRunning;
+
+_pulse_server = 0;
+
+_app_dir = QApplication::applicationDirPath ();
+}
+
+PulseManager::~PulseManager () {
+if (_pulse_server && is_server_running ())
+shutdown ();
+
+delete (_pulse_server);
+}
+
+void PulseManager::start () {
+assert (!is_server_running ());
+
+delete (_pulse_server);
+
+_pulse_server = new QProcess (0);
+_state = QProcess::Starting;
+
+#ifdef Q_OS_DARWIN
+start_osx ();
+#elif defined (Q_OS_WIN)
+start_win ();
+#elif defined (Q_OS_LINUX)
+start_linux ();
+#endif
+}
+
+void PulseManager::start_osx () {
+find_port ();
+
+if (generate_server_config () && generate_client_config ()) {
+cleanup_client_dir ();
+
+_pulse_server->setProcessEnvironment (_env);
+
+QStringList args;
+args << "--exit-idle-time=-1" << "-n"
+ << "-F" << _pulse_dir.absolutePath () + "/config.pa"
+ << "-p"
+ << QDir (_app_dir
+  + "/../Frameworks/pulse-2.0/modules").absolutePath ()
+ << "--high-priority";
+#ifdef DEBUG
+args << "--log-level=debug";
+#endif
+
+_pulse_server->setWorkingDirectory (_app_dir + "/../exe/");
+_pulse_server->start (_app_dir + "/../exe/pulseaudio", args);
+
+if (_pulse_server->waitForStarted ()) {
+x2goDebug << "pulse started with" << args << "waiting for 
finish...";
+_state = QProcess::Running;
+
+connect (_pulse_server, SIGNAL (finished (int)),
+ this,  SLOT (on_pulse_finished (int)));
+
+#ifdef DEBUG
+// Give PA a little time to come up.
+QTimer::singleShot (5000, this, SLOT (slot_play_startup_sound ()));
+#endif
+