Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(910)

Unified Diff: webrtc/modules/audio_processing/test/wav_based_simulator.cc

Issue 2561843003: Added functionality for simulating custom orders of the stream API calls in audioproc_f (Closed)
Patch Set: Changes in response to reviewer comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/audio_processing/test/wav_based_simulator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_processing/test/wav_based_simulator.cc
diff --git a/webrtc/modules/audio_processing/test/wav_based_simulator.cc b/webrtc/modules/audio_processing/test/wav_based_simulator.cc
index dd680dfdfbeb4da552a0024f5ed7f3c6f0619dd4..6cf0b744e6f5c040c81f7b8798e0992008c96b63 100644
--- a/webrtc/modules/audio_processing/test/wav_based_simulator.cc
+++ b/webrtc/modules/audio_processing/test/wav_based_simulator.cc
@@ -10,19 +10,57 @@
#include "webrtc/modules/audio_processing/test/wav_based_simulator.h"
+#include <stdio.h>
+#include <iostream>
+
#include "webrtc/base/checks.h"
+#include "webrtc/modules/audio_processing/test/test_utils.h"
#include "webrtc/test/testsupport/trace_to_stderr.h"
namespace webrtc {
namespace test {
+std::vector<WavBasedSimulator::SimulationEventType>
+WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
+ std::vector<WavBasedSimulator::SimulationEventType> call_chain;
+ FILE* stream = OpenFile(filename.c_str(), "r");
+
+ RTC_CHECK(stream) << "Could not open the custom call order file, reverting "
+ "to using the default call order";
+
+ char c;
+ size_t num_read = fread(&c, sizeof(char), 1, stream);
+ while (num_read > 0) {
+ switch (c) {
+ case 'r':
+ call_chain.push_back(SimulationEventType::kProcessReverseStream);
+ break;
+ case 'c':
+ call_chain.push_back(SimulationEventType::kProcessStream);
+ break;
+ case '\n':
+ break;
+ default:
+ FATAL() << "Incorrect custom call order file, reverting to using the "
+ "default call order";
+ fclose(stream);
+ return WavBasedSimulator::GetDefaultEventChain();
+ }
+
+ num_read = fread(&c, sizeof(char), 1, stream);
+ }
+
+ fclose(stream);
+ return call_chain;
+}
+
WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings)
: AudioProcessingSimulator(settings) {}
WavBasedSimulator::~WavBasedSimulator() = default;
std::vector<WavBasedSimulator::SimulationEventType>
-WavBasedSimulator::GetDefaultEventChain() const {
+WavBasedSimulator::GetDefaultEventChain() {
std::vector<WavBasedSimulator::SimulationEventType> call_chain(2);
call_chain[0] = SimulationEventType::kProcessStream;
call_chain[1] = SimulationEventType::kProcessReverseStream;
@@ -59,7 +97,12 @@ void WavBasedSimulator::Process() {
trace_to_stderr.reset(new test::TraceToStderr(true));
}
- call_chain_ = GetDefaultEventChain();
+ if (settings_.custom_call_order_filename) {
+ call_chain_ = WavBasedSimulator::GetCustomEventChain(
+ *settings_.custom_call_order_filename);
+ } else {
+ call_chain_ = WavBasedSimulator::GetDefaultEventChain();
+ }
CreateAudioProcessor();
Initialize();
« no previous file with comments | « webrtc/modules/audio_processing/test/wav_based_simulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698