Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1717)

Unified Diff: content/renderer/pepper/pepper_platform_audio_output_impl.cc

Issue 12383016: Merge AssociateStreamWithProducer message into CreateStream message for both audio output and input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_platform_audio_output_impl.cc
diff --git a/content/renderer/pepper/pepper_platform_audio_output_impl.cc b/content/renderer/pepper/pepper_platform_audio_output_impl.cc
index 90ec7ebfc677f036fd66d707a0e6c2acf670e018..683227d21438508c2aad61a4913448b425b2b96b 100644
--- a/content/renderer/pepper/pepper_platform_audio_output_impl.cc
+++ b/content/renderer/pepper/pepper_platform_audio_output_impl.cc
@@ -25,9 +25,8 @@ PepperPlatformAudioOutputImpl* PepperPlatformAudioOutputImpl::Create(
int source_render_view_id,
webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
scoped_refptr<PepperPlatformAudioOutputImpl> audio_output(
- new PepperPlatformAudioOutputImpl());
- if (audio_output->Initialize(sample_rate, frames_per_buffer,
- source_render_view_id, client)) {
+ new PepperPlatformAudioOutputImpl(source_render_view_id));
+ if (audio_output->Initialize(sample_rate, frames_per_buffer, client)) {
// Balanced by Release invoked in
// PepperPlatformAudioOutputImpl::ShutDownOnIOThread().
audio_output->AddRef();
@@ -97,27 +96,30 @@ void PepperPlatformAudioOutputImpl::OnStreamCreated(
}
void PepperPlatformAudioOutputImpl::OnIPCClosed() {
- ipc_ = NULL;
+ ipc_.reset();
+ stream_created_ = false;
}
PepperPlatformAudioOutputImpl::~PepperPlatformAudioOutputImpl() {
// Make sure we have been shut down. Warning: this will usually happen on
// the I/O thread!
- DCHECK_EQ(0, stream_id_);
+ DCHECK(!stream_created_);
DCHECK(!client_);
}
-PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl()
+PepperPlatformAudioOutputImpl::PepperPlatformAudioOutputImpl(
+ int source_render_view_id)
: client_(NULL),
- stream_id_(0),
+ ipc_(AudioMessageFilter::Get()->CreateAudioOutputIPC(
+ source_render_view_id)),
+ stream_created_(false),
main_message_loop_proxy_(base::MessageLoopProxy::current()) {
- ipc_ = RenderThreadImpl::current()->audio_message_filter();
+ CHECK(ipc_);
}
bool PepperPlatformAudioOutputImpl::Initialize(
int sample_rate,
int frames_per_buffer,
- int source_render_view_id,
webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client) {
DCHECK(client);
client_ = client;
@@ -149,39 +151,38 @@ bool PepperPlatformAudioOutputImpl::Initialize(
ChildProcess::current()->io_message_loop()->PostTask(
FROM_HERE,
base::Bind(&PepperPlatformAudioOutputImpl::InitializeOnIOThread,
- this, params, source_render_view_id));
+ this, params));
return true;
}
void PepperPlatformAudioOutputImpl::InitializeOnIOThread(
- const media::AudioParameters& params, int source_render_view_id) {
+ const media::AudioParameters& params) {
// Make sure we don't call init more than once.
- DCHECK_EQ(0, stream_id_);
- stream_id_ = ipc_->AddDelegate(this);
- DCHECK_NE(0, stream_id_);
+ DCHECK(!stream_created_);
- ipc_->CreateStream(stream_id_, params);
- ipc_->AssociateStreamWithProducer(stream_id_, source_render_view_id);
+ if (ipc_) {
+ ipc_->CreateStream(this, params);
+ stream_created_ = true;
+ }
}
void PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread() {
- if (stream_id_)
- ipc_->PlayStream(stream_id_);
+ if (stream_created_)
+ ipc_->PlayStream();
}
void PepperPlatformAudioOutputImpl::StopPlaybackOnIOThread() {
- if (stream_id_)
- ipc_->PauseStream(stream_id_);
+ if (stream_created_)
+ ipc_->PauseStream();
}
void PepperPlatformAudioOutputImpl::ShutDownOnIOThread() {
// Make sure we don't call shutdown more than once.
- if (!stream_id_)
+ if (!stream_created_)
return;
- ipc_->CloseStream(stream_id_);
- ipc_->RemoveDelegate(stream_id_);
- stream_id_ = 0;
+ ipc_->CloseStream();
+ stream_created_ = false;
Release(); // Release for the delegate, balances out the reference taken in
// PepperPluginDelegateImpl::CreateAudio.

Powered by Google App Engine
This is Rietveld 408576698