Add a global setting for audio support. Add some support for logging though not used. Some other fixes.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41316 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+26
-9
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
* haiku.php - an online Haiku demo using qemu and vnc.
|
* haiku.php - an online Haiku demo using qemu and vnc.
|
||||||
*
|
*
|
||||||
* Copyright 2007-2010, Francois Revol, [email protected].
|
* Copyright 2007-2011, Francois Revol, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -32,6 +32,9 @@ define("PAGE_TITLE", "Haiku Online Demo");
|
|||||||
// to use the tightvnc applet instead (supports > 8bpp):
|
// to use the tightvnc applet instead (supports > 8bpp):
|
||||||
// on debian, apt-get install tightvnc-java will put them in
|
// on debian, apt-get install tightvnc-java will put them in
|
||||||
// /usr/share/tightvnc-java
|
// /usr/share/tightvnc-java
|
||||||
|
// else you can get it from http://www.tightvnc.com/download-old.php :
|
||||||
|
// wget http://www.tightvnc.com/download/1.3.10/tightvnc-1.3.10_javabin.zip
|
||||||
|
// (you will have to move the VncViewer.jar file around)
|
||||||
define("VNCJAVA_PATH", "tightvnc-java");
|
define("VNCJAVA_PATH", "tightvnc-java");
|
||||||
define("VNCJAR", "VncViewer.jar");
|
define("VNCJAR", "VncViewer.jar");
|
||||||
define("VNCCLASS", "VncViewer.class");
|
define("VNCCLASS", "VncViewer.class");
|
||||||
@@ -58,6 +61,9 @@ define("VNCPORTBASE", 5900);
|
|||||||
//define("AUDIOPORTBASE", 8080);
|
//define("AUDIOPORTBASE", 8080);
|
||||||
define("AUDIOPORTBASE", (VNCPORTBASE + MAX_QEMUS));
|
define("AUDIOPORTBASE", (VNCPORTBASE + MAX_QEMUS));
|
||||||
|
|
||||||
|
// if audio is enabled
|
||||||
|
define("AUDIOENABLED", false);
|
||||||
|
|
||||||
// base port for serial output
|
// base port for serial output
|
||||||
//define("SERIALPORTBASE", 9000);
|
//define("SERIALPORTBASE", 9000);
|
||||||
define("SERIALPORTBASE", (VNCPORTBASE + MAX_QEMUS * 2));
|
define("SERIALPORTBASE", (VNCPORTBASE + MAX_QEMUS * 2));
|
||||||
@@ -74,7 +80,7 @@ define("QEMU_ARGS", ""
|
|||||||
."-daemonize " /* detach from stdin */
|
."-daemonize " /* detach from stdin */
|
||||||
."-localtime " /* not UTC */
|
."-localtime " /* not UTC */
|
||||||
."-name '" . addslashes(PAGE_TITLE) . "' "
|
."-name '" . addslashes(PAGE_TITLE) . "' "
|
||||||
."-monitor /dev/null "
|
."-monitor null " /* disable the monitor */
|
||||||
."-serial none "
|
."-serial none "
|
||||||
."-parallel none "
|
."-parallel none "
|
||||||
."-net none "
|
."-net none "
|
||||||
@@ -87,7 +93,7 @@ define("QEMU_IMAGE_PATH", "/home/revol/haiku.image");
|
|||||||
// BAD: let's one download the image
|
// BAD: let's one download the image
|
||||||
//define("QEMU_IMAGE_PATH", dirname($_SERVER['SCRIPT_FILENAME']) . "/haiku.image");
|
//define("QEMU_IMAGE_PATH", dirname($_SERVER['SCRIPT_FILENAME']) . "/haiku.image");
|
||||||
|
|
||||||
// max number of cpus for the VM, not more than 8
|
// max number of cpus for the VM, no more than 8
|
||||||
define("QEMU_MAX_CPUS", 1);
|
define("QEMU_MAX_CPUS", 1);
|
||||||
|
|
||||||
// qemu 0.8.2 needs "", qemu 0.9.1 needs ":"
|
// qemu 0.8.2 needs "", qemu 0.9.1 needs ":"
|
||||||
@@ -96,6 +102,7 @@ define("QEMU_VNC_PREFIX", ":");
|
|||||||
// name of session and pid files in /tmp
|
// name of session and pid files in /tmp
|
||||||
define("QEMU_SESSFILE_TMPL", "qemu-haiku-session-");
|
define("QEMU_SESSFILE_TMPL", "qemu-haiku-session-");
|
||||||
define("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-");
|
define("QEMU_PIDFILE_TMPL", "qemu-haiku-pid-");
|
||||||
|
define("QEMU_LOGFILE_TMPL", "qemu-haiku-log-");
|
||||||
// name of session variable holding the qemu slot; not yet used correctly
|
// name of session variable holding the qemu slot; not yet used correctly
|
||||||
define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR");
|
define("QEMU_IDX_VAR", "QEMU_HAIKU_SESSION_VAR");
|
||||||
|
|
||||||
@@ -153,6 +160,11 @@ function make_qemu_pidfile_name($idx)
|
|||||||
return "/tmp/" . QEMU_PIDFILE_TMPL . $idx;
|
return "/tmp/" . QEMU_PIDFILE_TMPL . $idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function make_qemu_logfile_name($idx)
|
||||||
|
{
|
||||||
|
return "/tmp/" . QEMU_LOGFILE_TMPL . $idx;
|
||||||
|
}
|
||||||
|
|
||||||
function find_qemu_slot()
|
function find_qemu_slot()
|
||||||
{
|
{
|
||||||
for ($idx = 0; $idx < MAX_QEMUS; $idx++) {
|
for ($idx = 0; $idx < MAX_QEMUS; $idx++) {
|
||||||
@@ -379,9 +391,8 @@ function output_options_form()
|
|||||||
echo "</td>\n</tr>\n";
|
echo "</td>\n</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
$enable_sound = 1;
|
|
||||||
echo "<tr ";
|
echo "<tr ";
|
||||||
if (!$enable_sound)
|
if (!AUDIOENABLED)
|
||||||
echo "class=\"haiku_online_disabled\"";
|
echo "class=\"haiku_online_disabled\"";
|
||||||
echo ">\n";
|
echo ">\n";
|
||||||
echo "<td align=\"right\">\n";
|
echo "<td align=\"right\">\n";
|
||||||
@@ -389,7 +400,7 @@ function output_options_form()
|
|||||||
echo "</td>\n<td>\n";
|
echo "</td>\n<td>\n";
|
||||||
echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\" ";
|
echo "<input type=\"checkbox\" name=\"sound\" id=\"sound_cb\" ";
|
||||||
echo "value=\"1\" ";
|
echo "value=\"1\" ";
|
||||||
if ($enable_sound) {
|
if (AUDIOENABLED) {
|
||||||
//echo "checked=\"checked\" /";
|
//echo "checked=\"checked\" /";
|
||||||
} else
|
} else
|
||||||
echo "disabled=\"disabled\" /";
|
echo "disabled=\"disabled\" /";
|
||||||
@@ -452,8 +463,8 @@ function output_options_form()
|
|||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
out("NOTE: You will need a Java-enabled browser to display the VNC " .
|
out("NOTE: You will need a Java-enabled browser to display the VNC " .
|
||||||
"Applet needed by this demo.");
|
"Applet used by this demo. " .
|
||||||
out("You can however use instead an external <a " .
|
"You can however use instead an external <a " .
|
||||||
"href=\"http://fr.wikipedia.org/wiki/Virtual_Network_Computing\"" .
|
"href=\"http://fr.wikipedia.org/wiki/Virtual_Network_Computing\"" .
|
||||||
">VNC viewer</a>.");
|
">VNC viewer</a>.");
|
||||||
ob_flush();
|
ob_flush();
|
||||||
@@ -490,6 +501,7 @@ function start_qemu()
|
|||||||
return $idx;
|
return $idx;
|
||||||
}
|
}
|
||||||
$pidfile = make_qemu_pidfile_name($idx);
|
$pidfile = make_qemu_pidfile_name($idx);
|
||||||
|
$logfile = make_qemu_logfile_name($idx);
|
||||||
$cmd = '';
|
$cmd = '';
|
||||||
if (isset($_GET['sound'])) {
|
if (isset($_GET['sound'])) {
|
||||||
$cmd .= "QEMU_AUDIO_DRV=twolame ";
|
$cmd .= "QEMU_AUDIO_DRV=twolame ";
|
||||||
@@ -514,6 +526,9 @@ function start_qemu()
|
|||||||
" -vnc " . QEMU_VNC_PREFIX . vnc_display() .
|
" -vnc " . QEMU_VNC_PREFIX . vnc_display() .
|
||||||
" -pidfile " . $pidfile .
|
" -pidfile " . $pidfile .
|
||||||
" " . QEMU_IMAGE_PATH;
|
" " . QEMU_IMAGE_PATH;
|
||||||
|
//$cmd .= " || echo $? && echo done )";
|
||||||
|
// redirect output to log file
|
||||||
|
//$cmd .= " >$logfile 2>&1";
|
||||||
|
|
||||||
if (file_exists($pidfile))
|
if (file_exists($pidfile))
|
||||||
unlink($pidfile);
|
unlink($pidfile);
|
||||||
@@ -703,6 +718,8 @@ function output_applet_code($external_only=false)
|
|||||||
$class = VNCCLASS;
|
$class = VNCCLASS;
|
||||||
if ($external_only)
|
if ($external_only)
|
||||||
return;
|
return;
|
||||||
|
if (!VNC_HIDE_CONTROLS)
|
||||||
|
$h += 32;
|
||||||
echo "<a name=\"haiku_online_applet\"></a>";
|
echo "<a name=\"haiku_online_applet\"></a>";
|
||||||
echo "<center>";
|
echo "<center>";
|
||||||
echo "<applet code=$class codebase=\"$vncjpath/\" ";
|
echo "<applet code=$class codebase=\"$vncjpath/\" ";
|
||||||
@@ -715,7 +732,7 @@ function output_applet_code($external_only=false)
|
|||||||
if (defined('VNC_USE_PASS') && VNC_USE_PASS)
|
if (defined('VNC_USE_PASS') && VNC_USE_PASS)
|
||||||
$pass = $_SESSION['VNC_PASS'];
|
$pass = $_SESSION['VNC_PASS'];
|
||||||
echo "<param name=\"PASSWORD\" value=\"" . $pass . "\">\n";
|
echo "<param name=\"PASSWORD\" value=\"" . $pass . "\">\n";
|
||||||
if (defined("VNC_HIDE_CONTROLS") && VNC_HIDE_CONTROLS)
|
if (VNC_HIDE_CONTROLS)
|
||||||
echo "<param name=\"Show controls\" value=\"No\">\n";
|
echo "<param name=\"Show controls\" value=\"No\">\n";
|
||||||
//echo "<param name=\"share desktop\" value=\"no\" />";
|
//echo "<param name=\"share desktop\" value=\"no\" />";
|
||||||
echo "<param name=\"background-color\" value=\"#336698\">\n";
|
echo "<param name=\"background-color\" value=\"#336698\">\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user