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

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: 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
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..d931b70f3623f81b26296d151bf9c326eb3cf4f3 100644
--- a/webrtc/modules/audio_processing/test/wav_based_simulator.cc
+++ b/webrtc/modules/audio_processing/test/wav_based_simulator.cc
@@ -10,19 +10,59 @@
#include "webrtc/modules/audio_processing/test/wav_based_simulator.h"
+#include <string.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");
+
+ if (!stream) {
hlundin-webrtc 2016/12/09 10:40:17 This is test/tools code. Crashing and burning rath
peah-webrtc 2016/12/09 10:49:59 Done.
+ std::cout << "Could not open the custom call order file, reverting to "
+ "using the default call order";
+ return WavBasedSimulator::GetDefaultEventChain();
+ }
+
+ char c;
+ size_t num_read = fread(&c, sizeof(char), 1, stream);
ivoc 2016/12/09 10:28:20 I think this is defined in <stdio.h>, shouldn't th
peah-webrtc 2016/12/09 10:49:59 Good point! I removed the inclusion of <string.h>
+ 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:
+ std::cout << "Incorrect custom call order file, reverting to using the "
hlundin-webrtc 2016/12/09 10:40:17 FATAL() << "What kind of input is this?!";
peah-webrtc 2016/12/09 10:49:59 Done.
+ "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 {
aleloi 2016/12/09 10:25:44 Why is GetDefaultEventChain not const now?
hlundin-webrtc 2016/12/09 10:40:17 It was made static in the header file.
peah-webrtc 2016/12/09 10:49:59 I made it static which caused it not possible to m
peah-webrtc 2016/12/09 10:49:59 Acknowledged.
+WavBasedSimulator::GetDefaultEventChain() {
std::vector<WavBasedSimulator::SimulationEventType> call_chain(2);
call_chain[0] = SimulationEventType::kProcessStream;
call_chain[1] = SimulationEventType::kProcessReverseStream;
@@ -59,7 +99,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();

Powered by Google App Engine
This is Rietveld 408576698