Start stream_audio from launch_cvd
It looks like there's an unassigned gap around port 7444, which is
easy since we have 6444 for vnc.
https://www.speedguide.net/port.php?port=7444
Enabling by default because stream_audio doesn't do any real work until
the first client connects.
Bug: 120027270
Test: launch pie on vsoc-02, stream youtube on 7445
Change-Id: Iae815f95e0392c5eb0e8be64ffb619742d2e778a
diff --git a/host/commands/launch/main.cc b/host/commands/launch/main.cc
index f4abc78..0f1276e 100644
--- a/host/commands/launch/main.cc
+++ b/host/commands/launch/main.cc
@@ -135,6 +135,11 @@
DEFINE_string(vnc_server_binary,
vsoc::DefaultHostArtifactsPath("bin/vnc_server"),
"Location of the vnc server binary.");
+DEFINE_bool(start_stream_audio, true,
+ "Whether to start the stream audio process.");
+DEFINE_string(stream_audio_binary,
+ vsoc::DefaultHostArtifactsPath("bin/stream_audio"),
+ "Location of the stream_audio binary.");
DEFINE_string(virtual_usb_manager_binary,
vsoc::DefaultHostArtifactsPath("bin/virtual_usb_manager"),
"Location of the virtual usb manager binary.");
@@ -146,6 +151,8 @@
"Location of the ivshmem server binary.");
DEFINE_int32(vnc_server_port, GetPerInstanceDefault(6444),
"The port on which the vnc server should listen");
+DEFINE_int32(stream_audio_port, GetPerInstanceDefault(7444),
+ "The port on which stream_audio should listen.");
DEFINE_string(socket_forward_proxy_binary,
vsoc::DefaultHostArtifactsPath("bin/socket_forward_proxy"),
"Location of the socket_forward_proxy binary.");
@@ -529,6 +536,16 @@
}
}
+void LaunchStreamAudioIfEnabled(cvd::ProcessMonitor* process_monitor) {
+ if (FLAGS_start_stream_audio) {
+ auto port_options = "-port=" + std::to_string(FLAGS_stream_audio_port);
+ cvd::Command stream_audio(FLAGS_stream_audio_binary);
+ stream_audio.AddParameter(port_options);
+ process_monitor->StartSubprocess(std::move(stream_audio),
+ OnSubprocessExitCallback);
+ }
+}
+
bool ResolveInstanceFiles() {
if (FLAGS_system_image_dir.empty()) {
LOG(ERROR) << "--system_image_dir must be specified.";
@@ -1169,6 +1186,7 @@
LaunchSocketForwardProxyIfEnabled(&process_monitor);
LaunchVNCServerIfEnabled(&process_monitor);
+ LaunchStreamAudioIfEnabled(&process_monitor);
LaunchAdbConnectorIfEnabled(&process_monitor);
ServerLoop(launcher_monitor_socket, vm_manager); // Should not return