Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/audio_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() {}
26 26
27 /////////////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////////////
28 // AudioRendererHost implementations. 28 // AudioRendererHost implementations.
29 AudioRendererHost::AudioRendererHost( 29 AudioRendererHost::AudioRendererHost(
30 AudioManager* audio_manager, 30 media::AudioManager* audio_manager,
31 content::MediaObserver* media_observer) 31 content::MediaObserver* media_observer)
32 : audio_manager_(audio_manager), 32 : audio_manager_(audio_manager),
33 media_observer_(media_observer) { 33 media_observer_(media_observer) {
34 } 34 }
35 35
36 AudioRendererHost::~AudioRendererHost() { 36 AudioRendererHost::~AudioRendererHost() {
37 DCHECK(audio_entries_.empty()); 37 DCHECK(audio_entries_.empty());
38 } 38 }
39 39
40 void AudioRendererHost::OnChannelClosing() { 40 void AudioRendererHost::OnChannelClosing() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream) 185 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream)
186 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream) 186 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream)
187 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume) 187 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume)
188 IPC_MESSAGE_UNHANDLED(handled = false) 188 IPC_MESSAGE_UNHANDLED(handled = false)
189 IPC_END_MESSAGE_MAP_EX() 189 IPC_END_MESSAGE_MAP_EX()
190 190
191 return handled; 191 return handled;
192 } 192 }
193 193
194 void AudioRendererHost::OnCreateStream( 194 void AudioRendererHost::OnCreateStream(
195 int stream_id, const AudioParameters& params) { 195 int stream_id, const media::AudioParameters& params) {
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
197 DCHECK(LookupById(stream_id) == NULL); 197 DCHECK(LookupById(stream_id) == NULL);
198 198
199 AudioParameters audio_params(params); 199 media::AudioParameters audio_params(params);
200 DCHECK_GT(audio_params.frames_per_buffer(), 0); 200 DCHECK_GT(audio_params.frames_per_buffer(), 0);
201 201
202 uint32 buffer_size = audio_params.GetBytesPerBuffer(); 202 uint32 buffer_size = audio_params.GetBytesPerBuffer();
203 203
204 scoped_ptr<AudioEntry> entry(new AudioEntry()); 204 scoped_ptr<AudioEntry> entry(new AudioEntry());
205 205
206 // Create the shared memory and share with the renderer process. 206 // Create the shared memory and share with the renderer process.
207 uint32 shared_memory_size = 207 uint32 shared_memory_size =
208 media::TotalSharedMemorySizeInBytes(buffer_size); 208 media::TotalSharedMemorySizeInBytes(buffer_size);
209 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) { 209 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 // Iterate the map of entries. 376 // Iterate the map of entries.
377 // TODO(hclam): Implement a faster look up method. 377 // TODO(hclam): Implement a faster look up method.
378 for (AudioEntryMap::iterator i = audio_entries_.begin(); 378 for (AudioEntryMap::iterator i = audio_entries_.begin();
379 i != audio_entries_.end(); ++i) { 379 i != audio_entries_.end(); ++i) {
380 if (!i->second->pending_close && controller == i->second->controller.get()) 380 if (!i->second->pending_close && controller == i->second->controller.get())
381 return i->second; 381 return i->second;
382 } 382 }
383 return NULL; 383 return NULL;
384 } 384 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698