Commit fa339bc1 authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

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
parent 1a315b40
......@@ -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>(
......
......@@ -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_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment