| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/audio_renderer_host.h" | 5 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/process.h" | 8 #include "base/process.h" |
| 9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
| 10 #include "chrome/browser/renderer_host/audio_sync_reader.h" | 10 #include "chrome/browser/renderer_host/audio_sync_reader.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 SendErrorMessage(entry->render_view_id, entry->stream_id); | 453 SendErrorMessage(entry->render_view_id, entry->stream_id); |
| 454 CloseAndDeleteStream(entry); | 454 CloseAndDeleteStream(entry); |
| 455 } | 455 } |
| 456 | 456 |
| 457 AudioRendererHost::AudioEntry* AudioRendererHost::LookupById( | 457 AudioRendererHost::AudioEntry* AudioRendererHost::LookupById( |
| 458 int route_id, int stream_id) { | 458 int route_id, int stream_id) { |
| 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 460 | 460 |
| 461 AudioEntryMap::iterator i = audio_entries_.find( | 461 AudioEntryMap::iterator i = audio_entries_.find( |
| 462 AudioEntryId(route_id, stream_id)); | 462 AudioEntryId(route_id, stream_id)); |
| 463 if (i != audio_entries_.end()) | 463 if (i != audio_entries_.end() && !i->second->pending_close) |
| 464 return i->second; | 464 return i->second; |
| 465 return NULL; | 465 return NULL; |
| 466 } | 466 } |
| 467 | 467 |
| 468 AudioRendererHost::AudioEntry* AudioRendererHost::LookupByController( | 468 AudioRendererHost::AudioEntry* AudioRendererHost::LookupByController( |
| 469 media::AudioOutputController* controller) { | 469 media::AudioOutputController* controller) { |
| 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 471 | 471 |
| 472 // Iterate the map of entries. | 472 // Iterate the map of entries. |
| 473 // TODO(hclam): Implement a faster look up method. | 473 // TODO(hclam): Implement a faster look up method. |
| 474 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 474 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 475 i != audio_entries_.end(); ++i) { | 475 i != audio_entries_.end(); ++i) { |
| 476 if (controller == i->second->controller.get()) | 476 if (!i->second->pending_close && controller == i->second->controller.get()) |
| 477 return i->second; | 477 return i->second; |
| 478 } | 478 } |
| 479 return NULL; | 479 return NULL; |
| 480 } | 480 } |
| OLD | NEW |