 Chromium Code Reviews
 Chromium Code Reviews Issue 5158003:
  Implement AudioOutputProxy.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 5158003:
  Implement AudioOutputProxy.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "media/audio/audio_manager_base.h" | 5 #include "media/audio/audio_manager_base.h" | 
| 6 #include "media/audio/audio_output_proxy.h" | |
| 7 #include "media/audio/audio_output_dispatcher.h" | |
| 
scherkus (not reviewing)
2010/11/22 06:43:15
dispatcher should come before proxy
 
Sergey Ulanov
2010/11/23 19:51:46
Done.
 | |
| 8 | |
| 9 // CompareAudioParams is needed for map to use AudioParameters as a key. | |
| 10 bool AudioManagerBase::CompareAudioParams::operator()( | |
| 11 const AudioParameters& a, | |
| 12 const AudioParameters& b) const { | |
| 13 if (a.format < b.format) | |
| 14 return true; | |
| 15 if (a.format > b.format) | |
| 16 return false; | |
| 17 if (a.channels < b.channels) | |
| 18 return true; | |
| 19 if (a.channels > b.channels) | |
| 20 return false; | |
| 21 if (a.sample_rate < b.sample_rate) | |
| 22 return true; | |
| 23 if (a.sample_rate > b.sample_rate) | |
| 24 return false; | |
| 25 if (a.bits_per_sample < b.bits_per_sample) | |
| 26 return true; | |
| 27 if (a.bits_per_sample > b.bits_per_sample) | |
| 28 return false; | |
| 29 return a.samples_per_packet > b.samples_per_packet; | |
| 30 } | |
| 6 | 31 | 
| 7 AudioManagerBase::AudioManagerBase() | 32 AudioManagerBase::AudioManagerBase() | 
| 8 : audio_thread_("AudioThread"), | 33 : audio_thread_("AudioThread"), | 
| 9 initialized_(false) { | 34 initialized_(false) { | 
| 10 } | 35 } | 
| 11 | 36 | 
| 37 AudioManagerBase::~AudioManagerBase() { | |
| 38 } | |
| 39 | |
| 12 void AudioManagerBase::Init() { | 40 void AudioManagerBase::Init() { | 
| 13 initialized_ = audio_thread_.Start(); | 41 initialized_ = audio_thread_.Start(); | 
| 14 } | 42 } | 
| 15 | 43 | 
| 16 MessageLoop* AudioManagerBase::GetMessageLoop() { | 44 MessageLoop* AudioManagerBase::GetMessageLoop() { | 
| 17 DCHECK(initialized_); | 45 DCHECK(initialized_); | 
| 18 return audio_thread_.message_loop(); | 46 return audio_thread_.message_loop(); | 
| 19 } | 47 } | 
| 48 | |
| 49 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( | |
| 50 AudioParameters params) { | |
| 51 if (!initialized_) | |
| 52 return NULL; | |
| 53 | |
| 54 scoped_refptr<AudioOutputDispatcher>& dispatcher = | |
| 55 output_dispatchers_[params]; | |
| 
scherkus (not reviewing)
2010/11/22 06:43:15
I tend to avoid using operator[] with map since it
 
Sergey Ulanov
2010/11/23 19:51:46
Yes, and it is desired behavior here.
 
scherkus (not reviewing)
2010/11/24 02:01:59
Thanks for explaining -- SGTM!
 | |
| 56 if (!dispatcher) | |
| 57 dispatcher = new AudioOutputDispatcher(this, params); | |
| 58 | |
| 59 return new AudioOutputProxy(dispatcher); | |
| 60 } | |
| OLD | NEW |