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

Unified Diff: media/video/capture/fake_video_capture_device.cc

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 | « media/video/capture/fake_video_capture_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/fake_video_capture_device.cc
diff --git a/media/video/capture/fake_video_capture_device.cc b/media/video/capture/fake_video_capture_device.cc
index ef44d86488497ef9d7d452f38bc2a8521d6c0863..81bc9b8931b46ebcb4233bd15d3783a7eac5b4ee 100644
--- a/media/video/capture/fake_video_capture_device.cc
+++ b/media/video/capture/fake_video_capture_device.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "media/audio/fake_audio_input_stream.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -22,14 +23,17 @@ static const int kFakeCaptureCapabilityChangePeriod = 30;
enum { kNumberOfFakeDevices = 2 };
bool FakeVideoCaptureDevice::fail_next_create_ = false;
+base::subtle::Atomic32 FakeVideoCaptureDevice::number_of_devices_ =
+ kNumberOfFakeDevices;
void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) {
// Empty the name list.
device_names->erase(device_names->begin(), device_names->end());
- for (int n = 0; n < kNumberOfFakeDevices; n++) {
- Name name(base::StringPrintf("fake_device_%d", n),
- base::StringPrintf("/dev/video%d", n));
+ int number_of_devices = base::subtle::NoBarrier_Load(&number_of_devices_);
+ for (int32 n = 0; n < number_of_devices; n++) {
+ Name name("fake_device_" + base::IntToString(n),
+ "/dev/video" + base::IntToString(n));
device_names->push_back(name);
}
}
@@ -51,8 +55,9 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
fail_next_create_ = false;
return NULL;
}
- for (int n = 0; n < kNumberOfFakeDevices; ++n) {
- std::string possible_id = base::StringPrintf("/dev/video%d", n);
+ int number_of_devices = base::subtle::NoBarrier_Load(&number_of_devices_);
+ for (int32 n = 0; n < number_of_devices; ++n) {
+ std::string possible_id = "/dev/video" + base::IntToString(n);
if (device_name.id().compare(possible_id) == 0) {
return new FakeVideoCaptureDevice();
}
@@ -64,6 +69,11 @@ void FakeVideoCaptureDevice::SetFailNextCreate() {
fail_next_create_ = true;
}
+void FakeVideoCaptureDevice::SetNumberOfFakeDevices(size_t number_of_devices) {
+ base::subtle::NoBarrier_AtomicExchange(&number_of_devices_,
+ number_of_devices);
+}
+
FakeVideoCaptureDevice::FakeVideoCaptureDevice()
: state_(kIdle),
capture_thread_("CaptureThread"),
« no previous file with comments | « media/video/capture/fake_video_capture_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698