[Cast] Fix Standalone Sender/Receiver
Over the last year, the standalone sender and receiver applications have
gone through some major changes, and unfortunately a few regressions
have been introduced.
This patch fixes the poor performance. This was actually caused by a "fix" to the
PlatformClientPosix implementation, where we were using inappropriate
values for network looping (50ms, which is an eternity).
Bug: b/182937147
Change-Id: I39af927401ce940b81829e5b2992e06bc544ef01
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2792912
Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
diff --git a/cast/standalone_receiver/main.cc b/cast/standalone_receiver/main.cc
index 1263f39..9faee41 100644
--- a/cast/standalone_receiver/main.cc
+++ b/cast/standalone_receiver/main.cc
@@ -230,7 +230,9 @@
}
auto* const task_runner = new TaskRunnerImpl(&Clock::now);
- PlatformClientPosix::Create(milliseconds(50), milliseconds(50),
+ // Cast has high networking demands--network operation timing and timeout must
+ // be kept extremely small.
+ PlatformClientPosix::Create(microseconds(50), microseconds(50),
std::unique_ptr<TaskRunnerImpl>(task_runner));
RunCastService(task_runner, interface, std::move(creds.value()),
friendly_name, model_name, discovery_enabled);
diff --git a/cast/standalone_sender/main.cc b/cast/standalone_sender/main.cc
index da7ed24..7479adc 100644
--- a/cast/standalone_sender/main.cc
+++ b/cast/standalone_sender/main.cc
@@ -174,7 +174,9 @@
#endif
auto* const task_runner = new TaskRunnerImpl(&Clock::now);
- PlatformClientPosix::Create(milliseconds(50), milliseconds(50),
+ // Cast has high networking demands--network operation timing and timeout must
+ // be kept extremely small.
+ PlatformClientPosix::Create(microseconds(50), microseconds(50),
std::unique_ptr<TaskRunnerImpl>(task_runner));
IPEndpoint remote_endpoint = ParseAsEndpoint(iface_or_endpoint);
diff --git a/platform/impl/platform_client_posix.h b/platform/impl/platform_client_posix.h
index 6bda424..9f086f5 100644
--- a/platform/impl/platform_client_posix.h
+++ b/platform/impl/platform_client_posix.h
@@ -9,6 +9,7 @@
#include <memory>
#include <mutex>
#include <thread>
+#include <vector>
#include "absl/types/optional.h"
#include "platform/api/time.h"
@@ -41,7 +42,8 @@
// |networking_loop_interval| sets the minimum amount of time that should pass
// between iterations of the loop used to handle networking operations. Higher
// values will result in less time being spent on these operations, but also
- // potentially less performant networking operations.
+ // less performant networking operations. Be careful setting values larger
+ // than a few hundred microseconds.
//
// |networking_operation_timeout| sets how much time may be spent on a
// single networking operation type.