Skip to content

Commit

Permalink
Ppapi audio: don't terminate thread on all negative pending_data.
Browse files Browse the repository at this point in the history
pending_data should be used exclusively for synchronisation purposes, and not
as an indication of the fill level of the playback buffer. Change condition
to only quit on kPauseMark.

BUG=chromium-os:26151
TEST=Stressed as described in bug and watched Lumpy survive negative numbers.
Review URL: https://chromiumcodereview.appspot.com/9958093

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130808 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ihf@chromium.org committed Apr 5, 2012
1 parent cf314aa commit 028b90f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ppapi/shared_impl/ppb_audio_shared.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -8,6 +8,8 @@

namespace ppapi {

const int PPB_Audio_Shared::kPauseMark = -1;

PPB_Audio_Shared::PPB_Audio_Shared()
: playing_(false),
shared_memory_size_(0),
Expand Down Expand Up @@ -86,7 +88,7 @@ void PPB_Audio_Shared::Run() {

while (sizeof(pending_data) ==
socket_->Receive(&pending_data, sizeof(pending_data)) &&
pending_data >= 0) {
pending_data != kPauseMark) {
callback_(buffer, shared_memory_size_, user_data_);
}
}
Expand Down
5 changes: 4 additions & 1 deletion ppapi/shared_impl/ppb_audio_shared.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -25,6 +25,9 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared
PPB_Audio_Shared();
virtual ~PPB_Audio_Shared();

// Keep in sync with media::AudioOutputController::kPauseMark.
static const int kPauseMark;

bool playing() const { return playing_; }

// Sets the callback information that the background thread will use. This
Expand Down
1 change: 1 addition & 0 deletions webkit/plugins/ppapi/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include_rules = [
"+ppapi/shared_impl",
"+ppapi/thunk",
"+printing",
"+media/audio",
"+media/video",
"+ui/base/ime",
"+ui/base/range",
Expand Down
3 changes: 3 additions & 0 deletions webkit/plugins/ppapi/ppb_audio_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "webkit/plugins/ppapi/ppb_audio_impl.h"

#include "base/logging.h"
#include "media/audio/audio_output_controller.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_audio_config.h"
Expand Down Expand Up @@ -52,6 +53,8 @@ PP_Resource PPB_Audio_Impl::Create(PP_Instance instance,
scoped_refptr<PPB_Audio_Impl> audio(new PPB_Audio_Impl(instance));
if (!audio->Init(config, audio_callback, user_data))
return 0;
CHECK(media::AudioOutputController::kPauseMark ==
::ppapi::PPB_Audio_Shared::kPauseMark);
return audio->GetReference();
}

Expand Down

0 comments on commit 028b90f

Please sign in to comment.