| Index: media/audio/audio_output_dispatcher_impl.cc
|
| diff --git a/media/audio/audio_output_dispatcher_impl.cc b/media/audio/audio_output_dispatcher_impl.cc
|
| index eaac8a4daae98c4e0167fe57da5c5d147aecf78a..1fd0371d5a3545fae64fab914683e3949b61ddae 100644
|
| --- a/media/audio/audio_output_dispatcher_impl.cc
|
| +++ b/media/audio/audio_output_dispatcher_impl.cc
|
| @@ -13,8 +13,13 @@
|
| #include "media/audio/audio_io.h"
|
| #include "media/audio/audio_output_proxy.h"
|
|
|
| +#include "content/browser/media/media_internals.h"
|
| +
|
| namespace media {
|
|
|
| +static int g_stream_id = 0;
|
| +static std::map<void*, int> g_stream_id_map;
|
| +
|
| AudioOutputDispatcherImpl::AudioOutputDispatcherImpl(
|
| AudioManager* audio_manager,
|
| const AudioParameters& params,
|
| @@ -77,6 +82,10 @@ bool AudioOutputDispatcherImpl::StartStream(
|
| physical_stream->SetVolume(volume);
|
| physical_stream->Start(callback);
|
| proxy_to_physical_map_[stream_proxy] = physical_stream;
|
| +
|
| + audio_manager_->GetMediaInternals()->OnSetAudioStreamPlaying(
|
| + this, g_stream_id_map[physical_stream], true);
|
| +
|
| return true;
|
| }
|
|
|
| @@ -94,6 +103,9 @@ void AudioOutputDispatcherImpl::StopStream(AudioOutputProxy* stream_proxy) {
|
|
|
| pausing_streams_.push_front(physical_stream);
|
|
|
| + audio_manager_->GetMediaInternals()->OnSetAudioStreamPlaying(
|
| + this, g_stream_id_map[physical_stream], false);
|
| +
|
| // Don't recycle stream until two buffers worth of time has elapsed.
|
| message_loop_->PostDelayedTask(
|
| FROM_HERE,
|
| @@ -109,6 +121,8 @@ void AudioOutputDispatcherImpl::StreamVolumeSet(AudioOutputProxy* stream_proxy,
|
| if (it != proxy_to_physical_map_.end()) {
|
| AudioOutputStream* physical_stream = it->second;
|
| physical_stream->SetVolume(volume);
|
| + audio_manager_->GetMediaInternals()->OnSetAudioStreamVolume(
|
| + this, g_stream_id_map[physical_stream], volume);
|
| }
|
| }
|
|
|
| @@ -124,6 +138,13 @@ void AudioOutputDispatcherImpl::StopStreamTask() {
|
| close_timer_.Reset();
|
| }
|
|
|
| +void AudioOutputDispatcherImpl::LogCloseStream(AudioOutputStream* stream) {
|
| + audio_manager_->GetMediaInternals()->OnSetAudioStreamStatus(
|
| + this, g_stream_id_map[stream], "closed");
|
| + audio_manager_->GetMediaInternals()->OnDeleteAudioStream(
|
| + this, g_stream_id_map[stream]);
|
| +}
|
| +
|
| void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
|
| DCHECK(message_loop_->BelongsToCurrentThread());
|
|
|
| @@ -137,6 +158,7 @@ void AudioOutputDispatcherImpl::CloseStream(AudioOutputProxy* stream_proxy) {
|
|
|
| while (idle_streams_.size() > paused_proxies_) {
|
| idle_streams_.back()->Close();
|
| + LogCloseStream(idle_streams_.back());
|
| idle_streams_.pop_back();
|
| }
|
| }
|
| @@ -152,13 +174,17 @@ void AudioOutputDispatcherImpl::Shutdown() {
|
| DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference";
|
|
|
| AudioOutputStreamList::iterator it = idle_streams_.begin();
|
| - for (; it != idle_streams_.end(); ++it)
|
| + for (; it != idle_streams_.end(); ++it) {
|
| (*it)->Close();
|
| + LogCloseStream(*it);
|
| + }
|
| idle_streams_.clear();
|
|
|
| it = pausing_streams_.begin();
|
| - for (; it != pausing_streams_.end(); ++it)
|
| + for (; it != pausing_streams_.end(); ++it) {
|
| (*it)->Close();
|
| + LogCloseStream(*it);
|
| + }
|
| pausing_streams_.clear();
|
| }
|
|
|
| @@ -173,6 +199,11 @@ bool AudioOutputDispatcherImpl::CreateAndOpenStream() {
|
| stream->Close();
|
| return false;
|
| }
|
| +
|
| + g_stream_id_map[stream] = g_stream_id;
|
| + audio_manager_->GetMediaInternals()->OnAudioStreamCreated(
|
| + this, g_stream_id++, params_, input_device_id_);
|
| +
|
| idle_streams_.push_back(stream);
|
| return true;
|
| }
|
| @@ -182,6 +213,7 @@ void AudioOutputDispatcherImpl::ClosePendingStreams() {
|
| DCHECK(message_loop_->BelongsToCurrentThread());
|
| while (!idle_streams_.empty()) {
|
| idle_streams_.back()->Close();
|
| + LogCloseStream(idle_streams_.back());
|
| idle_streams_.pop_back();
|
| }
|
| }
|
|
|