rtc::Event: Remove call site dependency on kForever being int.
In migrating rtc::Event to use TimeDelta instead of int, rtc::Event::kForever will have to become something else. This change removes dependencies on that kForever is int. Bug: webrtc:14366 Change-Id: Ic36057dda95513349e7ae60204e7271ff1f58825 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/271288 Auto-Submit: Markus Handell <handellm@webrtc.org> Reviewed-by: Magnus Flodman <mflodman@webrtc.org> Commit-Queue: Magnus Flodman <mflodman@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37795}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
f4f22872d0
commit
0931599e14
@ -142,16 +142,10 @@ class TestAudioDeviceModuleImpl
|
|||||||
return capturing_;
|
return capturing_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blocks until the Renderer refuses to receive data.
|
|
||||||
// Returns false if `timeout_ms` passes before that happens.
|
|
||||||
bool WaitForPlayoutEnd(int timeout_ms = rtc::Event::kForever) override {
|
|
||||||
return done_rendering_.Wait(timeout_ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blocks until the Recorder stops producing data.
|
// Blocks until the Recorder stops producing data.
|
||||||
// Returns false if `timeout_ms` passes before that happens.
|
// Returns false if `timeout_ms` passes before that happens.
|
||||||
bool WaitForRecordingEnd(int timeout_ms = rtc::Event::kForever) override {
|
bool WaitForRecordingEnd() override {
|
||||||
return done_capturing_.Wait(timeout_ms);
|
return done_capturing_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "modules/audio_device/include/audio_device.h"
|
#include "modules/audio_device/include/audio_device.h"
|
||||||
#include "modules/audio_device/include/audio_device_defines.h"
|
#include "modules/audio_device/include/audio_device_defines.h"
|
||||||
#include "rtc_base/buffer.h"
|
#include "rtc_base/buffer.h"
|
||||||
#include "rtc_base/event.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -141,12 +140,9 @@ class TestAudioDeviceModule : public AudioDeviceModule {
|
|||||||
bool Playing() const override = 0;
|
bool Playing() const override = 0;
|
||||||
bool Recording() const override = 0;
|
bool Recording() const override = 0;
|
||||||
|
|
||||||
// Blocks until the Renderer refuses to receive data.
|
|
||||||
// Returns false if `timeout_ms` passes before that happens.
|
|
||||||
virtual bool WaitForPlayoutEnd(int timeout_ms = rtc::Event::kForever) = 0;
|
|
||||||
// Blocks until the Recorder stops producing data.
|
// Blocks until the Recorder stops producing data.
|
||||||
// Returns false if `timeout_ms` passes before that happens.
|
// Returns false if `timeout_ms` passes before that happens.
|
||||||
virtual bool WaitForRecordingEnd(int timeout_ms = rtc::Event::kForever) = 0;
|
virtual bool WaitForRecordingEnd() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -108,13 +108,13 @@ class DataChannelObserverImpl : public webrtc::DataChannelObserver {
|
|||||||
low_buffered_threshold_event_.Reset();
|
low_buffered_threshold_event_.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaitForOpenState(int duration_ms) {
|
bool WaitForOpenState() {
|
||||||
return dc_->state() == webrtc::DataChannelInterface::DataState::kOpen ||
|
return dc_->state() == webrtc::DataChannelInterface::DataState::kOpen ||
|
||||||
open_event_.Wait(duration_ms);
|
open_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
bool WaitForClosedState(int duration_ms) {
|
bool WaitForClosedState() {
|
||||||
return dc_->state() == webrtc::DataChannelInterface::DataState::kClosed ||
|
return dc_->state() == webrtc::DataChannelInterface::DataState::kClosed ||
|
||||||
closed_event_.Wait(duration_ms);
|
closed_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set how many received bytes are required until
|
// Set how many received bytes are required until
|
||||||
@ -125,18 +125,18 @@ class DataChannelObserverImpl : public webrtc::DataChannelObserver {
|
|||||||
bytes_received_event_.Set();
|
bytes_received_event_.Set();
|
||||||
}
|
}
|
||||||
// Wait until the received byte count reaches the desired value.
|
// Wait until the received byte count reaches the desired value.
|
||||||
bool WaitForBytesReceivedThreshold(int duration_ms) {
|
bool WaitForBytesReceivedThreshold() {
|
||||||
return (bytes_received_threshold_ &&
|
return (bytes_received_threshold_ &&
|
||||||
bytes_received_ >= bytes_received_threshold_) ||
|
bytes_received_ >= bytes_received_threshold_) ||
|
||||||
bytes_received_event_.Wait(duration_ms);
|
bytes_received_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaitForLowbufferedThreshold(int duration_ms) {
|
bool WaitForLowbufferedThreshold() {
|
||||||
return low_buffered_threshold_event_.Wait(duration_ms);
|
return low_buffered_threshold_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
std::string SetupMessage() { return setup_message_; }
|
std::string SetupMessage() { return setup_message_; }
|
||||||
bool WaitForSetupMessage(int duration_ms) {
|
bool WaitForSetupMessage() {
|
||||||
return setup_message_event_.Wait(duration_ms);
|
return setup_message_event_.Wait(rtc::Event::kForever);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -182,7 +182,7 @@ int RunServer() {
|
|||||||
// It configures how much data should be sent and how big the packets
|
// It configures how much data should be sent and how big the packets
|
||||||
// should be.
|
// should be.
|
||||||
// First message is "packet_size,transfer_size".
|
// First message is "packet_size,transfer_size".
|
||||||
data_channel_observer->WaitForSetupMessage(rtc::Event::kForever);
|
data_channel_observer->WaitForSetupMessage();
|
||||||
auto parameters =
|
auto parameters =
|
||||||
SetupMessage::FromString(data_channel_observer->SetupMessage());
|
SetupMessage::FromString(data_channel_observer->SetupMessage());
|
||||||
|
|
||||||
@ -204,8 +204,7 @@ int RunServer() {
|
|||||||
if (!data_channel->Send(data_buffer)) {
|
if (!data_channel->Send(data_buffer)) {
|
||||||
// If the send() call failed, the buffers are full.
|
// If the send() call failed, the buffers are full.
|
||||||
// We wait until there's more room.
|
// We wait until there's more room.
|
||||||
data_channel_observer->WaitForLowbufferedThreshold(
|
data_channel_observer->WaitForLowbufferedThreshold();
|
||||||
rtc::Event::kForever);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
remaining_data -= buffer.size();
|
remaining_data -= buffer.size();
|
||||||
@ -217,7 +216,7 @@ int RunServer() {
|
|||||||
|
|
||||||
// Receiver signals the data channel close event when it has received
|
// Receiver signals the data channel close event when it has received
|
||||||
// all the data it requested.
|
// all the data it requested.
|
||||||
data_channel_observer->WaitForClosedState(rtc::Event::kForever);
|
data_channel_observer->WaitForClosedState();
|
||||||
|
|
||||||
auto end_time = webrtc::Clock::GetRealTimeClock()->CurrentTime();
|
auto end_time = webrtc::Clock::GetRealTimeClock()->CurrentTime();
|
||||||
auto duration_ms = (end_time - begin_time).ms<size_t>();
|
auto duration_ms = (end_time - begin_time).ms<size_t>();
|
||||||
@ -280,7 +279,7 @@ int RunClient() {
|
|||||||
|
|
||||||
// Send a configuration string to the server to tell it to send
|
// Send a configuration string to the server to tell it to send
|
||||||
// 'packet_size' bytes packets and send a total of 'transfer_size' MB.
|
// 'packet_size' bytes packets and send a total of 'transfer_size' MB.
|
||||||
observer.WaitForOpenState(rtc::Event::kForever);
|
observer.WaitForOpenState();
|
||||||
SetupMessage setup_message = {
|
SetupMessage setup_message = {
|
||||||
.packet_size = packet_size,
|
.packet_size = packet_size,
|
||||||
.transfer_size = transfer_size,
|
.transfer_size = transfer_size,
|
||||||
@ -291,7 +290,7 @@ int RunClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait until we have received all the data
|
// Wait until we have received all the data
|
||||||
observer.WaitForBytesReceivedThreshold(rtc::Event::kForever);
|
observer.WaitForBytesReceivedThreshold();
|
||||||
|
|
||||||
// Close the data channel, signaling to the server we have received
|
// Close the data channel, signaling to the server we have received
|
||||||
// all the requested data.
|
// all the requested data.
|
||||||
|
Reference in New Issue
Block a user