summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 17:45:30 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-04 17:45:30 +0000
commitfa339bc179559f2e87856cd7ae3e74eef4ed4799 (patch)
tree917d0cae3923c9642b6b3f57c2691c493f22cc82
parent1a315b402f2723f9e2d3ad455b29767106fab612 (diff)
downloadchromium_src-fa339bc179559f2e87856cd7ae3e74eef4ed4799.zip
chromium_src-fa339bc179559f2e87856cd7ae3e74eef4ed4799.tar.gz
chromium_src-fa339bc179559f2e87856cd7ae3e74eef4ed4799.tar.bz2
Fix crash in ScreenRecorder
BUG=91620 TEST=Host doesn't crash Review URL: http://codereview.chromium.org/7563026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95440 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/screen_recorder.cc6
-rw-r--r--remoting/host/screen_recorder.h5
2 files changed, 9 insertions, 2 deletions
diff --git a/remoting/host/screen_recorder.cc b/remoting/host/screen_recorder.cc
index 0b1d1d1..1a05797 100644
--- a/remoting/host/screen_recorder.cc
+++ b/remoting/host/screen_recorder.cc
@@ -47,6 +47,7 @@ ScreenRecorder::ScreenRecorder(
encoder_(encoder),
is_recording_(false),
network_stopped_(false),
+ encoder_stopped_(false),
recordings_(0),
frame_skipped_(false),
max_rate_(kDefaultCaptureRate),
@@ -387,6 +388,8 @@ void ScreenRecorder::DoEncode(
void ScreenRecorder::DoStopOnEncodeThread(Task* done_task) {
DCHECK_EQ(encode_loop_, MessageLoop::current());
+ encoder_stopped_ = true;
+
// When this method is being executed there are no more tasks on encode thread
// for this object. We can then post a task to capture thread to finish the
// stop sequence.
@@ -397,6 +400,9 @@ void ScreenRecorder::DoStopOnEncodeThread(Task* done_task) {
void ScreenRecorder::EncodedDataAvailableCallback(VideoPacket* packet) {
DCHECK_EQ(encode_loop_, MessageLoop::current());
+ if (encoder_stopped_)
+ return;
+
bool last = (packet->flags() & VideoPacket::LAST_PACKET) != 0;
if (last) {
int encode_time = static_cast<int>(
diff --git a/remoting/host/screen_recorder.h b/remoting/host/screen_recorder.h
index 0426ea7..3007aa5 100644
--- a/remoting/host/screen_recorder.h
+++ b/remoting/host/screen_recorder.h
@@ -180,9 +180,10 @@ class ScreenRecorder : public base::RefCountedThreadSafe<ScreenRecorder> {
// be used on the capture thread.
bool is_recording_;
- // Flag that indicates network is being stopped. This variable should only
- // be used on the network thread.
+ // Per-thread flags that are set when the ScreenRecorder is
+ // stopped. They must be used on the corresponding threads only.
bool network_stopped_;
+ bool encoder_stopped_;
// Timer that calls DoCapture.
base::RepeatingTimer<ScreenRecorder> capture_timer_;