Commit 74c5133a authored by miu@chromium.org's avatar miu@chromium.org

Fix for AudioEncoder crash when using cast.streaming API.

A subtle race condition was occurring between the destruction of the AudioBus
and a while-loop's final dereferencing of the audio_bus pointer before
breaking.

BUG=332623

Review URL: https://codereview.chromium.org/132783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244288 0039d316-1c4b-4281-b951-d872f2087c98
parent f8a3d7b7
......@@ -59,7 +59,7 @@ class AudioEncoder::ImplBase {
const base::TimeTicks& recorded_time,
const base::Closure& done_callback) {
int src_pos = 0;
while (src_pos < audio_bus->frames()) {
while (audio_bus && src_pos < audio_bus->frames()) {
const int num_samples_to_xfer =
std::min(samples_per_10ms_ - buffer_fill_end_,
audio_bus->frames() - src_pos);
......@@ -72,7 +72,8 @@ class AudioEncoder::ImplBase {
if (src_pos == audio_bus->frames()) {
cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE,
done_callback);
// Note: |audio_bus| is now invalid..
// Note: |audio_bus| is invalid once done_callback is invoked.
audio_bus = NULL;
}
if (buffer_fill_end_ == samples_per_10ms_) {
......
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