| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 this, | 380 this, |
| 381 stream_id, | 381 stream_id, |
| 382 render_view_id, | 382 render_view_id, |
| 383 render_frame_id, | 383 render_frame_id, |
| 384 params, | 384 params, |
| 385 output_device_id, | 385 output_device_id, |
| 386 shared_memory.Pass(), | 386 shared_memory.Pass(), |
| 387 reader.PassAs<media::AudioOutputController::SyncReader>())); | 387 reader.PassAs<media::AudioOutputController::SyncReader>())); |
| 388 if (mirroring_manager_) { | 388 if (mirroring_manager_) { |
| 389 mirroring_manager_->AddDiverter( | 389 mirroring_manager_->AddDiverter( |
| 390 render_process_id_, entry->render_view_id(), entry->controller()); | 390 render_process_id_, entry->render_frame_id(), entry->controller()); |
| 391 } | 391 } |
| 392 audio_entries_.insert(std::make_pair(stream_id, entry.release())); | 392 audio_entries_.insert(std::make_pair(stream_id, entry.release())); |
| 393 audio_log_->OnCreated(stream_id, params, output_device_id); | 393 audio_log_->OnCreated(stream_id, params, output_device_id); |
| 394 } | 394 } |
| 395 | 395 |
| 396 void AudioRendererHost::OnPlayStream(int stream_id) { | 396 void AudioRendererHost::OnPlayStream(int stream_id) { |
| 397 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 397 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 398 | 398 |
| 399 AudioEntry* entry = LookupById(stream_id); | 399 AudioEntry* entry = LookupById(stream_id); |
| 400 if (!entry) { | 400 if (!entry) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 // Prevent oustanding callbacks from attempting to close/delete the same | 446 // Prevent oustanding callbacks from attempting to close/delete the same |
| 447 // AudioEntry twice. | 447 // AudioEntry twice. |
| 448 AudioEntryMap::iterator i = audio_entries_.find(stream_id); | 448 AudioEntryMap::iterator i = audio_entries_.find(stream_id); |
| 449 if (i == audio_entries_.end()) | 449 if (i == audio_entries_.end()) |
| 450 return; | 450 return; |
| 451 scoped_ptr<AudioEntry> entry(i->second); | 451 scoped_ptr<AudioEntry> entry(i->second); |
| 452 audio_entries_.erase(i); | 452 audio_entries_.erase(i); |
| 453 | 453 |
| 454 media::AudioOutputController* const controller = entry->controller(); | 454 media::AudioOutputController* const controller = entry->controller(); |
| 455 if (mirroring_manager_) { | 455 if (mirroring_manager_) |
| 456 mirroring_manager_->RemoveDiverter( | 456 mirroring_manager_->RemoveDiverter(controller); |
| 457 render_process_id_, entry->render_view_id(), controller); | |
| 458 } | |
| 459 controller->Close( | 457 controller->Close( |
| 460 base::Bind(&AudioRendererHost::DeleteEntry, this, base::Passed(&entry))); | 458 base::Bind(&AudioRendererHost::DeleteEntry, this, base::Passed(&entry))); |
| 461 audio_log_->OnClosed(stream_id); | 459 audio_log_->OnClosed(stream_id); |
| 462 } | 460 } |
| 463 | 461 |
| 464 void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) { | 462 void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) { |
| 465 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 463 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 466 | 464 |
| 467 // At this point, make the final "say" in audio playback state. | 465 // At this point, make the final "say" in audio playback state. |
| 468 MediaObserver* const media_observer = | 466 MediaObserver* const media_observer = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 496 | 494 |
| 497 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); | 495 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); |
| 498 return i != audio_entries_.end() ? i->second : NULL; | 496 return i != audio_entries_.end() ? i->second : NULL; |
| 499 } | 497 } |
| 500 | 498 |
| 501 bool AudioRendererHost::HasActiveAudio() { | 499 bool AudioRendererHost::HasActiveAudio() { |
| 502 return !base::AtomicRefCountIsZero(&num_playing_streams_); | 500 return !base::AtomicRefCountIsZero(&num_playing_streams_); |
| 503 } | 501 } |
| 504 | 502 |
| 505 } // namespace content | 503 } // namespace content |
| OLD | NEW |