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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "content/browser/browser_main_loop.h" | 11 #include "content/browser/browser_main_loop.h" |
12 #include "content/browser/renderer_host/media/audio_sync_reader.h" | 12 #include "content/browser/renderer_host/media/audio_sync_reader.h" |
13 #include "content/common/media/audio_messages.h" | 13 #include "content/common/media/audio_messages.h" |
14 #include "content/public/browser/media_observer.h" | 14 #include "content/public/browser/media_observer.h" |
15 #include "media/audio/audio_util.h" | 15 #include "media/audio/shared_memory_util.h" |
16 | 16 |
17 using content::BrowserMessageFilter; | 17 using content::BrowserMessageFilter; |
18 using content::BrowserThread; | 18 using content::BrowserThread; |
19 | 19 |
20 AudioRendererHost::AudioEntry::AudioEntry() | 20 AudioRendererHost::AudioEntry::AudioEntry() |
21 : stream_id(0), | 21 : stream_id(0), |
22 pending_close(false) { | 22 pending_close(false) { |
23 } | 23 } |
24 | 24 |
25 AudioRendererHost::AudioEntry::~AudioEntry() {} | 25 AudioRendererHost::AudioEntry::~AudioEntry() {} |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (!reader->PrepareForeignSocketHandle(peer_handle(), | 128 if (!reader->PrepareForeignSocketHandle(peer_handle(), |
129 &foreign_socket_handle)) { | 129 &foreign_socket_handle)) { |
130 DeleteEntryOnError(entry); | 130 DeleteEntryOnError(entry); |
131 return; | 131 return; |
132 } | 132 } |
133 | 133 |
134 Send(new AudioMsg_NotifyStreamCreated( | 134 Send(new AudioMsg_NotifyStreamCreated( |
135 entry->stream_id, | 135 entry->stream_id, |
136 foreign_memory_handle, | 136 foreign_memory_handle, |
137 foreign_socket_handle, | 137 foreign_socket_handle, |
138 media::PacketSizeSizeInBytes(entry->shared_memory.created_size()))); | 138 media::PacketSizeInBytes(entry->shared_memory.created_size()))); |
139 } | 139 } |
140 | 140 |
141 void AudioRendererHost::DoSendPlayingMessage( | 141 void AudioRendererHost::DoSendPlayingMessage( |
142 media::AudioOutputController* controller) { | 142 media::AudioOutputController* controller) { |
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
144 | 144 |
145 AudioEntry* entry = LookupByController(controller); | 145 AudioEntry* entry = LookupByController(controller); |
146 if (!entry) | 146 if (!entry) |
147 return; | 147 return; |
148 | 148 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 // Iterate the map of entries. | 377 // Iterate the map of entries. |
378 // TODO(hclam): Implement a faster look up method. | 378 // TODO(hclam): Implement a faster look up method. |
379 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 379 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
380 i != audio_entries_.end(); ++i) { | 380 i != audio_entries_.end(); ++i) { |
381 if (!i->second->pending_close && controller == i->second->controller.get()) | 381 if (!i->second->pending_close && controller == i->second->controller.get()) |
382 return i->second; | 382 return i->second; |
383 } | 383 } |
384 return NULL; | 384 return NULL; |
385 } | 385 } |
OLD | NEW |