Chromium Code Reviews| Index: media/audio/audio_manager_base.cc |
| diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc |
| index 7b79613774c2b66ad3031794daf7810f894a1ddf..bcf189efbe9dd5b96fd07e6ae3796f0f737f93f9 100644 |
| --- a/media/audio/audio_manager_base.cc |
| +++ b/media/audio/audio_manager_base.cc |
| @@ -14,6 +14,8 @@ |
| #include "media/audio/audio_util.h" |
| #include "media/audio/fake_audio_input_stream.h" |
| #include "media/audio/fake_audio_output_stream.h" |
| +#include "media/audio/virtual_audio_input_stream.h" |
| +#include "media/audio/virtual_audio_output_stream.h" |
| #include "media/base/media_switches.h" |
| // TODO(dalecurtis): Temporarily disabled while switching pipeline to use float, |
| @@ -45,7 +47,8 @@ AudioManagerBase::AudioManagerBase() |
| max_num_input_streams_(kDefaultMaxInputStreams), |
| num_output_streams_(0), |
| num_input_streams_(0), |
| - audio_thread_(new base::Thread("AudioThread")) { |
| + audio_thread_(new base::Thread("AudioThread")), |
| + virtual_audio_input_stream_(NULL) { |
| #if defined(OS_WIN) |
| audio_thread_->init_com_with_mta(true); |
| #endif |
| @@ -100,7 +103,14 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStream( |
| !HasAudioOutputDevices(); |
| AudioOutputStream* stream = NULL; |
| - if (audio_output_disabled) { |
| + if (virtual_audio_input_stream_ && |
| + params.format() != AudioParameters::AUDIO_FAKE) { |
| + // TODO(justinlin): This seems to sometimes be called twice for 1 video. |
|
Alpha Left Google
2012/11/28 01:04:47
What should this TODO do?
justinlin
2012/11/28 14:30:31
Right, I'll remove the TODO and fix this.
|
| + // They both attach, but then one of them detaches prematurely, and the |
| + // other one doesn't detach which causes a DCHECK fail? |
| + stream = VirtualAudioOutputStream::MakeStream(this, params, |
| + virtual_audio_input_stream_); |
| + } else if (audio_output_disabled) { |
| stream = FakeAudioOutputStream::MakeFakeStream(this, params); |
| } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { |
| stream = MakeLinearOutputStream(params); |
| @@ -130,7 +140,24 @@ AudioInputStream* AudioManagerBase::MakeAudioInputStream( |
| } |
| AudioInputStream* stream = NULL; |
| - if (params.format() == AudioParameters::AUDIO_FAKE) { |
| + if (params.format() == AudioParameters::AUDIO_MIRROR_BROWSER) { |
| + // TODO(justinlin): Currently, we can only support mirroring audio from 1 |
|
Alpha Left Google
2012/11/28 01:04:47
No need to mention tab.
You can just mention the
justinlin
2012/11/28 14:30:31
Done.
|
| + // tab, so subsequent tab capture requests will just get fake audio. |
| + // Maybe we should just return the same stream and ref-count, so that we |
| + // only actually destroy the stream when there's no mirroring? |
| + if (!virtual_audio_input_stream_) { |
| + virtual_audio_input_stream_ = |
| + VirtualAudioInputStream::MakeStream(this, params); |
| + stream = virtual_audio_input_stream_; |
| + message_loop_->PostTask(FROM_HERE, base::Bind( |
|
Alpha Left Google
2012/11/28 01:04:47
What would this task do?
justinlin
2012/11/28 14:30:31
NotifyAllOutputChangeListeners needs to be called
|
| + &AudioManagerBase::NotifyAllOutputDeviceChangeListeners, |
| + base::Unretained(this))); |
| + } else { |
| + // TODO(justinlin): Maybe we can return NULL if this doesn't cause the |
|
Alpha Left Google
2012/11/28 01:04:47
This code doesn't need a TODO isn't it?
justinlin
2012/11/28 14:30:31
Done.
|
| + // media request to fail? |
| + stream = FakeAudioInputStream::MakeFakeStream(this, params); |
| + } |
| + } else if (params.format() == AudioParameters::AUDIO_FAKE) { |
| stream = FakeAudioInputStream::MakeFakeStream(this, params); |
| } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) { |
| stream = MakeLinearInputStream(params, device_id); |
| @@ -233,6 +260,7 @@ void AudioManagerBase::GetAudioInputDeviceNames( |
| } |
| void AudioManagerBase::ReleaseOutputStream(AudioOutputStream* stream) { |
| + DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK(stream); |
| // TODO(xians) : Have a clearer destruction path for the AudioOutputStream. |
| // For example, pass the ownership to AudioManager so it can delete the |
| @@ -242,8 +270,16 @@ void AudioManagerBase::ReleaseOutputStream(AudioOutputStream* stream) { |
| } |
| void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { |
| + DCHECK(message_loop_->BelongsToCurrentThread()); |
| DCHECK(stream); |
| // TODO(xians) : Have a clearer destruction path for the AudioInputStream. |
| + |
| + if (virtual_audio_input_stream_ == stream) { |
| + virtual_audio_input_stream_->Stop(); |
| + virtual_audio_input_stream_ = NULL; |
| + NotifyAllOutputDeviceChangeListeners(); |
|
Alpha Left Google
2012/11/28 01:04:47
What should the output streams do? Write a comment
justinlin
2012/11/28 14:30:31
Done.
|
| + } |
| + |
| num_input_streams_--; |
| delete stream; |
| } |