summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorperkj@chromium.org <perkj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-27 13:10:30 +0000
committerperkj@chromium.org <perkj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-27 13:10:30 +0000
commit5ec711b14cc8d226cc7814153b9bd81d8de6be9a (patch)
treea1d0a4e925b9594187d8ac83096d1765b04ecabe /media
parent635e7bfc1f92b8aeec113a5e1c39739556a93952 (diff)
downloadchromium_src-5ec711b14cc8d226cc7814153b9bd81d8de6be9a.zip
chromium_src-5ec711b14cc8d226cc7814153b9bd81d8de6be9a.tar.gz
chromium_src-5ec711b14cc8d226cc7814153b9bd81d8de6be9a.tar.bz2
Fix crash when trying to use a camera that is already in use.
This cl change the behaviour of VideoCaptureManager to not report errors that occur after a stream have been created. Ie - MediaStreamManager should not be told that starting a video capture device have failed since the video capture was not started through the MediaStreamManager. Instead - only the client that tried to start the video capture is notified of the error. BUG=152158 TEST= See the defect report. Review URL: https://chromiumcodereview.appspot.com/10990027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159011 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/video/capture/fake_video_capture_device.cc10
-rw-r--r--media/video/capture/fake_video_capture_device.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/media/video/capture/fake_video_capture_device.cc b/media/video/capture/fake_video_capture_device.cc
index ec64d60..7512060 100644
--- a/media/video/capture/fake_video_capture_device.cc
+++ b/media/video/capture/fake_video_capture_device.cc
@@ -15,6 +15,8 @@ namespace media {
static const int kFakeCaptureTimeoutMs = 100;
enum { kNumberOfFakeDevices = 2 };
+bool FakeVideoCaptureDevice::fail_next_create_ = false;
+
void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) {
// Empty the name list.
device_names->erase(device_names->begin(), device_names->end());
@@ -28,6 +30,10 @@ void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) {
}
VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
+ if (fail_next_create_) {
+ fail_next_create_ = false;
+ return NULL;
+ }
for (int n = 0; n < kNumberOfFakeDevices; ++n) {
std::string possible_id = StringPrintf("/dev/video%d", n);
if (device_name.unique_id.compare(possible_id) == 0) {
@@ -37,6 +43,10 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
return NULL;
}
+void FakeVideoCaptureDevice::SetFailNextCreate() {
+ fail_next_create_ = true;
+}
+
FakeVideoCaptureDevice::FakeVideoCaptureDevice(const Name& device_name)
: device_name_(device_name),
observer_(NULL),
diff --git a/media/video/capture/fake_video_capture_device.h b/media/video/capture/fake_video_capture_device.h
index a80f945..bbb7569 100644
--- a/media/video/capture/fake_video_capture_device.h
+++ b/media/video/capture/fake_video_capture_device.h
@@ -20,6 +20,9 @@ class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
public:
static VideoCaptureDevice* Create(const Name& device_name);
virtual ~FakeVideoCaptureDevice();
+ // Used for testing. This will make sure the next call to Create will
+ // return NULL;
+ static void SetFailNextCreate();
static void GetDeviceNames(Names* device_names);
@@ -53,6 +56,8 @@ class MEDIA_EXPORT FakeVideoCaptureDevice : public VideoCaptureDevice {
int frame_size_;
scoped_array<uint8> fake_frame_;
+ static bool fail_next_create_;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(FakeVideoCaptureDevice);
};